Search code examples
azure-devopsazure-devops-hosted-agent

Can I use a hosted build agent to build a VS 2019 project that targets both netcore 2.1 and 3.1?


I had a VS 2017 project that targeted netcore 2.1. This was built and deployed using a YAML build pipeline on the hosted vs 2017 agent.

We needed to support netcore 3.1 as well as 2.1 so I updated the project to VS 2019 and changed it to multi-target both netcore 2.1 and 3.1. This builds fine on my dev machine but (obviously) failed on the existing build pipeline that uses the vs 2017 image.

Based on the documentation I have update the build pipeline to use the 'windows-2019' vm image.

However, this gives me the following error message:

The framework 'Microsoft.NETCore.App', version '2.1.0' was not found.

I'd rather not create and maintain a build server internally for this so is it possible on a hosted agent?


Solution

  • This turns out to have been caused by the test projects still targeting netcore 2.1.

    Our build pipeline runs tests (using the vstest task) on both x86 and x64 and it was only the x86 tests that were failing.

    After we updated the test projects to netcore 3.1, it worked as expected and the tests passed.