ExcludeFoldersFromDeployment在发布配置文件中不起作用

时间:2017-01-09 04:33:18

标签: visual-studio tfs

我正在尝试使用ExcludeFoldersFromDeployment排除发布配置文件中的文件夹,但是在发布到azure-app服务时它并不存在

文件夹位置:\ b \ c \ foldername

如果有人可以提供帮助,请告诉我!

3 个答案:

答案 0 :(得分:1)

如果您在此环境中工作,以防有人因不同的EXCLUDE方法感到困惑,请添加一个附加答案:

Visual Studio 2017 + ASP.NET core 2 + Azure应用服务。

尝试一下:

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

编辑YourProject.csproj文件,

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

顺便说一句,我也尝试了这些帖子,这些帖子不起作用:

  1. 使用.wpp.targets文件:Excluding Files and Folders from Deployment
  2. 使用Web Deploy ProfileExclude unwanted binaries from azure package
  3. 使用ExcludeFilesFromDeploymentExcludeFoldersFromDeploymentWeb Deployment: Excluding Files and Folders via the Web Application’s Project File

通过所有这些方法,即使遵循这篇文章,也无法排除web.configHow to exclude web.config when publishing with Visual Studio 2013?

答案 1 :(得分:0)

根据this文章,您需要编辑.pubxml或.wpp.targets文件并添加 ExcludeFilesFromDeployment 元素或 ExcludeFoldersFromDeployment 元素(或者两者都在 PropertyGroup 元素中。检查您是否具有正确的设置,如示例所示:

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

排除文件或文件夹的另一个选择是使用PublishIgnore NuGet包。在.NET Web开发和工具博客的Web Publishing a simpler way to exclude files/folders from being published中解释了此选项。

答案 2 :(得分:0)

我也在努力解决这个问题,在查看@Dongdong答案后,我得出以下结论: 编辑YourProject.csproj文件,并添加以下内容

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

您也可以应用一些条件。

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

您可以根据需要扩展它。该目录中排除的文件将不会发布。

相关问题