MSbuild command line parameter for skipping the directory

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

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=

MSbuild command line parameter for skipping the directory, 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,� Log the build output to a single file in the current directory. If you don't specify number, the output file is named msbuild.log. If you specify number, the output file is named msbuild<n>.log, where <n> is number. Number can be a digit from 1 to 9.

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>

MSBuild Command-Line Reference, If you run MSBuild from a shell other than the Windows command prompt, lists of arguments to a switch (separated by semicolons or If you don't specify a project file, MSBuild searches the current working directory for a file name Is this page helpful? Yes No. Any additional feedback? Skip Submit. I provided a sample project & msbuild command that is not working a month ago and have not heard a single word back. Pretty much until this issue is fixed, automated deployment is dead for anything that needs to transform a web config as a part of that deployment using the latest versions of MSBuild.

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>

Use MSBuild.exe to build specific targets in solutions, At the command line, type MSBuild.exe <SolutionName>.sln , where < SolutionName> project, which is located in the NewFolder solution folder. cmd Set the environment variable MSBUILDEMITSOLUTION=1 and build your solution. Is this page helpful? Yes No. Any additional feedback? Skip Submit. The example column in the table relates to the following example project file, assumed to be located at C:\Source\Repos\ConsoleApp1\ConsoleApp1, and shows the values of these properties have when accessed in the project file, when MSBuild is invoked with no special command-line options, with a preview build of Visual Studio 2019 version 16.7

MSBuild commandline seems to ignore publish properties � Issue , When I run msbuild from the commandline: "msbuild application.sln /p: DeployOnBuild=t MSBuild command to publish to a folder using the above publish profile: works ok but want to automate the process if the publishing is Skipped. @vijayrkn - Visual Studio itself is creating that parameter in the� If this parameter is not specified, the task uses the SDK installation path that corresponds to the version of the framework that is running MSBuild. UseCommandProcessor: Optional bool parameter. When set to true, this task creates a batch file for the command line and executes it by using the command-processor instead of executing the command

<msbuild> Task, Builds the specified targets in the project file using MSBuild . if, bool, If true then the task will be executed; otherwise, skipped. dir, directory, The value for a directory-based command-line argument; will be replaced with the absolute path of� When you invoke msbuild /target:publish at the command line, it tells the MSBuild system to build the project and create a ClickOnce application in the publish folder. This is equivalent to selecting the Publish command in the IDE. This command executes msbuild.exe, which is on the path in the Visual Studio command-prompt environment.

Analyzing with SonarQube Scanner for MSBuild - Scanners, To use it, execute the following commands from the root folder of your of scanner have the same capabilities and command line arguments. Most task parameters, and a few sets of parameters, correspond to a command-line option. AdditionalIncludeDirectories. Optional String[] parameter. Adds a directory to the list of directories that are searched for include files. For more information, see /I (Additional include directories). AdditionalOptions. Optional String parameter. A list

Comments
  • I have a follow up question: How do you skip a directory during VS Build in VSTS?
  • Thanks for reply. i will try and let you know
  • 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 "-".
  • Richard thanks for your help, i found out alternative , i added following code in .csproj file <ExcludeFoldersFromDeployment>Data</ExcludeFoldersFromDeployment> and it worked for me
  • @user1200750 - You should add that as a separate answer and mark it as correct.