Create a Visual Studio Online Build Definition for .Net Core

Finally the new preview for .Net Core Build Tasks are available. Basically they are a wrapper for the dotnet.exe file and provide a possibility to execute the dotnet commands

  • build
  • publish
  • restore
  • test
  • run

The Visual Studio Online .Net Core tasks provide the possibility to select the parameters from a drop down, insert a reference to a project.json file and add additional arguments.

The parameter publish additionally provides the option to „publish web projects“. If you want to build e.g. a console application you need to uncheck this option. Additionally you can select to „Zip Published Projects“. This option stores the published package as Zip within the artifacts folder.

The Control Options within the .Net Core Build Tasks are standard.

Sadly using the .net code test-parameter does not integrate with the test results of the build. So you will not see the executed number of tests. But maybe this will follow in a future release 🙂

Howto create Visual Studio Online .Net Core Build Definition

Steps to create the visual studio online .Net Core Build Task:

  1. Goto Build, Click „New“ and select „Visual Studio“ as Build definition.Create new Build definition
  2. Select your repository and branch to build.
  3. Delete all for .Net Core unnecessary tasks. I suggest to keep Nuget restore as some projects might still need that.
  4. Click „Add build step…“ and add „.Net Core (PREVIEW)“ four times. One for each step you need to perform.
  5. Reorder the Tasks and configure the following command for each .Net Core task: restore, build, test, publish. The next steps will show the configuration in detail.
  6. Configure dotnet restore task. Insert the desired project.json file. The „**/“ tells the task to use every project.json it finds within the solution.
  7. Configure dotnet build task.
  8. Configure dotnet test task.
  9. Configure dotnet publish task. As argument here you should add the built in staging directory so the final package is stored there and can be used within the next build step. In this example I use a console application, therefore I do not check the „Publish Web Projects“ checkbox and I like the package to be zipped.
  10. Check the configuration of the „Publish Artifact“ task. By default the build.artifactsstagingdirectory variable should be inserted. This takes care about uploading the package into the artifacts folder so you can download it from the server after it has been built ore use it in the release process.
  11. Now you can save the build definition and „Queue new build…“. If necessary change the Queue and Branch, I keep the default. And click OK.
  12. Now wait for the Build to complete and you should get a valid build. Now you can navigate to the „Artifacts“ section and download your package.

As a conclution building Core Project with Visual Studio Online has become pretty easy with the new preview tasks and can be set up within 5 minutes. I think it’s awesome, and hope you enjoy.

Happy building 🙂

Schreibe einen Kommentar