0
votes

Ran into this issue again, but the previous solution doesn't apply (removing Microsoft.Net.Compilers v3.8.0 via Nuget - this package doesn't exist in this solution)...

We have a VS2019 solution that we just replaced the old Microsoft FXCop Code Analyzers (3.3.x) with the newer Microsoft.CodeAnalysis.NetAnalyzers (5.0.3) via Nuget.

We are using the build agent on a TFS 2015 Update3 server. The server has VS2019 and Build Tools, all updated to latest. The same as on our development machines.

The solution built just fine with the old/deprecated analyzers, but now throws an error with the new analyzers. The error is:

[ProjectPath]\src\packages\Microsoft.CodeAnalysis.NetAnalyzers.5.0.3\build\Microsoft.CodeAnalysis.NetAnalyzers.props (1): The default XML namespace of the project must be the MSBuild XML namespace. 
If the project is authored in the MSBuild 2003 format, please add xmlns="http://schemas.microsoft.com/developer/msbuild/2003" to the <Project> element. 
If the project has been authored in the old 1.0 or 1.2 format, please convert it to MSBuild 2003 format.

I have verified all projects in the solution do, in fact, have the recommended namespace in the [project] element. In doing some experimentation and research, something appears to be overriding the normal TFS 2015 compiler version. I cannot figure out what it would be.

NOTE: I went back to FXCop Code Analyzers 2.9.12 and everything builds in TFS just fine. When I tried to use 3.3.x, I get the same build error again. Not sure what that means.

We would like to get off the old/deprecated analyzers. Any and all help is very much appreciated.

1
Can you build the solution successfully on your local VS2019?Levi Lu-MSFT
Yes. The solution builds perfectly on my local workstation. No issues, regardless of the code analyzer package(s) I have installed. TFS builds fine up to FXCop Analyzers 2.9.x, but no further.Alex A
Could you check the build log of the build task in the tfs pipeline to see if the msbuild that from visual studio 2019 was used ?Levi Lu-MSFT
Thanks Levi - how do I pull the build log for the particular failed build? I can see it in Visual Studio on my local machine, but do not see where it indicates the MSBUILD version. In our project template, we have it set to dynamically configure as: <Project ToolsVersion="$(VisualStudioVersion)" xmlns="schemas.microsoft.com/developer/msbuild/2003">Alex A
I have also tried using a specific ToolsVersion as well as "Current". They all behave similarly. What is the process to force the MSBUILD engine to use the very latest tools version?Alex A

1 Answers

0
votes

To make the tfs build use the msbuild.exe of VS2019. You can try editing your build template .xaml to set the ToolPath to the location of the msbuild.exe which is in visual studio 2019 pro.

ToolPath="C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin"

Or, you can edit TFSBuildServiceHost.exe.config file to make MSBuild task to use a specific MsBuild Location. See below:

<msbuildToolsets>
      <toolset toolsVersion="16.0">
         <property name="MSBuildToolsPath" value="C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin" />
      </toolset>
      <toolset toolsVersion="latest">
         <property name="MSBuildToolsPath" value="C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin" />
      </toolset>      
   </msbuildToolsets>

You can refer to below threads for more information.

how to select which MSBUILD.exe is used

Build VS2017 project with TFS 2012 build server