Today I was busy setting up a new CI pipeline on Azure DevOps. As part of this pipeline I wanted to create a web deploy package that later can be picked up by a release pipeline to deploy it on multiple environments.
Here is the pipeline I created:
# Starter pipeline | |
# Start with a minimal pipeline that you can customize to build and deploy your code. | |
# Add steps that build, run tests, deploy, and more: | |
# https://aka.ms/yaml | |
trigger: | |
- master | |
pool: | |
vmImage: 'ubuntu-latest' | |
variables: | |
solution: '**/*.sln' | |
buildPlatform: 'Any CPU' | |
buildConfiguration: 'Development' | |
artifactName: 'WebDeployArtifact' | |
steps: | |
- task: DotNetCoreCLI@2 | |
displayName: 'dotnet build' | |
inputs: | |
projects: '**/*.csproj' | |
arguments: '--configuration $(buildConfiguration)' | |
- task: DotNetCoreCLI@2 | |
displayName: 'Run tests' | |
inputs: | |
command: 'test' | |
projects: '**/*[Tt]ests/*.csproj' | |
- task: DotNetCoreCLI@2 | |
displayName: 'Publish service' | |
inputs: | |
command: 'publish' | |
publishWebProjects: true | |
arguments: '--configuration $(BuildConfiguration) /p:WebPublishMethod=Package /p:PackageLocation="$(build.artifactStagingDirectory)""' | |
zipAfterPublish: false | |
modifyOutputPath: false | |
- task: PublishBuildArtifacts@1 | |
displayName: 'Publish Artifact' | |
inputs: | |
PathtoPublish: '$(build.artifactStagingDirectory)' | |
ArtifactName: $(artifactName) | |
Unfortunately when I tried to run this pipeline, it failed with the following error message:
/usr/share/dotnet/sdk/6.0.401/Sdks/Microsoft.NET.Sdk.Publish/targets/PublishTargets/Microsoft.NET.Sdk.Publish.MSDeployPackage.targets(97,5): error MSB6004: The specified task executable location "%ProgramW6432%/IIS/Microsoft Web Deploy V3/msdeploy.exe" is invalid. [/home/vsts/work/1/s/Example/Example.csproj]
##[error]Error: The process '/usr/bin/dotnet' failed with exit code 1
The reason why this fails is because MSDeploy
is a Windows-only thing. Inside my pipeline I had specified to use a Linux build server. That explains why it cannot find "%ProgramW6432%/IIS/Microsoft Web Deploy V3/msdeploy.exe".
To fix it, I updated my pipeline to use a Windows VM instead:
# Starter pipeline | |
# Start with a minimal pipeline that you can customize to build and deploy your code. | |
# Add steps that build, run tests, deploy, and more: | |
# https://aka.ms/yaml | |
trigger: | |
- master | |
pool: | |
vmImage: 'windows-latest' |