.net - 从 VS 2017 .NET Core 项目中的发布目录中排除文件

标签 .net asp.net-core .net-core visual-studio-2017 dotnet-cli

我的项目的 wwwroot 文件夹中有一个 .gitignore 文件,我试图将其排除在发布之外。以下代码似乎不起作用:

<ItemGroup>
  <Content Include="wwwroot\.gitignore">
    <CopyToPublishDirectory>Never</CopyToPublishDirectory>
  </Content>
</ItemGroup>

当我使用 dotnetpublish 命令发布项目时,.gitignore 文件仍然可以在输出目录中找到。

最佳答案

您必须像这样使用Update:

<Content Update="wwwroot\.gitignore">
  <CopyToPublishDirectory>Never</CopyToPublishDirectory>
</Content>

关于.net - 从 VS 2017 .NET Core 项目中的发布目录中排除文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42490607/

相关文章:

C# - 使用 Python 文件中的方法

c# - 如何在C#程序中获取任务栏通知区域宽度?

c# - 为什么 TPL 不支持状态过滤的多任务延续?

azure - 将角色名称添加到 Application Insights 遥测

.net - Control.Invoke 是否发送消息?

asp.net-core - 生成的 jwt token 中的受众为空

c# - 如何使用默认本地化创建用于本地化的 SharedResource 类

c# - Net Core 集成测试 : Run Startup. cs 和来自其他程序的配置

c# - automapper 继承 Profile 返回 json 中的额外属性

c# - NLog 环境变量配置文件