Click here to Skip to main content
14,972,994 members
Articles / All Topics
Technical Blog
Posted 12 Feb 2011

Tagged as

Stats

23.7K views

Resolve /temp/global.asax(1,0): error ASPPARSE: Could not load type- Team Build

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
12 Feb 2011CPOL1 min read
Resolve /temp/global.asax(1,0): error ASPPARSE: Could not load type- Team Build

I was trying to automate the build in an ASP.NET MVC Web application using Team Build, and the build kept failing with this error:

/temp/global.asax(1,0): error ASPPARSE: Could not load type

After taking a look at the build log, I was able to see that the error is generated right after a command to aspnet_compiler.exe is made. I also looked at the parameters, and I noticed that the path was incorrect. To confirm that the problem was just with Team Build, I loaded the same project with Visual Studio and did the build manually. Everything worked ok.

I decided to take a look at the web project file (.csproj), and noticed the following settings:

XML
<PropertyGroup>
    <MvcBuildViews>true</MvcBuildViews>
</PropertyGroup>

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

The MvcBuildViews variable is used to indicate that the MVC views should be compiled to detect any errors with the views. Currently, errors within a view file are not detected until run time. The physical path in the AfterBuild target did work for the Desktop build, but not the Team Build. The AspNetCompiler MSBuild task expects to find the compiled DLL in the bin folder of the web project, but this is not the same location on the build machine.

To solve this problem, I had to edit the MVC web application project file and edit the AfterBuild target to match the following:

XML
<Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
    <AspNetCompiler Condition="'$(IsDesktopBuild)' == 'true'" 
	VirtualPath="temp" PhysicalPath="$(ProjectDir)\..\$(ProjectName)" /> 
    <AspNetCompiler Condition="'$(IsDesktopBuild)' == 'false'" 
	VirtualPath="temp" PhysicalPath="$(OutDir)\_PublishedWebsites\$(ProjectName)" />
</Target>

I had to add a condition to check if the build was being done using Visual Studio (IsDeskTopBuild=true) and use the default PhysicalPath (bin folder in the project directory). If the build was not done using Visual Studio, the physical path was modified to reflect the path from the build machine. After making the change, I checked in the web application project file, and the next automated build completed successfully.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

ozkary
Architect OG-BITechnologies
United States United States
Software engineer, author & speaker who enjoys mentoring, learning, speaking and sharing with others about software development technologies. Microsoft MVP.

My Blog

Comments and Discussions

 
GeneralMy vote of 5 Pin
rrossenbg27-Apr-13 22:57
Memberrrossenbg27-Apr-13 22:57 
GeneralYour solution didn't quite work for me, but this work: Pin
Yves Tr15-Mar-11 10:07
MemberYves Tr15-Mar-11 10:07 
GeneralRe: Your solution didn't quite work for me, but this work: Pin
ozkary15-Mar-11 11:21
Memberozkary15-Mar-11 11:21 
yes, the $(WebProjectOutputDir) variable which is defined in the Microsoft.WebApplication.targets file does the work for both desktop and team builds.

In regards to the isDesktopBuild variable not being defined. I am curious to know which version of team build and visual studio are you using? It seems to be defined for vs2008/vs2010 builds.

thanks for the feedback.
GeneralRe: Your solution didn't quite work for me, but this work: Pin
Yves Tr23-Mar-11 6:29
MemberYves Tr23-Mar-11 6:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.