问题描述
我现在已经尝试了许多不同的方法,但是似乎都没有达到预期的效果.
I've tried many different things now, none of which seem to work out as expected.
我想与我的库共享一个示例config(或图像或其他内容)文件,以供他人使用和派生.我尝试将默认值设置为仅为此目的,我尝试通过*.nuspec
和*.csproj
将其包含在nuget包中.没有一个起作用.
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.
对于*.nuspec
部分,我已经尝试过:
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" />
对于*.csproj
部分,我尝试将文件的build action
设置为content
,resource
,embedded resource
和None
.
For the *.csproj
part, I've tried to set the build action
of the file to content
, resource
, embedded resource
and None
.
有没有办法?有没有办法告诉nuget
,获取此文件并使其表现为我提供的dll,无论您在哪里构建,它都需要它?
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?
推荐答案
一个想法可能是执行配置文件转换.您可以使用示例来修改项目上的app.config
或web.config
,以供用户应用,而不仅仅是直接部署配置文件.另外,正如您在评论中提到的那样,您可以添加Powershell脚本来执行您正在考虑的操作.
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.
这篇关于NuGet不复制配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!