ASP.NET MVC 1.0 AfterBuilding Views fails on TFS Build

后端 未结 9 1360
你的背包
你的背包 2020-12-12 17:42

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):


  ...         


        
相关标签:
9条回答
  • 2020-12-12 18:22

    This problem seems similar to the one talked about here: http://blogs.msdn.com/aaronhallberg/archive/2007/07/02/team-build-and-web-deployment-projects.aspx it seems the invocation of aspnet_compiler.exe fails to locate the binaries because the are not in the bin folder of the MVC project on the build machine. I haven't worked out a solution yet.

    0 讨论(0)
  • 2020-12-12 18:22

    The accepted answer didn't work for me. The $(PublishDir) parameter did not point to the correct location. Instead I had to use:

      <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>
    
    0 讨论(0)
  • 2020-12-12 18:23

    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.

    0 讨论(0)
  • 2020-12-12 18:27

    Actually, there's a better solution to this problem. I've tested it with VS/TFS 2010 but it should also work with VS/TFS 2008.

    <Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
      <AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
    </Target>
    

    I'm going to work with the MVC team to update their project template to to use this approach along with a custom target (rather than overriding AfterBuild).

    I've published a blog post on How to Turn on Compile-time View Checking for ASP.NET MVC projects in TFS Build 2010.

    0 讨论(0)
  • 2020-12-12 18:27

    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>
    
    0 讨论(0)
  • 2020-12-12 18:31

    We are still testing this out, but it appears that you can move the false/true from the tag set, into the property group for your DEBUG build version, you can still set it to true and MSBuild will compile (assuming MSBuild TfsBuild.proj file is setup to use something other than debug configuration). You will need to edit the csproj file using Notepad to accomplish this.

    <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
      <PropertyGroup>
        <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
        <MvcBuildViews>true</MvcBuildViews>
        ....
    

    You need to move the MVCBuildViews tag from the default property group above, to the debug configuration property group (below). Again, when we get the TFS / MSBuild setup, I'll try to post the step we added to our TFSBuild.proj file in TFS.

      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
        <MvcBuildViews>true</MvcBuildViews>
        <DebugSymbols>true</DebugSymbols>
        ....
    
    0 讨论(0)
提交回复
热议问题