net core 2.0 appsettings.json save on bin directory

烈酒焚心 提交于 2019-12-22 07:39:08

问题


I am new in net core 2.0.

I am connecting to datbase. I am used to use an App.Config or Web.Config to set the connection string. But in net core 2.0 uses appsettings.json file instead.

When I compile de Application, appsettings.json file is not generated in bin directory. So when I run the appplication from Console c>dotnet prj.dll thrown an excepción because connection file is not found.

My question is... I have to copy appsettings.json file manually to bin directory or is there a way to save it in bin directory when Project is compiled?

thanks


回答1:


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.

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>

.



来源:https://stackoverflow.com/questions/48708965/net-core-2-0-appsettings-json-save-on-bin-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!