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
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:
- Goto Build, Click „New“ and select „Visual Studio“ as Build definition.Create new Build definition
- Select your repository and branch to build.
- Delete all for .Net Core unnecessary tasks. I suggest to keep Nuget restore as some projects might still need that.
- Click „Add build step…“ and add „.Net Core (PREVIEW)“ four times. One for each step you need to perform.
- 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.
- Configure dotnet restore task. Insert the desired project.json file. The „**/“ tells the task to use every project.json it finds within the solution.
- Configure dotnet build task.
- Configure dotnet test task.
- 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.
- 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.
- 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.
- 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 a.net 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 🙂