【问题标题】:VS 2010 pre-compile web sites with build process?VS 2010 使用构建过程预编译网站?
【发布时间】:2011-11-25 12:03:16
【问题描述】:

VS 2010; TFS 2010; ASP.Net 4.0; 2010 年网络部署项目;

我正在使用构建过程模板来进行一键式部署(仅适用于开发人员和 QA)。我希望我的网站被预编译。我可以用命令行来做,使用:

 C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler 
-v /site_name 
-p "C:\...\site_name" 
-f "C:\...\site_name1"

如果我将文件从 site_name1 复制到 site_name...

但 IDE 中是否有此选项? 必须从命令行执行此操作似乎很愚蠢。我已经阅读了很多关于不同选项的信息,但似乎没有一个适用于使用构建定义进行构建。

【问题讨论】:

    标签: build build-process build-automation precompiled


    【解决方案1】:

    您可以通过将以下内容添加到您的 .csproj 文件中来做到这一点

    <PropertyGroup>
    <PrecompileVirtualPath>/whatever</PrecompileVirtualPath>
    <PrecompilePhysicalPath>.</PrecompilePhysicalPath>
    <PrecompileTargetPath>..\precompiled</PrecompileTargetPath>
    <PrecompileForce>true</PrecompileForce>
    <PrecompileUpdateable>false</PrecompileUpdateable>
    </PropertyGroup>
    
     <Target Name="PrecompileWeb" DependsOnTargets="Build">
    <Message Importance="high" Text="Precompiling to $(PrecompileTargetPath)" />
    <GetFullPath path="$(PrecompileTargetPath)">
      <Output TaskParameter="fullPath" PropertyName="PrecompileTargetFullPath" />
    </GetFullPath>
    <Message Importance="high" Text="Precompiling to fullpath: $(PrecompileTargetFullPath)" />
    <GetFullPath path="$(PrecompilePhysicalPath)">
      <Output TaskParameter="fullPath" PropertyName="PrecompilePhysicalFullPath" />
    </GetFullPath>
    <Message Importance="high" Text="Precompiling from fullpath: $(PrecompilePhysicalFullPath)" />
    <AspNetCompiler PhysicalPath="$(PrecompilePhysicalPath)" VirtualPath="$(PrecompileVirtualPath)" TargetPath="$(PrecompileTargetPath)" Debug="true" Force="$(PrecompileForce)" Updateable="$(PrecompileUpdateable)" FixedNames="true" />
    

    然后在TFS2010的默认模板中

    • 您的构建定义
    • 进程选项卡
    • 高级参数部分
    • MSBuild 参数
    • 设置/target="PrecompileWeb"

    【讨论】:

      【解决方案2】:

      就目前而言,我找不到任何 IDE 选项来使用构建过程模板预编译网站。我很想被证明是错误的,因为使用命令行 aspnet_compiler 需要我们(在我们的设置中)破解打开实际的构建过程模板,这是我们试图避免的。

      我很想被证明是错的! :)

      【讨论】:

      • 你不必打开构建过程模板
      【解决方案3】:

      我们有一个网站作为 Web 应用程序存储在 TFS2010 中。我使用 MSBuild 命令从 TFS2010 进行部署。如果你在 VS2010 Team Explorer 中打开你的项目,你会看到有一个“Builds”选项。如果您添加构建并在进程选项卡中使用构建参数,例如 ...:/p:DeployOnBuild=True /p:DeployTarget=MsDeployPublish /p:CreatePackageOnPublish=True /p:MSDeployPublishMethod=RemoteAgent /p:MSDeployServiceUrl =http://111.111.111.111/msdeployagentservice /p:DeployIisAppPath=MySiteNameInIIS /p:UserName=myDomain\BuildUser /p:Password=BuildUserPassword 在“要构建的项目”的“进程”选项卡中,您只需指向它到您的 .sln 文件(可能与 .cspro 一起使用,但随后语法略有变化)

      我们有一个 TFS2010 服务器,我将我们的一些站点部署到开发、质量保证、预生产或生产 IIS 服务器。我对开发版本进行单元测试,如果测试失败,则不部署。

      MSBuild 命令会进行预编译,这对您有用吗?

      【讨论】:

        【解决方案4】:

        添加了预编译设置。以下适用于 Visual Studio 2015

        1. 打开解决方案
        2. 右键单击项目
        3. 选择“发布...”
        4. 进入设置,展开“文件”
        5. 选中“发布期间预编译”

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2018-12-06
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-05-17
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多