用于跳过目录的MSbuild命令行参数

时间:2012-10-19 20:34:19

标签: msbuild teamcity msdeploy

我在团队城市中有以下命令行参数进行部署。一切正常,但我想在部署时跳过一些目录。如何在团队城市的msbuild脚本中添加该逻辑

/P:Configuration=%env.Configuration%
/P:DeployOnBuild=True
/P:DeployTarget=MSDeployPublish
/P:MsDeployServiceUrl=https://%env.TargetServer%/MsDeploy.axd
/P:AllowUntrustedCertificate=True
/P:MSDeployPublishMethod=WMSvc
/P:CreatePackageOnPublish=True
/P:SkipExtraFilesOnServer=True
/P:UserName=xxxxx
/P:Password=xxxxx

3 个答案:

答案 0 :(得分:5)

我正在做同样的事情。我不想修改我的.csproj文件,所以我尝试了这个。到目前为止它对我有用。就我而言,我从部署而不是Data文件夹中排除了媒体,App_Data \ Logs和App_Data \ preview文件夹。

基本上,您可以将ExcludeFoldersFromDeployment作为参数传递给MSBuild。将它与SkipExtraFilesOnServer相结合可以解决问题。

/p:Configuration=Debug
/p:DeployOnBuild=True
/p:DeployTarget=MSDeployPublish
/p:MsDeployServiceUrl=OurDevWebServer/msdeployagentservice
/p:AllowUntrustedCertificate=True
/p:MSDeployPublishMethod=RemoteAgent
/p:CreatePackageOnPublish=True
/p:DeployIisAppPath=umbraco_TestSite
/p:IgnoreDeployManagedRuntimeVersion=True
/p:SkipExtraFilesOnServer=True
/p:ExcludeFoldersFromDeployment="media;App_Data\Logs;App_Data\preview"
/p:IncludeSetAclProviderOnDestination=False
/p:AuthType=NTML /p:UserName=

答案 1 :(得分:1)

您无法通过命令行指定WPP跳过规则,因为它们被声明为项目,而不是属性。

以下是在pubxml(或wpp.targets)内声明跳过规则的语法:

<ItemGroup>
  <MsDeploySkipRules Include="SkipErrorLogFolder1"> 
    <SkipAction>Delete</SkipAction> 
    <ObjectName>filePath</ObjectName> 
    <AbsolutePath>ErrorLog</AbsolutePath> 
  </MsDeploySkipRules> 
</ItemGroup>

答案 2 :(得分:1)

实际上我已经在我的项目中实现了这个,如下所示:

<ItemGroup>
        <MsDeploySkipRules Include="SkipDeleteApp_Data_Import">
            <SkipAction></SkipAction>
            <ObjectName>dirPath</ObjectName>
            <AbsolutePath>$(_Escaped_WPPAllFilesInSingleFolder)\\App_Data\\Import</AbsolutePath>
        </MsDeploySkipRules>
    </ItemGroup>
    <ItemGroup>
        <MsDeploySkipRules Include="SkipDeleteApp_Data_File">
            <SkipAction></SkipAction>
            <ObjectName>filePath</ObjectName>
            <AbsolutePath>$(_Escaped_WPPAllFilesInSingleFolder)\\App_Data\\en-US-custom.txt</AbsolutePath>
        </MsDeploySkipRules>
    </ItemGroup>
相关问题