admin 管理员组

文章数量: 1086019

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.

本文标签: cOverridable configuration in a NET Core nuget packageStack Overflow