Search code examples
asp.netvisual-studio-2012publish

VS 2012 Publish: Can't find the valid AspnetMergePath


I just installed Update 2 for Visual Studio 2012, which introduces a new Publish dialog. I'm trying to make it do what it used to do (precompile a website before publishing), and I'm running into the error that it

"Can't find the valid AspnetMergePath"

which is thrown from the file Microsoft.Web.Publishing.AspNetCompileMerge.targets. I've confirmed that the file aspnet_merge.exe exists in multiple places on my computer, but

$(GetAspNetMergePath) 

is evaluating to an empty string for some reason. I must be missing some configuration setting, but I've never messed with those before, so I'm confused as to why this would start suddenly.

Can anyone offer advice on how to resolve this? I've done the standard Google searching on this error and nothing has led me to the right solution.


Solution

  • 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 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" />