NuGet doesn't copy config file

北慕城南 提交于 2019-12-23 09:39:36

问题


I've tried many different things now, none of which seem to work out as expected.

I would like to share an example config(or image or whatever) file with my library that someone would be able to use and derive from. I tried to default to just To do so I tried to include it in the nuget package via *.nuspec and via *.csproj. None of which worked.

For the *.nuspec part, I've tried this:

<file src="bin\$configuration$\example.mylib.config" target="lib\net45" />
<file src="bin\$configuration$\example.mylib.config" target="build" />
<file src="bin\$configuration$\example.mylib.config" target="bin" />

I've also tried this, but that only copies the file to the other projects sources, which is not what I want. I would like it to only show up in the output of the build.

<file src="bin\$configuration$\example.mylib.config" target="content" />

For the *.csproj part, I've tried to set the build action of the file to content, resource, embedded resource and None.

Is there a way at all? Is there a way to tell nuget, take this file, and behave like the dll I'm providing needs this by it's side, wherever you build?


回答1:


One thought might be to perform a config file transformation. Rather than just deploying a config file directly, you could modify the app.config or web.config on the project with a sample for the user to apply. Alternatively, as you mentioned in your comment, you could add in a Powershell script to perform the manipulations you were considering.



来源:https://stackoverflow.com/questions/19830557/nuget-doesnt-copy-config-file

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