[英]Unable to exclude files when automated deployment is run from TFS 2013 using build definition file
我正在嘗試使用構建定義文件從TFS 2013運行自動部署時排除文件。
我在“構建定義”中使用的自變量(MSBuild自變量)如下:
/p:DeployOnBuild=True /p:DeployTarget=MSDeployPublish /p:CreatePackageOnPublish=True
/p:MSDeployPublishMethod=WMSVC /p:MSDeployUseChecksum=true /p:AuthType=NTLM
/p:AllowUntrustedCertificate=True /p:MSDeployServiceUrl=https://servername/msdeploy.axd
/p:DeployIisAppPath="TestSite" /p:UserName=
在構建定義中,我已經將Configuration提到為“任何CPU |發行版”,並且與我在csproj中提到ExcludeFoldersFromDeployment相對應:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ExcludeFilesFromDeployment>bin\some.dll</ExcludeFilesFromDeployment>
<ExcludeFoldersFromDeployment>someFolder</ExcludeFoldersFromDeployment>
</PropertyGroup>
當我右鍵單擊項目並單擊發布時,它成功排除了這些文件,但是當我嘗試通過構建定義運行它時,它並不排除這些文件和文件夾。
請幫忙。 我也嘗試過使用wpp.targets文件。 但是沒有運氣。
我能夠找到解決方法。 不完全是一種解決方法。 所以就到這里。 右鍵單擊項目,然后單擊發布。 在“個人資料”部分下,創建一個新的個人資料。 給它起個名字,比如說“ TestDeployment”。 保存並關閉窗口。 這將在您的項目中生成一個.pubxml文件,其位置為\\ Properties \\ PublishProfile。 在此文件下,我們可以定義跳過規則。 在下面添加以下行:
<AfterAddIisSettingAndFileContentsToSourceManifest>AddCustomSkipRules</AfterAddIisSettingAndFileContentsToSourceManifest>
在該元素之外添加以下內容:
<Target Name="AddCustomSkipRules">
<Message Text="Adding Custom Skip Rules" />
<ItemGroup>
<!--Skipping folders-->
<MsDeploySkipRules Include="Skip_some_Folder">
<ObjectName>dirPath</ObjectName>
<AbsolutePath>$(_DestinationContentPath)\\bin\\some</AbsolutePath>
<XPath>
</XPath>
</MsDeploySkipRules>
</ItemGroup>
</Target>
請注意,這是一個正則表達式。 在這里,我跳過了一個文件夾,所以我提到了“ dirPath”。 如果必須跳過文件,則將其設置為“ filePath”。 保存此文件,並在構建定義中,轉到Process,然后在“ MSBuild arguments”下添加:
/p:DeployOnBuild=True /p:PublishProfile=TestDeployment
在這里,我添加了“ DeployOnBuild”,以便僅在構建通過后才運行。 在“ PublishProfile”下,我提到了我們生成的.pubxml的名稱。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.