c# - Overridable configuration in a .NET Core nuget package - Stack Overflow

I have a .NET Core library that needs a specific configuration file in order to work, so I have incorpo

I have a .NET Core library that needs a specific configuration file in order to work, so I have incorporated the file in the nuget package as an asset so that it will work straight away when deployed.

However I would also like to be able to override that configuration file. In Visual Studio I can do this by having a copy of the file in my project folder configured to copy to output, but when it runs under the dotnet command line I get the following message:

error NETSDK1152: Found multiple publish output files with the same relative path

Reading the documentation suggests that there is no guarantee of which file will "win" when they are copied.

Obviously, that doesn't work for me, but the pattern I'm looking for is entirely consistent: If there is a configuration in the project use that, otherwise use the default from the library.

Is there a simple way to configure this in my project or in my build so that I can have the project version always override the default and avoid the error mentioned above?

I can see an alternative where I pass in a different configuration file name as an environment variable, but it feels a bit scruffy and ends up with two configuration files in the deployment folder, one of which will never be used.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744077024a4554587.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信