Alex Rivera | Logout

ASP.NET MVC 1.0 AfterBuilding Views fails on TFS Build

Asked 2009-04-16T11:07:00.703
63

I've upgraded from ASP.NET MVC Beta to 1.0 and did the following changes to the MVC project (as descibed in the RC release notes):

<Project ...>
  ...
  <MvcBuildViews>true</MvcBuildViews>
  ...
  <Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
    <AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)\..\$(ProjectName)" />
  </Target>
  ...
</Project>

While the build runs fine on our local dev boxes, it fails under TFS 2008 Build with "Could not load type 'xxx.MvcApplication'", see below build log:

...
using "AspNetCompiler" task from assembly "Microsoft.Build.Tasks.v3.5, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Task "AspNetCompiler"

  Command:
  C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v temp -p D:\Builds\xxx\Continuous\TeamBuild\Sources\UI\xxx.UI.Dashboard\\..\xxx.UI.Dashboard 
  The "AspNetCompiler" task is using "aspnet_compiler.exe" from "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe".
  Utility to precompile an ASP.NET application
  Copyright (C) Microsoft Corporation. All rights reserved.

/temp/global.asax(1): error ASPPARSE: Could not load type 'xxx.UI.Dashboard.MvcApplication'.
  The command exited with code 1.

Done executing task "AspNetCompiler" -- FAILED.
...

MVC 1.0 is installed on TFS and the solution compiles when built within a Visual Studio instance on the same TFS server.

How can I resolve this TFS Build issue?

Edit
Report

2 Answers

3

Jim Lamb's solution didn't work for us when I built our web .csproj with

/p:UseWPP_CopyWebApplication=true;PipelineDependsOnBuild=False

because the target was being executed AfterBuild and the application has not been copied into the WebProjectOutputDir yet. (BTW, I pass those properties to the web project build cos I want the build to create a OutDir folder with only my binaries and cshtml files suitable for zipping, ie not an in-place build)

To get around this issue and honour the intent of his original target, I did the following:

<PropertyGroup>
    <OnAfter_WPPCopyWebApplication>
        MvcBuildViews;
    </OnAfter_WPPCopyWebApplication>
</PropertyGroup>

<Target Name="MvcBuildViews" Condition="'$(MvcBuildViews)'=='true'">
    <AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
</Target>
answered 2012-11-27T17:07:21.600
1

I assume you meant you changed the following setting in the .csproj file:

<MvcBuildViews>true</MvcBuildViews>

The setting you posted in your question shouldn't be touched. If it works on your local machine, then obviously you can pre-build an ASP.NET MVC application.

I think you need to track down what's different between your TFS build environment and your local VS machines. Maybe it's using a different version of MsBuild or something.

Try performing both builds with verbose output and compare the two to see what's different.

answered 2009-04-20T16:14:29.813

Your Answer