5

I am trying to exclude a folder in publish profile using ExcludeFoldersFromDeployment but it is not wxcluding while publishing to azure-app service

folder location : a\b\c\foldername

Please let me know if anyone can help!!

neha
  • 443
  • 1
  • 6
  • 12
  • Which version of TFS are you using? Do you use XAML build or v-next build to publish to azure-app service? How's your build definition look? If you publish locally without TFS, is ExcludeFoldersFromDeployment working? – Cece Dong - MSFT Jan 09 '17 at 09:41

4 Answers4

10

Add an additional answer, in case someone got confused by different EXCLUDE methodologies, if you are working in this environment:

Visual Studio 2017 + ASP.NET core 2 + Azure App Service.

try this:

https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/visual-studio-publish-profiles?view=aspnetcore-2.1#exclude-files

Edit YourProject.csproj file,

<ItemGroup>
  <Content Update="wwwroot/content/**/*.txt" CopyToPublishDirectory="Never" />
</ItemGroup>

BTW, I also tried these posts, which do not work:

  1. use .wpp.targets file: Excluding Files and Folders from Deployment
  2. Use Web Deploy Profile: Exclude unwanted binaries from azure package
  3. Use ExcludeFilesFromDeployment or ExcludeFoldersFromDeployment: Web Deployment: Excluding Files and Folders via the Web Application’s Project File

By all those methods, web.config could not be excluded, even following this post: How to exclude web.config when publishing with Visual Studio 2013?

Dongdong
  • 2,208
  • 19
  • 28
0

According to this article, you need to edit the .pubxml or the .wpp.targets file and add an ExcludeFilesFromDeployment element or an ExcludeFoldersFromDeployment element (or both) in the PropertyGroup element. Check whether you have correct setting as the example shows:

<PropertyGroup">
  <ExcludeFilesFromDeployment>
    File1.aspx;File2.aspx
  </ExcludeFilesFromDeployment>
  <ExcludeFoldersFromDeployment>
    Folder1;Folder2
  </ExcludeFoldersFromDeployment>
</PropertyGroup> 

Another option to exclude files or folders is to use the PublishIgnore NuGet package. This option is explained in Web Publishing a simpler way to exclude files/folders from being published on the .NET Web Development and Tools blog.

Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39
0

In order to exclude folders from a Blazor hosted app (like a PWA) you need to add the exclusion to the Client project, not to the Server.

I.e., you have a solution with a project named Server and a project named Client.
The Client.csproj should contains the exclusion, like:

    <ItemGroup>
        <Content Update="wwwroot\images\contents\**" CopyToPublishDirectory="Never" />
    </ItemGroup>

Now, the wwwroot folder created by the Server.pubxml will not contains the images/contents folder and sulfolders.

Nicola Biada
  • 2,325
  • 1
  • 8
  • 22
-1

I was also struggling with the issue and after looking at the @Dongdong answer I came to following conclusion: Edit YourProject.csproj file and include the following

  <ItemGroup>
      <Content Update="web.Debug.config;web.Release.config;web.QA.config;appsettings.Debug.json;appsettings.Release.json;" CopyToPublishDirectory="Never" />
  </ItemGroup>

You can also apply some condition as well.

  <ItemGroup>
      <Content Condition="'$(Configuration)|$(Platform)'=='QA|AnyCPU'" Update="appsettings.json;" CopyToPublishDirectory="Never" />
  </ItemGroup>

You can extend it as per your requirement. Excluded files from the directory won't be published.

Haris
  • 1,179
  • 7
  • 15
  • 32