问题描述
我从ASP.NET MVC Beta版升级到1.0,并做了以下更改MVC项目(如在RC版本说明descibed):
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>
在构建运行在我们的本地开发盒精致,它在2008年TFS构建失败,无法加载类型xxx.MvcApplication',见下生成日志:
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安装在TFS并将该溶液在相同的TFS服务器上的Visual Studio实例中内置汇编
MVC 1.0 is installed on TFS and the solution compiles when built within a Visual Studio instance on the same TFS server.
我怎样才能解决这个TFS构建问题?
How can I resolve this TFS Build issue?
推荐答案
问题发生在一个ASP.NET MVC项目的AfterBuild目标中使用的AspNetCompiler MSBuild任务预计基准的DLL在的bin文件夹这样的事实, Web项目。
The problem stems from the fact that the AspNetCompiler MSBuild task used within the AfterBuild target of an ASP.NET MVC project expects to reference the dll's in the bin folder of the Web project.
在桌面生成bin文件夹是你期望你的源代码树下面。
On a desktop build the bin folder is where you would expect it under your source tree.
不过TFS Teambuild编译源文件的输出到不同的目录中生成服务器上。当AspNetCompiler任务开始就无法找到bin目录中引用所需的DLL,你会得到异常。
However TFS Teambuild compiles the output of your source to a different directory on the build server. When the AspNetCompiler task starts it cannot find the bin directory to reference the required DLL and you get the exception.
解决方案是修改MVC项目的AfterBuild目标如下:
Solution is to modify the AfterBuild target of the MVC Project to be as follows:
<Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
<AspNetCompiler Condition="'$(IsDesktopBuild)' != 'false'" VirtualPath="temp" PhysicalPath="$(ProjectDir)\..\$(ProjectName)" />
<AspNetCompiler Condition="'$(IsDesktopBuild)' == 'false'" VirtualPath="temp" PhysicalPath="$(PublishDir)\_PublishedWebsites\$(ProjectName)" />
</Target>
此更改使您编译双方在桌面上查看和TFS构建服务器。
This change enables you to compile Views on both the desktop, and the TFS build server.
这篇关于ASP.NET MVC 1.0 AfterBuilding意见通过TFS构建失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!