NuGet不复制配置文件 [英] NuGet doesn't copy config file

查看:72
本文介绍了NuGet不复制配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在已经尝试了许多不同的方法,但是似乎都没有达到预期的效果.

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设置为contentresourceembedded resourceNone.

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?

推荐答案

一个想法可能是执行

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不复制配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆