.Net7 自动拷贝appsettings.json到debug文件下
- IDE
Rider
在配置json时遇到路径的问题The configuration file 'appsettings.json' was not found and is not optional. The expected physical path was
IConfiguration config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json5")
.Build();
- 需要修改
.csproj
文件 在ItemGroup
下添加 添加完成如下
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
<Content Include="appsettings.json5">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
之后会自动拷贝appsettings.json5文件到运行目录方便很多
本文作者:Z_DK
本文链接:https://www.cnblogs.com/xslx/p/16994711.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
分类:
.NetCore
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步