Build/Test Issues

Grid Node + MSBuild 14 detection

Started by jschreuder on 9,869 views

Hi,

I'm giving the grid node thing a try on a fresh Azure VM.

My tests are running and failing, and the logs show a bunch of errors related to my usage of fat arrows which were introduced in C#6.

I assume this is the reason:

WARNING - NCrunch: This project has been built with MSBuild v4.0 because MSBuild v14.0 was not found on this server. Some build tasks may fail when not executed using the correct version of MSBuild.


However, I know for sure MSBuild 14 is installed, as I can see it on disk (installed via the VS 2015 Build Tools).

External image

Do I need to add something to my PATH, or is the NCrunch grid node just not picking up this installation for reasons outside my control?

Edited

Hi, thanks for sharing this issue.

NCrunch searches for MSBuild through the presence of the "Microsoft.Build, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" assembly inside the GAC. If NCrunch can't find this file in the GAC, it won't be able to resolve the build engine and will give you this warning. Check that this assembly is installed in the GAC.
Thanks, I did

C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools>gacutil /i "C:\Program Files (x86)\MSBuild\14.0\Bin\Microsoft.Build.dll"
via command prompt and I have progressed a little further.
I have similar problem but with Visual Studio 2017.

When I had Visual Studio 2013 both on my local machine and on remote server, everything works as expected. Now, I'm using Visual Studio 2017 on my local computer, and Build Tools for Visual Studio 2017 on remote server. This configuration works as expected - I have TeamCity on my remote server building my project using Build Tools without problem.

Unfortunately I have hard times with nCrunch. I have this error:

NCrunch: If you are experiencing problems in getting this project to build, have a look at http://www.ncrunch.net/documentation/troubleshooting_project-build-issues
NCrunch: This project was built on server 'REMOTE-SERVER'
..\..\..\windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets (917, 7): The target "AssignLinkMetadata" does not exist in the project.


WARNING - NCrunch: [h]This project has been built with MSBuild v4.0 because MSBuild v15.0 was not found on this server.[/h] Some build tasks may fail when not executed using the correct version of MSBuild.

NCrunch: The following files were used when building this project locally but do not seem to exist on the remote grid node responsible for building this project:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.CSharp.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.CSharp.CurrentVersion.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Roslyn\Microsoft.CSharp.Core.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\Managed\Microsoft.CSharp.DesignTime.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\Managed\Microsoft.Managed.DesignTime.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Microsoft.Common.props
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Imports\Microsoft.Common.props\ImportBefore\Microsoft.NuGet.ImportBefore.props
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.props
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.NETFramework.props
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.NETFramework.CurrentVersion.props
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\CodeAnalysis\Microsoft.CodeAnalysis.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.NETFramework.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.NETFramework.CurrentVersion.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.WinFX.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Data.Entity.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Xaml.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.WorkflowBuildExtensions.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\TeamTest\Microsoft.TeamTest.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\Microsoft.Docker.ImportAfter.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.Docker.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\Microsoft.NET.Build.Extensions.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\Microsoft.NET.Build.Extensions.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\Microsoft.NET.Build.Extensions.NETFramework.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\Microsoft.NET.Build.Extensions.ConflictResolution.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\Microsoft.NuGet.ImportAfter.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\Microsoft.QualityTools.Testing.Fakes.ImportAfter.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\Fakes\Microsoft.QualityTools.Testing.Fakes.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\Microsoft.Web.ImportAfter.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\Managed.Web\Microsoft.Web.IISSupport.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.ServiceModel.targets

Often this can be caused by configuration differences between your client machine and the grid node, in which case the installed SDK directories may be different between machines. If you are experiencing consistent problems when building this project on the grid node, the missing files listed above are worth investigating as they may highlight SDKs required on the grid node that have not yet been installed. Please note that this is not necessarily an error case as projects very often build successfully on grid nodes with only a subset of the client machine's installed SDKs.


I added Microsoft.Build.dll to GAC but it didn't help:

C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.1 Tools>gacutil.exe /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\Microsoft.Build.dll"

C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.1 Tools>gacutil.exe /l Microsoft.Build
Microsoft (R) .NET Global Assembly Cache Utility. Version 4.0.30319.0
Copyright (c) Microsoft Corporation. All rights reserved.

The Global Assembly Cache contains the following assemblies:
Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL


I checked all *.targets files and they are on server, only under different path. On my local machine they are located:

C:\Program Files (x86)\Microsoft Visual Studio\2017\[h]Enterprise[/h]\


On server:

C:\Program Files (x86)\Microsoft Visual Studio\2017\[h]BuildTools[/h]\


Any ideas how can I solve this problem?
This problem is caused by the inability of NCrunch on your grid node to locate the installation of VS2017.

VS2017 is much more complicated to reference than other versions of VS, as there is no reliable central way of finding it outside of a COM API, which I've had some problems with in the past. I am uncertain of how this COM API operates without a physical installation of VS on the machine. I'm not sure how Build Tools for Visual Studio 2017 qualifies - this use case has not been tested and I cannot guarantee that it will work. It's quite possible that you may need to physically install VS on the grid node itself.

Try setting an "NCrunchVSInstallPath.VS2017" environment variable on the grid node server with a value set to the directory 3 levels below MSBuild.exe as it exists on the grid node server. So for example, if your MSBuild.exe is under:
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin", then you should set this environment variable to "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise"

Make sure the environment variable is defined at system level and that the grid node service is restarted after it's declared. If in doubt, reboot the machine.
Setting NCrunchVSInstallPath.VS2017 Environment variable gives me different error:

NCrunch was unable to parse this project file because of an unexpected error: Microsoft.Build.Exceptions.InvalidProjectFileException: The tools version "15.0" is unrecognized. Available tools versions are "2.0", "3.5", "4.0".


Quick google gives me this solution:

https://github.com/dotnet/docfx/issues/1969#issuecomment-323235324

But in my case VSINSTALLDIR is C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools. VisualStudioVersion is unchanged = 15.0.

After that NCrunch is still giving me warning about missing files:

NCrunch: The following files were used when building this project locally but do not seem to exist on the remote grid node responsible for building this project:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.CSharp.targets
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.CSharp.CurrentVersion.targets
(...)


But is working without problem. Thanks for help.

Edited

Great to hear, thanks for confirming!

Don't worry about the missing file warning. This is just a goto-hint if you do actually have any problems. Those files naturally won't be on the grid node because it doesn't have VS installed.

Post a reply

Log in to reply.