1

I am having a problem with TFS2013 using a Team Build which does a build then a publish of a website.
Everything works fine when I do a Publish Web site from my dev machine using VS2013 and the (right-click) Publish Web site option for the Web site project. I get the following error on the TFS2013 Build server:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Transform\Microsoft.Web.Publishing.AspNetCompileMerge.targets(421,5): error :

**Can't find the valid AspnetCompilerPath** [C:\Builds\3\Web\Development to WebDev\Sources\Web\Website\Development\ASP.NET\App\website.publishproj]
Done Building Project "C:\Builds\3\Web\Development to WebDev\Sources\Web\Website\Development\ASP.NET\App\website.publishproj" (default targets) -- FAILED.

**

I am using the follow MSBuild arguments in the Team Build setup.
/p:DeployOnBuild=true;VisualStudioVersion=12.0;DeployTarget=WebFileSystemPublish;PublishProfile=Development

The Development Web Transform works fine on the Build Server in response to the 'PublishProfile=Development' argument. The Web.Config file is properly transformed for our Development environment. As noted in the MSBuild Argument, I use the FileSystem publish option and want to keep it that way.

I have modified the Build Server 'C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Transform\Microsoft.Web.Publishing.AspNetCompileMerge.targets' to log some properties as follows in Target 'ConfigureForAspNetPreCompileMerge':

<Message Text="[TargetFrameworkVersion]: $(TargetFrameworkVersion)" />
<Message Text="[AspnetCompilerPath]: $(AspnetCompilerPath)" />
<Message Text="[Framework40Dir]: $(Framework40Dir)" />
<Message Text="[MSBuildToolsRoot]: $(MSBuildToolsRoot)" />
<Message Text="[MSBuildRuntimeVersion]: $(MSBuildRuntimeVersion)" />

Which logs the following information to the website.log file for the Team Build: ConfigureForAspNetPreCompileMerge:

[TargetFrameworkVersion]: v4.0 [AspnetCompilerPath]: [Framework40Dir]: C:\Program Files (x86)\MSBuild\v4.0.30319 [MSBuildToolsRoot]: C:\Program Files (x86)\MSBuild\ [MSBuildRuntimeVersion]: 4.0.30319

The [Framework40Dir] is different than my local machine logging the same data at the same MSBuild target:

12> Task Parameter:Text=[TargetFrameworkVersion]: v4.0 12>
[TargetFrameworkVersion]: v4.0 12> Task Parameter:Text=[AspnetCompilerPath]: 12> [AspnetCompilerPath]: 12> Task Parameter:Text=[Framework40Dir]: C:\Windows\Microsoft.NET\Framework\v4.0.30319 12> [Framework40Dir]: C:\Windows\Microsoft.NET\Framework\v4.0.30319 12> Task Parameter:Text=[MSBuildToolsRoot]: C:\Program Files (x86)\MSBuild\ 12> [MSBuildToolsRoot]: C:\Program Files (x86)\MSBuild\ 12> Task Parameter:Text=[MSBuildFrameworkToolsRoot]: C:\Windows\Microsoft.NET\Framework\ 12>
[MSBuildFrameworkToolsRoot]: C:\Windows\Microsoft.NET\Framework\ 12>
Task Parameter:Text=[MSBuildRuntimeVersion]: 4.0.30319 12>
[MSBuildRuntimeVersion]: 4.0.30319

The TeamBuild value for [Framework40Dir] is: 'C:\Program Files (x86)\MSBuild\v4.0.30319' vs my local DEV machine of: C:\Windows\Microsoft.NET\Framework\v4.0.30319

This seems very unusual.

I have also changed the TeamBuild file: 'C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Transform\Microsoft.Web.Publishing.AspNetCompileMerge.targets' to manually set the property of Framework40Dir as 'C:\Windows\Microsoft.NET\Framework\v4.0.30319' but that seems to hang the whole TeamBuild process when it gets to that point and runs the Team Build forever until I manually stop it.

This is the same solution that worked here: TFS Build Server cannot get publish profile to work: "Can't find the valid AspnetCompilerPath" but it doesn't work for me. That issue is identical to my problem.

The Build server is up to date with TFS2013.3. I do not have Visual Studio 2013 installed on that machine and would very much like not to do that. I have read that VS is not needed for TFS Team Builds.

Help with this issue is very much appreciated.....Thanks.

Community
  • 1
  • 1
Mike
  • 111
  • 2
  • 6

3 Answers3

2

I would install vs2013 onto the build server it removes the majority of these issues, allows you to run code coverage against your unit tests and doesn't require a licence as long as you have a valid licence on your development machine. I know this isn't the answer you wanted.

Just TFS
  • 4,697
  • 1
  • 18
  • 22
  • Thanks for the response. That is my next option unless something else pops up. – Mike Aug 19 '14 at 13:19
  • same result after installing VS2013 with Update 3 on the TFS2013 Build Server. [Framework40Dir]: C:\Program Files (x86)\MSBuild\v4.0.30319 is set to the MSBuild directory location in the TeamBuild target of 'ConfigureForAspNetPreCompileMerge'. – Mike Aug 19 '14 at 19:28
  • Have you logged onto the build server and built it in vs on there? – Just TFS Aug 19 '14 at 21:39
  • Within VS2013 on the TFS2013 Build Server, the solution was built and published successfully....exactly like my dev machine. And again, the Team Build failed with the following error: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Transform\Microsoft.Web.Publishing.AspNetCompileMerge.targets(423,5): error : Can't find the valid AspnetCompilerPath – Mike Aug 20 '14 at 15:24
  • Which template are you using? – Just TFS Aug 20 '14 at 17:57
  • Humour me and remove the visual studio argument, in fact how far does it get with no arguments? What are the configuration and platform settings on the build definition. – Just TFS Aug 20 '14 at 21:07
  • I removed all MSBuild arguments passed in for the TeamBuild setup and the website publish did not attempt any ASPnet compile or merge. The Configuration to Build is 'Any CPU|Debug'. – Mike Aug 20 '14 at 21:28
  • I'll be honest I'm really struggling, you would have thought that [Framework40Dir] issue would have been fixed once vs was installed and the fact that it builds in VS on the build server would have enforced this. I run minimal arguments on my web builds and only pass in /p:DeployOnBuild=true;PublishProfile=Development, all the additional information required should be available in the PublishProfile. I'll try and trace the [Framework40Dir] today if i get time but I'm stuck for time and ideas at the moment sorry. – Just TFS Aug 21 '14 at 08:07
2

I have found the secret sauce. I needed to set the ToolsVersion in my website.publishproj file Project section to "12.0".

I also needed to set the ToolsVersion to "12.0" in the DefaultTemplate.xaml 'Run MSBuild for Project' workflow activities as detailed in this article.

Building Visual Studio 2013 solutions with your TFS 2010 / 2012 Build Templates

The TeamBuild now works like the VS2013 Publish Web site....but this whole process takes almost twice as long as the former Web Deployment Projects we used before. I will have to investigate if there is some way to speed up the Publish process.

Hope this helps someone else with this issue.

Mike
  • 111
  • 2
  • 6
2

please change the $(Framework40Dir) with this path C:\Windows\Microsoft.NET\Framework\v4.0.30319.

Santhosh
  • 89
  • 1
  • 3
  • 2
    or add /p:Framework40Dir="C:\Windows\Microsoft.NET\Framework\v4.0.30319" to the msbuild command line. – kerem Dec 17 '14 at 09:35