ASP.NET MVC 1.0 AfterBuilding意见通过TFS构建失败
-
09-09-2019 - |
题
我从ASP.NET MVC测试版升级到1.0,并做了以下更改MVC项目(如在RC版本说明descibed):
<Project ...>
...
<MvcBuildViews>true</MvcBuildViews>
...
<Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)\..\$(ProjectName)" />
</Target>
...
</Project>
虽然构建运行在我们的本地开发盒精致,它在2008年TFS构建失败,“无法加载类型‘xxx.MvcApplication’”,见下面生成日志:
...
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.
...
1.0 MVC安装在TFS,并将该溶液在相同的TFS服务器上的Visual Studio实例内内置汇编
我怎样才能解决这个TFS构建问题?
解决方案
问题发生在一个ASP.NET MVC项目的AfterBuild目标中使用的AspNetCompiler MSBuild任务预计基准的DLL的Web项目的bin文件夹的事实造成的。
在桌面生成bin文件夹是希望它的源代码树下面。
然而TFS Teambuild编译源的输出,以不同的目录生成服务器上。当AspNetCompiler任务启动时,它无法找到bin目录中引用所需的DLL和你得到的异常。
解决方案是修改MVC项目的AfterBuild目标如下:
<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构建服务器。
其他提示
其实,有一个更好的解决这个问题。我已经与2010 VS / TFS测试,但它也应该能VS / 2008 TFS工作。
<Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
</Target>
我要与MVC团队合作,以更新他们的项目模板,以使用自定义的目标(而不是覆盖AfterBuild)一起使用这种方法。
我已经发表了关于如何的打开编译时视图检查在TFS ASP.NET MVC项目建设2010 。
吉姆羔羊的解决方案并没有为我们工作时,我建立了我们的网站的.csproj与
/p:UseWPP_CopyWebApplication=true;PipelineDependsOnBuild=False
,因为目标正在执行AfterBuild
和应用尚未被复制到WebProjectOutputDir
尚未。 (顺便说一句,我通过这些属性在Web项目建设因为我想构建创建只有我的二进制文件和CSHTML一个OUTDIR文件的文件夹适用于荏苒,即不就地生成)
要解决这个问题,并兑现自己当初目标的意图,我做了以下内容:
<PropertyGroup>
<OnAfter_WPPCopyWebApplication>
MvcBuildViews;
</OnAfter_WPPCopyWebApplication>
</PropertyGroup>
<Target Name="MvcBuildViews" Condition="'$(MvcBuildViews)'=='true'">
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
</Target>
我假设你的意思是你在.csproj的文件中更改以下设置:
<MvcBuildViews>true</MvcBuildViews>
您在您的问题发布的设置应不能触及。 如果它工作在本地计算机上,那么很明显,你可以预先建立一个ASP.NET MVC应用程序。
我觉得你需要跟踪什么是你的TFS构建环境和当地VS机器之间的不同。也许这是使用不同版本的MSBuild或东西。
尝试执行都建立有详细的输出和比较两个,看看有什么不同。
我们还在测试了这一点,但现在看来,可以从标签集移动假/真,进入属性组为您调试内部版本,你还可以将它设置为true的MSBuild将编译(假设的MSBuild TfsBuild.proj文件设置为使用比调试配置以外的东西)。你需要用记事本完成这个编辑的csproj文件。
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<MvcBuildViews>true</MvcBuildViews>
....
您需要将MVCBuildViews标签从默认属性组移动的上方,所述调试配置属性组(下文)。同样,当我们得到的TFS /的MSBuild设置,我将尝试后,我们加入到我们的TFS文件TFSBuild.proj步骤。
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<MvcBuildViews>true</MvcBuildViews>
<DebugSymbols>true</DebugSymbols>
....
此问题似乎类似于一个讲到这里: 的http:// blogs.msdn.com/aaronhallberg/archive/2007/07/02/team-build-and-web-deployment-projects.aspx 似乎aspnet_compiler.exe的调用未能找到二进制文件,因为在构建机器上的MVC项目的bin文件夹都没有。我还没有研究出了解决办法呢。
接受的答案并没有为我工作。该$(PublishDir)参数没有指向正确的位置。相反,我不得不使用:
<Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
<AspNetCompiler Condition="'$(IsDesktopBuild)' != 'false'" VirtualPath="temp" PhysicalPath="$(ProjectDir)\..\$(ProjectName)" />
<AspNetCompiler Condition="'$(IsDesktopBuild)' == 'false'" VirtualPath="temp" PhysicalPath="$(OutDir)\_PublishedWebsites\$(ProjectName)" />
</Target>
我有一些旧的文件夹,在不可见在解我的源控制。
可以没有预先建立ASP.NET MVC应用程序。