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!!
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!!
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:
Edit YourProject.csproj file,
<ItemGroup>
<Content Update="wwwroot/content/**/*.txt" CopyToPublishDirectory="Never" />
</ItemGroup>
BTW, I also tried these posts, which do not work:
.wpp.targets file: Excluding Files and Folders from DeploymentWeb Deploy Profile: Exclude unwanted binaries from azure packageExcludeFilesFromDeployment or ExcludeFoldersFromDeployment: Web Deployment: Excluding Files and Folders via the Web Application’s Project FileBy all those methods, web.config could not be excluded, even following this post:
How to exclude web.config when publishing with Visual Studio 2013?
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.
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.