nuget - 在 dotnet 包中包含自定义配置文件

标签 nuget .net-core .net-standard

我在 .netstandard2.0 项目中有一个配置文件,我想在打包时将它包含在同一目录中,我已经在 csprof 文件中有这个:

  <ItemGroup>
    <None Include="load.config">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
  </ItemGroup>

当我用 dotnet build 构建它时,配置文件确实被复制到输出目录,但是当dotnet pack , nugget 只包含 .dll,不包含 .config 文件,我如何在 nugget 包中包含这个配置文件?

最佳答案

尝试添加 Pack="true"属性(property):

<ItemGroup>
    <None Include="load.config" Pack="true">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
</ItemGroup>

您可能还需要指定 PackagePath属性(property)也是如此。我在 files section 中找到了 sample .

关于nuget - 在 dotnet 包中包含自定义配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48337110/

相关文章:

c# - Razor Core 安装 jquery.unobtrusive.ajax 缺少 js 文件

asp.net - 将 NuGet 与 ASP.NET "Web Site"项目中的 *.dll.refresh 文件与 Web 部署项目一起使用

.net - HTTP 错误 500 : localhost is currently unable to handle this request

c# - .NET Standard 是否在它支持的每个平台上标准化 HResult 值?

c# - 在 Visual Studio 中的多存储库中开发和调试项目

c# - 为什么 C# 引用在 NuGet 和 Visual Studio 之间添加不同

c# - .Net Core - IConfigurationRoot 读取整个 json 文件

c# - .NET Core 中抽象类的依赖注入(inject)

c# - .Net Standard 对 Nuget 包的依赖

c# - Azure Function 中的 Html 到 Pdf 库