2011-08-17 59 views
13

有沒有辦法在ASP.NET MVC項目的.csproj文件本身中設置MSDeploy參數?特別是一個「跳過」參數,它應該跳過一個「Temp」文件夾。如何在.csproj文件中設置MSDeploy設置

-skip:objectName=dirPath,absolutePath="\\temp" 

..或者如何將此參數傳遞到MSBuild.exe參數列表?

+0

您的目標是如何定義的?你明確運行msbuild.exe? – sll

+0

MSBuild.exe由TFS構建服務器執行,其參數類似於此:'/ p:DeployOnBuild = true; DeployTarget = MsDeployPublish; MSDeployPublishMethod = WMSVC; MsDeployServiceUrl = ...' –

+0

您可以像msbuild.exe/p:absolutePath =「\\ temp」? – sll

回答

10

在項目文件中定義<MsDeploySkipRules>。例如:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 
    <PropertyGroup> 
    <OnBeforePackageUsingManifest>AddSkipRules</OnBeforePackageUsingManifest> 
    </PropertyGroup> 
    <Target Name="AddSkipRules"> 
    <ItemGroup> 
     <MsDeploySkipRules Include="SkipTempDirOnDeploy"> 
     <SkipAction></SkipAction> 
     <ObjectName>dirPath</ObjectName> 
     <AbsolutePath>$(_Escaped_PackageTempDir)\\Temp$</AbsolutePath> 
     <XPath></XPath> 
     </MsDeploySkipRules> 
    </ItemGroup> 
    </Target> 
</Project> 
+8

爲了在部署期間通過Visual Studio「發佈」功能進行工作,必須使用'AfterAddIisSettingAndFileContentsToSourceManifest'而不是'OnBeforePackageUsingManifest'。查看評論http://blog.alanta.nl/2011/02/web-deploy-customizing-deployment.html?showComment=1314013105475#c1406362862563428999 –

+4

當我嘗試這個時,我得到「無法識別跳過指令'skipaction'」。在構建中。我錯過了什麼? –

+1

我得到和Paul Smith一樣的錯誤。 – Chris

相關問題