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

7

26

I am wanting to use Visual Web Developer Express 2010 to publish a website, pre-compiled to a remote server over FTP using the following settings:

  • Deploy only files needed to run this application
  • Precompile this application before publishing
  • Allow website to be updatable
  • No databases are being deployed
  • Site is being deployed as file hierarchy, not as .zip package

My first build/deploy seemed to have gone well, but after my second compilation I receive the following error:

Transformed web.config using C:\path_to_site\Web.Debug.config into obj\Debug\TransformWebConfig\transformed\web.config.
Copying all files to temporary location below for package/publish:
obj\Debug\AspnetCompileMerge\Source.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.5\Web\Transform\Microsoft.Web.Publishing.AspNetCompileMerge.targets(132,5): Error : Can't find the valid AspnetMergePath

And here's a subset of the content of the Microsoft.Web.Publishing.AspNetConfigurationMerge.targets file:

  <Target
      Name="GetAspNetMergePath"
      DependsOnTargets="$(GetAspNetMergePathDependsOn)"
      Condition ="'$(GetAspNetMergePath)' != 'false'">
    <PropertyGroup>
      <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" />
  </Target>

EDIT: Changing the publish settings to delete all existing files before publishing does not fix the problem after all. I'm assuming that the problem is local for now because of this.

There does not appear to be an AspMergePath tag in my web.config. I am not aware if I am supposed to manually add the tag. However, the path "obj{publish setting}\AspnetCompileMerge\Source" does exist in my project.

And in case it matters, my project name is "TestProject.NET"

Your feedback is appreciated.

Irascible answered 3/10, 2012 at 17:27 Comment(4)
have you tried to publish your site via "File System" method ? Just as test.Frayda
Yes. The "File System" publish method runs into the same problem.Irascible
you are not suppose to add any tag ('AspMergePath'), another test. Does it run with ctrl + shift + W ?Frayda
Yes. The site runs just fine using ctrl + shift + WIrascible
M
15

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

Mesa answered 22/5, 2013 at 14:34 Comment(3)
Having the same issue, this solution works well for me. Even if I would have prefered the "cleaner" one, the one proposed by @tspauld, sadly, I didn't managed to make it work in my case.Rahal
This solution worked for me too, but I don't know why the <TargetFrameworkSDKToolsDirectory> line was missing completely from my .targets file.Filum
This is also my solution. For the.NET 4.6.2 should it be: <TargetFrameworkSDKToolsDirectory>C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools\</TargetFrameworkSDKToolsDirectory>. Note: don't miss the backslash at the end of the TargetFrameworkSDKToolsDirectory path. Otherwise the AspnetMergePath can't be correctly merged.Fluorspar
S
13

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

Sennight answered 15/4, 2013 at 14:55 Comment(2)
Thank you for the information! Unfortunately, I cannot verify the correctness of this answer since I have since changed projects.Irascible
Correct answer. Works even nowadays. On the build server you need to install 2015 MSBuild Tools and Windows 10 SDK.Razzledazzle
W
13

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.

Wynd answered 8/1, 2014 at 19:6 Comment(4)
Ahh .. did not work .. Win8, VS 2012 and 2013 installed, what possibly could be the path :(Defector
I notice you also passed VisualStudioVersion=12.0...you wouldn't happen to be trying to build using VS 2013 on a TFS 2012 build server, would you?Boyceboycey
This only worked for me when I removed the trailing backslash. ie. /p:AspnetMergePath="C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools"Scale
Update for Windows 10 - /p:AspnetMergePath="C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools"Moreville
S
5

One workaround for all this stuff [including having to install the SDK etc] is to disable the Precompile On Publish option, which requires AspNetMerge to be present even if you're not specifying that you want stuff to be merged in the ultimate output.

I was going to great lengths to figure out how to turn it off, poring over the options dialog and Reading the Friendly Manual to confirm I had it turned off for ages only to realize it was the checkbox outside:

enter image description here

Unchecking yields the following changes to the .pubxml:

-    <PrecompileBeforePublish>True</PrecompileBeforePublish>
-    <EnableUpdateable>True</EnableUpdateable>
-    <DebugSymbols>False</DebugSymbols>
-    <WDPMergeOption>DonotMerge</WDPMergeOption>

Which worked for me.

NB it is however critical to have as covered here both the Web (which will silently make publishing via /p:DeployOnBuild inert) and the WebApplications (which will give a compiler error) subfolders present under %Program Files (x86)%\MSBuild\Microsoft\VisualStudio\v14.0 (assuming Visual Studio 2015 tooling) for publishing to successfully generate packages

Silvestro answered 10/2, 2016 at 12:40 Comment(1)
just ran into this bug with VS2022 - it was working for 2 years no problem on older .NetFW websites. Tried to re-publish it, got this same error. Unchecking precompile works, but I'd like to fix the bugBrusquerie
B
1

I hit the same problem.

Edit the Microsoft.Web.Publishing.AspNetConfigurationMerge.targets file and add the following line. Make sure run editor with Administrator Rights.

Looks the correct versión Visual Studio in my case VS2013.

x64

<TargetFrameworkSDKToolsDirectory>C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\</TargetFrameworkSDKToolsDirectory>

x86

<TargetFrameworkSDKToolsDirectory>C:\Program Files\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\</TargetFrameworkSDKToolsDirectory>

And it Works! I can compile my Project.

Babi answered 10/9, 2014 at 13:30 Comment(0)
T
1

In my case was missing. It happened after updating Visual Studio 2017 to 15.7.5. Before that it was working fine. I have to add

<TargetFrameworkSDKToolsDirectory>C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\</TargetFrameworkSDKToolsDirectory>

It was at Line no 129 in Microsoft.Web.Publishing.AspNetCompileMerge.targets

Tavarez answered 20/7, 2018 at 12:43 Comment(1)
curious, where is this file located in the OS? I can't find it anywhere on my system?Brusquerie
H
0

change targetFramework ...

<compilation debug="true" targetFramework="4.8"/>
<httpRuntime targetFramework="4.8"/>
Heavily answered 23/10, 2021 at 16:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.