VS 2010预编译网站的构建过程?

时间:2011-09-26 19:44:23

标签: build tfs2010 build-process build-automation precompiled

VS 2010; TFS 2010; ASP.Net 4.0; Web部署项目2010;

我正在使用构建过程模板进行一键式部署(仅适用于dev和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中有一个选项吗?从命令行执行此操作似乎很愚蠢。我已经阅读了很多关于不同选项的内容,但似乎没有一个适用于构建定义。

4 个答案:

答案 0 :(得分:3)

您可以通过将以下内容添加到.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 Arguments
  • 设置/target="PrecompileWeb"

答案 1 :(得分:0)

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

我希望被证明是错的! :)

答案 2 :(得分:0)

我们有一个网站作为Web应用程序存储在TFS2010中。我使用MSBuild命令从TFS2010部署。如果您在VS2010团队资源管理器中打开项目,您将看到有“构建”选项。如果添加构建,并在进程选项卡使用像......构建参数: / P:DeployOnBuild =真/ P:DeployTarget = MsDeployPublish / P:CreatePackageOnPublish =真/ P:MSDeployPublishMethod = RemoteAgent / P:MSDeployServiceUrl = HTTP://111.111.111.111/msdeployagentservice / p:DeployIisAppPath = MySiteNameInIIS / p:用户名= myDomain的\ BuildUser / p:密码= BuildUserPassword 在进程选项卡它说: “项目,以建立” 你只要点它到您的.sln文件(可能与.cspro一起使用,但语法稍有变化)

我们有一台TFS2010服务器,我将一些网站部署到dev,qa,预生产或生产IIS服务器。我在dev构建上进行单元测试,如果测试失败,那么我就不进行部署。

MSBuild命令执行预编译,这对你有用吗?

答案 3 :(得分:0)

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

  1. 打开解决方案
  2. 右键单击项目
  3. 选择&#34;发布...&#34;
  4. 转到设置,展开&#34;文件
  5. 检查&#34;在发布期间预编译&#34;