MSBuild 2015 publish: Cannot find a valid AspnetMergePath

I have a build on TeamCity that packs a web project, ready for future deployment, currently using MSBuild 2013. When I recently clicked on some code, I got build errors (due to the fact that I used some C functions # 6), so I went to change the build configuration to use MSBuild 2015 instead and got this error:

[Error] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Transform\Microsoft.Web.Publishing.AspNetCompileMerge.targets(132, 5): Can't find the valid AspnetMergePath

This error was mentioned earlier in other issues (for example, here: VS 2012 Publish: Cannot find a valid AspnetMergePath ), but, unfortunately, none of the mentioned fixes in these issues worked for me.

Things I have tried or already dealt with:

  • The Web and WebApplication directories from the local machine (in C: \ Program Files (x86) \ MSBuild \ Microsoft \ VisualStudio \ v14.0) were copied to build the server (they were always there)
  • Added <TargetFrameworkSDKToolsDirectory>C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\</TargetFrameworkSDKToolsDirectory> to Microsoft.Web.Publishing.AspNetCompileMerge.targets file
  • Added /p:AspnetMergePath="C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\" command to the MSBuild command

I'm losing a bit with this: pretty much the only thing I haven't tried is installing Visual Studio on the build server, but I'd really like to avoid this if I can (because I think you're funny that you need to install the full IDE on the CI server!).

Additional Information:

  • everything works fine if you switch the build to MSBuild 2013 (although obviously we don’t want to get stuck in the past)
  • We have a number of other clean collections that work with MSBuild 2015 without errors
+6
source share
2 answers

Both the second and third solutions originally proposed at VS 2012 Publish: Cannot find a valid AspnetMergePath , do work, but the correct version of the SDK tools must be provided .

Original article ( VS 2012 Publish: Cannot find a valid AspnetMergePath ) was written in 2013 and covers Visual Studio 2012. Aspnet_merge.exe, which supports C # 6.0 and .NET 4.6, is not the one that goes along the path "C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\" .

To get the third solution, use the following path instead of "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\" .

In other words, adding /p:AspnetMergePath="C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\" to the MSBuild command solves the problem .

My team had the same problem as the one you are describing, and adding this parameter to the MSBuild step, fixing it right away. (I assume, of course, that you have the version of NETFX tools 4.6 on your build machine.)

As a side note, since you said you were using Team City - instead of adding the specified parameter directly as a command-line parameter, you can use the recommended Team City and configure the appropriate build parameter .

+5
source

The accepted answer is simply a cure for the symptoms and does not address the underlying problem. Launch MSBuild with the diagnostic protocol . If you look at Microsoft.Web.Publishing.AspNetCompileMerge.targets , you will see that it is trying to associate TargetFrameworkSDKToolsDirectory with AspnetMergeName . If you search the MSBuild log, you will find that TargetFrameworkSDKToolsDirectory empty. TargetFrameworkSDKToolsDirectory is created from TargetFrameworkSDKDirectory , which is also empty.

This is what you need to fix. In my case:

  • Install the Windows 7.1 SDK (using this workaround on Windows Server 2016).
  • In VS2017, the path is determined based on /configuration/msbuildToolsets/toolset/property[@name="FrameworkSDKRoot] , which in my case is Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\NETFXSDK\ 4.6.1@InstallationFolder . In my case, this node was available only in WOW6432Node , it must also be available in the 64-bit registry, you need to copy the node to an equivalent location in the 64-bit registry.
+1
source

All Articles