如何在nuget包中包含appsettings.json配置设置?

时间:2017-06-20 21:02:52

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

我正在运行.net核心1.1,nuget 3.5,以及在VS团队服务上托管软件包。

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

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

我读过您可以使用install.ps1脚本来包含该文件,但我还读到了不推荐使用install.ps1。

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

1 个答案:

答案 0 :(得分:3)

尝试在<files>文件中使用.nuspec节点。 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>