MSbuild command line parameter for skipping the directory
Asked Answered
S

3

3

I have following command line parameters in team city for deployment. everything works fine but i want to skip some directory while deployment. how can i add that logic in following msbuild script in team city

/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
Solidus answered 19/10, 2012 at 20:34 Comment(1)
I have a follow up question: How do you skip a directory during VS Build in VSTS?Fluctuant
P
7

I was working on the same thing. I didn't like having to modify my .csproj file, so I tried this. It is working for me so far. In my case, I was excluding the media, App_Data\Logs, and App_Data\preview folders from deployment instead of the Data folder.

Basically, you can pass the ExcludeFoldersFromDeployment as a parameter to MSBuild. Combining that with the SkipExtraFilesOnServer does the trick.

/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=
Porshaport answered 7/4, 2014 at 19:25 Comment(0)
P
1

You can't specify a WPP skip rule via the command line because they are declared as items, not properties.

Here is the syntax for declaring the skip rule inside your pubxml (or wpp.targets):

<ItemGroup>
  <MsDeploySkipRules Include="SkipErrorLogFolder1"> 
    <SkipAction>Delete</SkipAction> 
    <ObjectName>filePath</ObjectName> 
    <AbsolutePath>ErrorLog</AbsolutePath> 
  </MsDeploySkipRules> 
</ItemGroup>
Photomultiplier answered 21/10, 2012 at 0:37 Comment(4)
Thanks for reply. i will try and let you knowSolidus
i added your code in my wpp.targets and run the above command from team city but the same result, its not skipping the folder name Data. when i try to run from vs 2012 it gives me following error MSDEPLOY(0,0): Error : Unrecognized argument 'Web'. All arguments must begin with "-".Solidus
Richard thanks for your help, i found out alternative , i added following code in .csproj file <ExcludeFoldersFromDeployment>Data</ExcludeFoldersFromDeployment> and it worked for meSolidus
@Solidus - You should add that as a separate answer and mark it as correct.Photomultiplier
G
1

Actually I already implement this in my project as follow:

<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>
Gnathous answered 17/4, 2013 at 6:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.