且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

net core 2.0 appsettings.json保存在bin目录中

更新时间:2023-02-14 15:17:35

我一直在寻找这个问题的答案,而我发现的大多数帖子都引用了project.json文件,该文件现在已被弃用,以支持.csproj文件根据本指南于2017年3月发布

I've been looking for an answer to this question and most of the posts I've found reference the project.json file which has now been deprecated in favour of the .csproj file according to this guide published March 2017.

此文档还指出如何在.csproj文件中使用 CopyToOutputDirectory属性,以确保将appsettings.json文件复制到内部版本的输出目录中:

This document also indicates how you can use the "CopyToOutputDirectory" attribute in your .csproj file to ensure your appsettings.json file is copied to the output directory on build:

<Project ...>
    ...
    <ItemGroup>
        <None Include="appsettings.json" CopyToOutputDirectory="Always" />
    </ItemGroup>
</Project>