1

与 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中有一个选项吗?必须从命令行执行此操作似乎真的很愚蠢。我已经阅读了很多关于不同选项的内容,但似乎没有一个适用于使用构建定义进行构建。

4

4 回答 4

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 参数
  • /target="PrecompileWeb"
于 2011-12-05T20:29:53.693 回答
0

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

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

于 2011-09-29T16:40:19.657 回答
0

我们有一个网站作为 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 命令进行预编译,这对您有用吗?

于 2012-01-26T18:15:01.810 回答
0

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

  1. 打开解决方案
  2. 右键单击项目
  3. 选择“发布...”
  4. 进入设置,展开“文件
  5. 选中“发布期间预编译”
于 2016-08-31T14:49:08.233 回答