Enable VSTS hosted build for dotnetcore (csproj)

The recent decision by Microsoft to move away from project.json/xproj dotnetcore structure to the MSBuild compatible csproj structure has been met with mixed reviews in the development community. Personally, I'm not a massive fan, but my biggest bug bear has came from the fact that the Visual Studio Team Services (VSTS) build systems lagged behind this release. Meaning that I couldn't upgrade to the newest project structure without breaking my build pipelines. The advice from Microsoft. Host your own build agents. Ok, that's a viable work around but I am using hosted build/deploy agents for a reason, I don't want to maintain my own infrastructure!

Luckily, this issue has now been rectified and the VSTS hosted build agents can now support both project structures.

If you have an existing build pipeline set-up on VSTS hosted builds you'll notice that the build will fail with an error message along the lines of

Invalid input 'd:\a\1\s\MyProject\MyProject.csproj'. The file type was not recognized.

The two versions of dotnet core cannot reside side by side, so a whole new hosted build agent has been created by the VSTS team. By default, your build will be set-up to run against the "Hosted" build agent, to change this to the new build agent follow these steps:

  • Log in to visualstudio.com and navigate to the team project you would like to change.

  • Click on the "Build & Releases" tab, and navigate to the build you wish to change.

Build and Releases tab

  • Click the "Edit" link next to the "Queue new build..." button, to edit the build definition.

Edit build definition

  • Update any build/restore tasks that currently point at the old project.json/*.xproj file to now point at the new *.cspoj file.

  • Navigate to the "Options" tab, and you should see that the build agent is set to "Hosted" or "Default". Change this to the "Hosted VS2017" option.

Hosted VS2017 Option

  • Then click the "Save & Queue" button.

The build should now complete successfully.