包括dotnet包中的自定义配置文件

问题描述 投票:1回答:1

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

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

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

nuget .net-core .net-standard
1个回答
3
投票

尝试添加Pack="true"属性:

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

您可能还需要指定PackagePath属性。我在files section找到了样品。

© www.soinside.com 2019 - 2024. All rights reserved.