2011-09-26 46 views
1

VS 2010; TFS 2010; ASP.Net 4.0; Web部署项目2010;VS 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此选项??从命令行执行此操作看起来确实很愚蠢。我已阅读了很多关于不同选项的内容,但似乎没有一个适用于使用构建定义进行构建。

回答

0

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

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

+0

您不必破解打开构建过程模板 – Maslow

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"
0

我们必须存储在TFS2010作为Web应用程序的网站。我使用MSBuild命令从TFS2010进行部署。如果你在VS2010团队资源管理器中打开你的项目,你会看到有一个“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在Process选项卡中显示“要构建的项目”,您只需将它指向您的.sln文件(可能适用于.cspro,但语法略有变化)

我们有一个TFS2010服务器,我将我们的几个站点部署到dev,qa,预生产或生产IIS服务器。我对开发版本进行了单元测试,如果测试失败,我不会部署。

MSBuild命令执行预编译,会为你工作吗?

0

已添加预编译设置。在Visual Studio 2015年

  1. 打开一个解决方案
  2. 对项目
  3. 选择 “发布...”
  4. 转到设置右键单击以下作品,展开 “文件
  5. 检查” 预编译在发布期间“