Menu

ASP.NET Core 2.1 Preview on VSTS

As part of my ongoing work to create an ASP.NET Core Webhook I have been looking at getting an automated build setup on VSTS to build, test and publish the package to nuget. However when I setup a new build definition it would not build.

This is how I solved this problem.

Setup

After pushing my source code to a git repository in VSTS I created a new Build definition. As part of the setup I chose the "ASP.NET Core" featured template.

This sets up a basic template which restores, builds, runs tests and publishes the output.

However this would not restore the nuget packages the project relied on as they were preview packages from the myget feed.

NuGet.config

To specify the package sources to use I added a NuGet.config file to the root of the repository and updated the restore step to use this file.

Version issues

Unfortunately this did not solve the problem as there was a further error about version numbers.

From a different Github Issue on the dotnet repository it suggested it should be possible to install and use the preview!

.NET Core Tool Installer Task

This tool allows for you to specify the SDK or Runtime version you need for your build pipeline and downloads them for you to use in the duration of the build. The 3rd example (yes I know it says 2 twice!) shows how to add in a preview version.

I updated the task information to install an SDK and specified the version as 2.1.300-preview1-008174 (below) and kicked off a build.

Success!

Conclusion

In this post I have outlined how I got a VSTS build definition to install the new ASP.NET Core 2 Preview SDK to build a 2.1 targetted project.

Any comments, queries or suggestions then please contact me on Twitter @WestDiscGolf