TFS Build Server cannot make publishing profile work: "Cannot find a valid AspnetCompilerPath"

I have a solution with a bunch of web projects, and I want my build server to automatically create packages for each project. I can get (almost) everything that works. The build is fine, and packages will be created on each build. But only when I do not specify PublishProfile in the arguments of MSBuild. That way, it will only embed the default values, and not precompile my websites, etc. (Arguments /p:DeployOnBuild=True /p:IsAutoBuild=True /p:VisualStudioVersion=12.0 )

However, I want to use publishing profiles (.pubxml) created in Visual Studio. Each project has a "Test.pubxml". But when I specify the PublishProfile parameter, the assembly will fail with the following error message (Arguments /p:DeployOnBuild=True;PublishProfile=Test /p:IsAutoBuild=True /p:VisualStudioVersion=12.0 ):

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Transform\Microsoft.Web.Publishing.AspNetCompileMerge.targets (411): Can't find the valid AspnetCompilerPath

Yes, the Microsoft.Web.Publishing.AspNetCompileMerge.targets file exists in this folder. I can deploy projects from Visual Studio on my development machine just fine.

I use the following: Windows Server 2012 R2 Visual Studio Ultimate 2013 Update 1 Update (installed on the build server) Projects for .Net 4.5.1

+8
tfs visual-studio msbuild
source share
2 answers

I had the same problem, I found this question and came up with a slightly less hacky solution:

Just add /P:Framework40Dir=c:\windows\microsoft.net\framework\v4.0.30319 as an additional parameter to MSBuild.

No need to edit .targets files or install anything else. Worked for me, so I just do:

 msbuild MyWebProject.csproj /T:Package /P:PublishProfile=MyProfile /P:Framework40Dir=(as above) 

I use it to create a Web Deploy package in a subfolder of my choice - without a profile, it goes to obj/debug/package . Who uses obj ? Blergh :)

+12
source share

I got the same error and circumvented it with a hack.

I edited the Microsoft.Web.Publishing.AspNetCompileMerge.targets file.

Find AspnetCompilerPath node and replace $ (Framework40Dir) with C: \ Windows \ Microsoft.NET \ Framework \ v4.0.30319 .

I suppose you could set the value of $ (Framework40Dir) earlier in the file.

I recommend backing up the file before changing it (the file also has a comment at the top suggesting this).

I assume that the correct solution would be to set some environment variable or registry value.

+5
source share

All Articles