1

I am trying to exclude files when automated deployment is run from TFS 2013 using build definition file.

The arguments (MSBuild Arguments) I am using in Build Definition are as follows:

 

/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=

 

In the build definition i have mentioned Configuration as "Any CPU|Release" and corresponding to that I have mentioned ExcludeFoldersFromDeployment in csproj:

<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>

When I right click on project and click publish it excludes these files successfully, but when i try to run this through build definition it doesn't exclude these files and folders.

Please help. I have tried using wpp.targets file also. But no luck.

Himanshu Singla
  • 390
  • 3
  • 11

1 Answers1

0

I was able to find a workaround. Not exactly a workaround. So here it goes. Right click on project and click publish. Under Profile section, make a new profile. Give it a name, lets say 'TestDeployment'. Save and close the window. This generates a .pubxml file in your project, location of which is \Properties\PublishProfile. Under this file we can define our skip rules. Under the add the following line:

<AfterAddIisSettingAndFileContentsToSourceManifest>AddCustomSkipRules</AfterAddIisSettingAndFileContentsToSourceManifest>

And outside of that element add the following:

  <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>

Please note that is a regular expression. Here I am skipping a folder so I have mentioned as 'dirPath'. If you have to skip files then make it 'filePath'. Save this file and in the build definition, go to Process and then under 'MSBuild arguments' add:

/p:DeployOnBuild=True /p:PublishProfile=TestDeployment

Here I have added 'DeployOnBuild' so that this runs only when build has passed. And under 'PublishProfile' I have mentioned the name of the .pubxml that we generated.

Himanshu Singla
  • 390
  • 3
  • 11