To continue from my last post where we published the Test Results, it makes sense I should continue and package the site and create an artifact to use later with Release Management.
I am going to edit the same build definition from the last blog post and add a new Command Line task from the catalogue to execute dotnet publish.
Click Add build step… and choose Utility section to get the Command Line task. Click Add and move the task directly under the Publish Test Results task we added previously.
We will set the following values for the Command Line task:
- Tool: C:\Program Files\dotnet\dotnet.exe
- Arguments: publish $(Build.SourcesDirectory)\src\MusicStore –framework $(PublishFramework) –output $(Build.ArtifactStagingDirectory)\publish –configuration $(BuildConfiguration)
- Working folder: $(Build.SourcesDirectory)
I created a variable for PublishFramework and set it to net451 to use in the task above.
Disable the Publish Symbols Path and Copy Files to: $(build.artifactstagingdirectory) as they are no longer required (part of template). Now save the changes to your build definition and queue a new build.
After approximately 13 minutes you should have a successful build and you can see the results of the dotnet publish command (success) and now we’re ready to create our build artifact.
Now let’s edit the build definition to grab the folder created as part of the publish. We’ll add a Zip A Folder tasks to package it up nicely.
Add the Zip A Folder task immediately after the Run dotnet publish task and set the following values
- Path to folder: $(Build.ArtifactStagingDirectory)\publish
- Path to the zip file: $(Build.ArtifactStagingDirectory)\publish-iis.zip
It should look like this, if you cannot find this task as part of the Release Management Utility tasks. You can install it from the VS Marketplace and install it to use on-premises or VSTS.
Now we can edit the Publish Artifact MusicStore task so it picks up the Zip file we created in the previous step. The Publish Artifact task needs to get the zip file, so we’ll set the following values for the task:
- Path to Publish: $(Build.ArtifactStagingDirectory)\publish-iis.zip
- Artifact Name: MuiscStore-Package
- Artifact Type: Server
- Always Run: Not Checked
Save the build definition and Queue a new build to add the Zip file as an artifact to your build.
If you view the Build Summary and click on the Artifacts link you can explore the MusicStore-Package to view your Zip file.
You now have an artifact you can use in your Release Management pipeline.
If you have any comments or feedback on the steps above please let me know.