【问题标题】:How do I include appsettings.json configuration settings in a nuget package?如何在 nuget 包中包含 appsettings.json 配置设置?
【发布时间】:2017-11-23 13:56:32
【问题描述】:

我在 VS 团队服务上运行 .net core 1.1、nuget 3.5 和托管包。

我在这里研究了转换:https://docs.microsoft.com/en-us/nuget/create-packages/source-and-config-file-transformations

但我需要 json 文件的解决方案,而不是配置文件。

我了解到您可以使用 install.ps1 脚本来包含该文件,但我还了解到 install.ps1 已被弃用。

目前在 nuget 包中包含 json 配置文件的方法是什么?

【问题讨论】:

  • 如果您设置Build Action: ContentCopy to output directory文件属性,它将自动复制到content包的子文件夹。

标签: json asp.net-core nuget .net-core


【解决方案1】:

尝试在.nuspec 文件中使用<files> 节点。来自here的示例:

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
    <metadata>
    <!-- ... -->
    </metadata>
    <files>
    <!-- Add a readme -->
    <file src="readme.txt" target="" />

    <!-- Add files from an arbitrary folder that's not necessarily in the project -->
    <file src="..\..\SomeRoot\**\*.*" target="" />
    </files>
</package>

【讨论】:

    猜你喜欢
    • 2016-12-21
    • 1970-01-01
    • 2016-08-16
    • 1970-01-01
    • 2020-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-30
    • 1970-01-01
    相关资源
    最近更新 更多