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.
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.
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.
Unfortunately this did not solve the problem as there was a further error about version numbers.
Unable to resolve 'Microsoft.NETCore.App (>= 2.1.0)' for '.NETCoreApp,Version=v2.1'.
This got me thinking. As part of the preview if you wanted to run a preview web application on Azure then you had to enable the preview build extension. Would VSTS be the same?
I came across an issue in VSTS-agent GitHub repository which pointed me towards the
.NET Core Tool Installer so I added one in.
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.
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