Created
May 31, 2022 18:50
-
-
Save luuksommers/7dd10db8435d7d3624343021abecd53d to your computer and use it in GitHub Desktop.
Gitlab CI dotnet iis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file shows how to setup the template for your projects | |
include: | |
- project: 'templates' | |
file: 'gitlab-templates/dotnet-framework.v1.gitlab-ci.yml' | |
variables: | |
ENABLE_UNITTESTS: 'true' | |
DEFAULT_IIS_SITENAME: "my-awesome-deployment.nl" # For dev deploys this gets prefixed with 'development.', for prod it gets prefixed with 'www.' | |
DEFAULT_DEVELOPMENT_URL: "https://my-awesome-deployment.devserver.nl/" | |
DEFAULT_PRODUCTION_URL: "https://www.my-awesome-deployment.nl/" | |
# If you want to do some additional things during the default steps, | |
# for example build node stuff, you can do that in the 'before_script' | |
build_debug: | |
cache: | |
key: npm-cache | |
paths: | |
- '$env:CI_PROJECT_DIR\\.npm\\' | |
before_script: | |
- 'npm ci --cache $env:CI_PROJECT_DIR\\.npm --prefer-offline' | |
- 'npx lerna bootstrap -- --cache $env:CI_PROJECT_DIR\\.npm --prefer-offline' | |
- 'npx lerna run test' | |
- 'npx lerna run build' | |
# Or you can overrule the variables for the seperate steps | |
deploy_production: | |
variables: | |
IIS_SERVER: 'overruled-prodserver.nl' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include: | |
- project: 'templates' # refer to the base template of dotnet-framework.v1.gitlab-ci.yml | |
file: 'gitlab-templates/dotnet-framework.v1.gitlab-ci.yml' | |
build_debug: | |
stage: build | |
script: | |
- 'dotnet restore' | |
- 'dotnet build --nologo --no-restore --verbosity quiet /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:PackageLocation="$CI_PROJECT_DIR\$PACKAGE_TO_DEPLOY" /p:Configuration=Debug /p:EnvironmentName=Staging' | |
# INSTALL https://www.nuget.org/packages/JUnitXml.TestLogger/ into the test projects | |
test: | |
script: | |
- 'dotnet restore' | |
- 'dotnet test --no-restore --test-adapter-path:. --logger:"junit;LogFilePath=..\..\artifacts\{assembly}-test-result.xml;MethodFormat=Class;FailureBodyFormat=Verbose"' | |
build_release: | |
stage: build | |
script: | |
- 'dotnet restore' | |
- 'dotnet build --nologo --no-restore --verbosity quiet /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:PackageLocation="$CI_PROJECT_DIR\$PACKAGE_TO_DEPLOY" /p:Configuration=Release /p:EnvironmentName=Production' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is de default build script for .net solutions | |
# To implement this, override the variables with [OVERRIDE THIS VARIABLE] | |
# Or overrule parts of the script that dont fit your needs | |
# See https://docs.gitlab.com/ee/ci/yaml/includes.html | |
# The deployment phase expects a MSDEPLOY package as a zip file in artifacts\website.zip | |
# To overrule the file location update the PACKAGE_TO_DEPLOY variable. | |
include: | |
- template: "Workflows/MergeRequest-Pipelines.gitlab-ci.yml" | |
stages: | |
- build | |
- test | |
- deploy | |
variables: | |
ENABLE_UNITTESTS: 'false' | |
DEFAULT_IIS_SITENAME: "[OVERRIDE THIS VARIABLE]" | |
DEFAULT_DEVELOPMENT_URL: "[OVERRIDE THIS VARIABLE]" | |
DEFAULT_PRODUCTION_URL: "[OVERRIDE THIS VARIABLE]" | |
PACKAGE_TO_DEPLOY: 'artifacts\website.zip' | |
NUGET_PATH: 'C:\tools\build\nuget.exe' | |
MSBUILD_PATH: 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe' | |
MSDEPLOY_PATH: 'C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe' | |
validate_tag: | |
stage: .pre | |
script: | |
- echo Release tags should follow semver numbering | |
- echo For example "1.0.3" | |
- exit 1 | |
tags: | |
- windows | |
rules: | |
- if: $CI_COMMIT_TAG && $CI_COMMIT_TAG !~ /^[0-9]+[.][0-9]+[.][0-9]+$/ | |
build_debug: | |
stage: build | |
script: | |
- '& "$env:NUGET_PATH" restore -Verbosity quiet' | |
- '& "$env:MSBUILD_PATH" /p:DeployOnBuild=true /p:DeployTarget=Package /p:PackageLocation="$env:CI_PROJECT_DIR\$env:PACKAGE_TO_DEPLOY" /p:Configuration=Debug -consoleloggerparameters:"ErrorsOnly;Summary" -verbosity:quiet -m' | |
artifacts: | |
expire_in: 5 days | |
paths: | |
- '$env:PACKAGE_TO_DEPLOY' | |
tags: | |
- windows | |
rules: | |
- if: $CI_COMMIT_TAG | |
when: never | |
- if: $CI_MERGE_REQUEST_IID | |
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH | |
# INSTALL https://www.nuget.org/packages/JUnitXml.TestLogger/ into the test projects | |
test: | |
stage: test | |
script: | |
- '& "$env:NUGET_PATH" restore -Verbosity quiet' | |
- '& "$env:MSBUILD_PATH" /p:DeployOnBuild=true /p:DeployTarget=Package /p:PackageLocation="$env:CI_PROJECT_DIR\$env:PACKAGE_TO_DEPLOY" /p:Configuration=Debug -consoleloggerparameters:"ErrorsOnly;Summary" -verbosity:quiet -m' | |
- 'dotnet test tests\**\bin\**\*.Tests.dll --test-adapter-path:. --logger:"junit;LogFilePath=.\artifacts\{assembly}-test-result.xml;MethodFormat=Class;FailureBodyFormat=Verbose"' | |
artifacts: | |
when: always # save test results even when the task fails | |
expire_in: 1 week | |
paths: | |
- artifacts/*test-result.xml | |
reports: | |
junit: | |
- artifacts/*test-result.xml | |
tags: | |
- windows | |
rules: | |
- if: $ENABLE_UNITTESTS == 'false' | |
when: never | |
- if: $CI_COMMIT_TAG | |
when: never | |
- if: $CI_MERGE_REQUEST_IID | |
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH | |
deploy_development: | |
environment: | |
name: development | |
url: $DEFAULT_DEVELOPMENT_URL | |
stage: deploy | |
variables: | |
IIS_SERVER: 'devserver.nl' | |
IIS_SITENAME: development.$DEFAULT_IIS_SITENAME | |
IIS_WEBDEPLOY_USERNAME: $DEVSERVER_WEBDEPLOY_USERNAME # SET BY CI/CD Protected variables | |
IIS_WEBDEPLOY_PASSWORD: $DEVSERVER_WEBDEPLOY_PASSWORD # SET BY CI/CD Protected variables | |
script: | |
- | | |
$arguments = [string[]]@( | |
"-verb:sync", | |
"-source:package='$PACKAGE_TO_DEPLOY'", | |
"-dest:auto,computerName='https://${IIS_SERVER}:8172/msdeploy.axd?site=$IIS_SITENAME',userName='$IIS_WEBDEPLOY_USERNAME',password='$IIS_WEBDEPLOY_PASSWORD',authtype='Basic'", | |
"-setParam:name='IIS Web Application Name',value='$IIS_SITENAME'", | |
"-allowUntrusted", | |
"-skip:Directory='App_Data'", | |
"-skip:skipaction='Delete',objectname='dirPath',absolutepath='\\media'") | |
- Start-Process "$env:MSDEPLOY_PATH" -ArgumentList $arguments -NoNewWindow -Wait | |
tags: | |
- windows | |
rules: | |
- if: $CI_COMMIT_TAG | |
when: never | |
- if: $CI_MERGE_REQUEST_IID | |
when: manual | |
allow_failure: true | |
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH | |
dependencies: | |
- build_debug | |
build_release: | |
stage: build | |
script: | |
- '& "$env:NUGET_PATH" restore -Verbosity quiet' | |
- '& "$env:MSBUILD_PATH" /p:DeployOnBuild=true /p:DeployTarget=Package /p:PackageLocation="$env:CI_PROJECT_DIR\$env:PACKAGE_TO_DEPLOY" /p:Configuration=Release -consoleloggerparameters:"ErrorsOnly;Summary" -verbosity:quiet -m' | |
artifacts: | |
paths: | |
- '$PACKAGE_TO_DEPLOY' | |
tags: | |
- windows | |
rules: | |
- if: $CI_COMMIT_TAG | |
deploy_production: | |
environment: | |
name: production | |
url: $DEFAULT_PRODUCTION_URL | |
stage: deploy | |
variables: | |
IIS_SERVER: 'prodserver.nl' | |
IIS_SITENAME: www.$DEFAULT_IIS_SITENAME | |
IIS_WEBDEPLOY_USERNAME: $PRODSERVER_WEBDEPLOY_USERNAME # SET BY CI/CD Protected variables | |
IIS_WEBDEPLOY_PASSWORD: $PRODSERVER_WEBDEPLOY_PASSWORD # SET BY CI/CD Protected variables | |
script: | |
- | | |
$arguments = [string[]]@( | |
"-verb:sync", | |
"-source:package='$PACKAGE_TO_DEPLOY'", | |
"-dest:auto,computerName='https://${IIS_SERVER}:8172/msdeploy.axd?site=$IIS_SITENAME',userName='$IIS_WEBDEPLOY_USERNAME',password='$IIS_WEBDEPLOY_PASSWORD',authtype='Basic'", | |
"-setParam:name='IIS Web Application Name',value='$IIS_SITENAME'", | |
"-allowUntrusted", | |
"-skip:Directory='App_Data'", | |
"-skip:skipaction='Delete',objectname='dirPath',absolutepath='\\media'") | |
- Start-Process "$env:MSDEPLOY_PATH" -ArgumentList $arguments -NoNewWindow -Wait | |
tags: | |
- windows | |
rules: | |
- if: $CI_COMMIT_TAG | |
when: manual | |
dependencies: | |
- build_release |
Hi, I currently struggling to find any useful information about GitLab pipelines & deployment on IIS Servers. For now I found nothing that covers this topic completely. I hope you could make any video or short tutorial somewhere. Thank you in advance.
I'll help you with problem but not good at teaching
Thank you,
vivek
…On Wed, Dec 18, 2024, 8:48 PM Piotr Lebelt ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
Hi, I currently struggling to find any useful information about GitLab
pipelines & deployment on IIS Servers. For now I found nothing that covers
this topic completely. I hope you could make any video or short tutorial
somewhere. Thank you in advance.
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/luuksommers/7dd10db8435d7d3624343021abecd53d#gistcomment-5348034>
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AYR56LNCWJR4XGPHZMNUL3D2GGG33BFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVEYTCNRWGAYDCMBWU52HE2LHM5SXFJTDOJSWC5DF>
.
You are receiving this email because you commented on the thread.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>
.
Indeed, in case you have a specific question, please let us know. This gist is for example missing the IIS configuration; but it's more of a reference implementation of how you can do certain things in gitlab ci.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It shows job success but I didn't see any artifact that has been sent to the deployment server (IIS).