0
votes

Is it possible to use a TFS 2018 Server (Version 16.131.27701.1) to build a C# program with Visual Studio 2019? If so, how?

I have a build agent (with Azure Pipelines Agent v2.184.0) that has Visual Studio 2019 installed. TFS says it has the following capabilites:

MSBuild capabilities

Visual Studio capabilities

In my build pipeline I tried both the Visual Studio Build task and the MSBuild task. However with both tasks, I can only select a Visual Studio version up to 2017:

Visual Studio version selection MSBuild version selection

When using "Latest", it automatically falls back to using 4.0:

Project file contains ToolsVersion="16.0". This toolset may be unknown or missing, in which case you may be able to resolve this by installing the appropriate version of MSBuild, or the build may have been forced to a particular ToolsVersion for policy reasons. Treating the project as if it had ToolsVersion="4.0".

I even tried setting the path to MSBuild 16.0 manually:

MSBuild path

Then I get a different error:

C:\Program Files\dotnet\sdk\5.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(241,5): Error NETSDK1004: Assets file 'C:\Users[...]\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.

However the NuGet Restore task is right before the MSBuild task and it completed successfully!

1

1 Answers

0
votes

Usually VS and TFS will match the current versions, the root cause is that the agent of TFS 2018 cannot identify the capabilities of VS 2019 since VS 2019 is not released that time. For example in TFS 2018, it will support VS 2017 and previous versions, in Azure DevOps server 2019 it will support the VS 2019 and previous versions. And at present, we find some developer can make the VS2019 works in the TFS2018 by using the agent 2.159.2. We recommend you can download the version 2.159.2 and use the MSbuild task to try again.