2

I am using a custom target for publishing my web site to a local folder.

The target (found here) looks like:

<Target Name="PublishToFileSystem"
        DependsOnTargets="PipelinePreDeployCopyAllFilesToOneFolder">
    <Error Condition="'$(PublishDestination)'==''"
           Text="The PublishDestination property must be set to the intended publishing destination." />
    <MakeDir Condition="!Exists($(PublishDestination))"
             Directories="$(PublishDestination)" />

    <ItemGroup>
        <PublishFiles Include="$(_PackageTempDir)\**\*.*" />
    </ItemGroup>

    <Copy SourceFiles="@(PublishFiles)"
          DestinationFiles="@(PublishFiles->'$(PublishDestination)\%(RecursiveDir)%(Filename)%(Extension)')"
          SkipUnchangedFiles="True" />
</Target>

The corresponding msbuild command looks like:

msbuild projectfile.csproj /p:DeployOnBuild=true /p:VisualStudioVersion=14.0 /p:configuration=Release /p:PublishDestination=C:\inetpub\wwwroot\WebSite /T:PublishToFileSystem

That works fine so far. However, I would like to exclude the APP_DATA directory from publishing.

So, is there a way to exclude the APP_DATA directory from publishing? Maybe by excluding it from the file set defined with <PublishFiles Include="$(_PackageTempDir)\**\*.*" />?

Environment: Visual Studio 2015 MSBuild Tools 2015

Community
  • 1
  • 1
JanDotNet
  • 3,746
  • 21
  • 30

3 Answers3

3

The easiest way I found is to set this inside the publish profile.

<ExcludeApp_Data>False</ExcludeApp_Data>

enter image description here

dwp4ge
  • 1,963
  • 22
  • 27
2

You can do it from solution property. Just right click on solution and choose its property. You will get Package/Publish tab there you just need to check "Exclude files from the App_Data Folder". You can check at attached screen shot. Hope this can help you.enter image description here

Vipin Rathore
  • 148
  • 1
  • 9
  • Thanks for the answer. Unfortunately I am using VS2015 (MSBuild ToolsVersion 14.0) where the option is not available anymore. Regarding to [this post](http://stackoverflow.com/questions/32570047/how-to-exclude-folders-from-publish-deployment-of-visual-studio-2013-web-applica), the option is moved to the pubxml file (which is not part of my publish procedure). – JanDotNet Jan 04 '17 at 12:55
0

It is possible to set the option (suggested by @Vipin Rathore) within the project file:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <ExcludeFoldersFromDeployment>APP_DATA</ExcludeFoldersFromDeployment>
</PropertyGroup>
JanDotNet
  • 3,746
  • 21
  • 30