I am new to Azure build pipeline and some extent I have managed to create a build and publish artifact.
Issue: when build is ready and I am copying artifact and it goes to some weird path which I can see after downloading it.
Like ==> My.Web\Content\D_C\a\1\s\My.Web\obj\Release\Package\PackageTmp
I just need zip that contain publish version that can be directly copy to IIS.
trigger:
- '*'
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/t:build /p:DeployOnBuild=true /p:OutputPath="$(Build.ArtifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(build.artifactStagingDirectory)\_PublishedWebsites\My.Web_Package\My.Web.zip'
publishLocation: 'pipeline'
artifact: 'drop'
name: 'WebArtifact-$(Build.BuildNumber)'
Let me know what wrong I am doing, Also under my solution there are multiple project library but I need single publish version for ASP.NET MVC 5 web project application which is in my solution .
Please guild if there is better way to write this pipeline.
Also let me know if we can add build number / version number for the same.
Really appreciate your any suggestion and input.
The Artifact will be Published in the Default
The VS Build task will build your app similar to the Visual Studio that uses MSBuild to build your task.
Visual Studio:-
Ms Build is used to build the app:-
I built the app and published it into a local folder and this is how the build folder looks like:-
Azure Build Pipeline:-
The same thing happens in your Azure DevOps pipeline, The Build is done with Ms Build when you use Vs Build and the published artifact is stored in -
$(Build.ArtifactStagingDirectory)> According to this MS Document:Build.ArtifactStagingDirectoryis the predefined variables of Azure DevOps Agent that you are using to run the pipeline. As you are using windows-latest as an agent, the Build.ArtifactStagingDirectory routes toc:\agent_work\1\a. Thus it is getting stored to the default location above.I have used below YAML pipeline to build the
Asp.Net MVC 5project and publish it aszipwith published artifact name set to the build-number.Reference for VsBuild here.
Output:-
But, Instead of using
VSbuild task, And as you need to manage multiple packages and libraries, I recommend using.NET Core CLItask to build your application and then publish it into IIS like below:-There is
zipAfterPublish: trueparameter which will zip the build artifact after its built is complete.Output:-