Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 534
adsilb Avatar asked Apr 17 '13 21:04

adsilb


4 Answers

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

like image 189
ialiashkevich Avatar answered Nov 01 '22 06:11

ialiashkevich


I had the same issue today while building using msbuild command line. The fix is to use the msbuild.exe in C:\Program Files (x86)\MSBuild\12.0\Bin
and not from C:\Windows\Microsoft.NET\Framework\v4.0.30319

The issue is caused by the fact that new msbuild is now part of visual studio 2013 and not .Net framework any more.

like image 21
softveda Avatar answered Nov 01 '22 08:11

softveda


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.

like image 6
tspauld Avatar answered Nov 01 '22 07:11

tspauld


I had the same issue in VS 2012 and all I did was the following:

Click Publish,Under Publish Web go to Settings tab, Uncheck "Precompile during publishing."

like image 2
tmndungu Avatar answered Nov 01 '22 07:11

tmndungu