"Can't find the valid AspnetMergePath" on Visual Web Developer Publish? "Can't find the valid AspnetMergePath" on Visual Web Developer Publish? asp.net asp.net

"Can't find the valid AspnetMergePath" on Visual Web Developer Publish?


I hit the same problem. Searched through all microsoft related sites, found a lot of complaints and no intention from microsoft to fix it.

Here how I worked it around at my system. Edit the Microsoft.Web.Publishing.AspNetConfigurationMerge.targets file and add the following line. Please make sure that the Microsoft SDK path is the same on your PC, if not then change it:

<TargetFrameworkSDKToolsDirectory>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\</TargetFrameworkSDKToolsDirectory>

Here is how it should look like:

  <Target  Name="GetAspNetMergePath"  DependsOnTargets="$(GetAspNetMergePathDependsOn)"  Condition ="'$(GetAspNetMergePath)' != 'false'"><PropertyGroup>  <TargetFrameworkSDKToolsDirectory>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\</TargetFrameworkSDKToolsDirectory>  <AspnetMergeName>aspnet_merge.exe</AspnetMergeName>  <AspnetMergePath Condition="Exists('$(TargetFrameworkSDKToolsDirectory)$(AspnetMergeName)')">$(TargetFrameworkSDKToolsDirectory)</AspnetMergePath></PropertyGroup><Error Condition="'$(AspnetMergePath)' == '' Or !Exists($(AspnetMergePath))"       Text="Can't find the valid AspnetMergePath" />


Here is a solution that does not require changing the targets file. The workaround from http://connect.microsoft.com/VisualStudio/feedback/details/786492/publish-cant-find-the-valid-aspnetmergepath suggests passing additional properteries to msbuild. I was able to get it to work using this:

msbuild website.publishproj /p:DeployOnBuild=true /p:PublishProfile=Release /p:VisualStudioVersion=12.0 /p:AspnetMergePath="C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\"

The key here is the AspnetMergePath property, which you may need to change if the Windows SDK is installed in a different location. If I include the GetAspNetMergePath property from the workaround it fails, but that may be needed depending on the SDK version.


What you need is aspnet_merge.exe, tool that is distributed as part of Windows SDK. It's intended to precompile sites, so you can either turn that precompilation off, or install proper version of Windows SDK. Reference is to the Wikipedia, because of nice prepared links to the download pages. You don't need to download/install everything (it's huge), just download web installer and select .Net tools, it will take around 50 megabytes.

Please, notice that bundled with Visual Studio 2010 Windows SDK ver. 7.0A isn't available to separate download, so you'll have to either install Visual Studio on your build server, or tweak something as described in answers to "Running MSBuild fails to read SDKToolsPath".