NuGet 包,无需将文件添加到 Visual Studio 项目
我刚刚开始使用 NuGet,并试图理解它。我可能正在尝试使用 NuGet 来做一些它不适合的事情,但我希望有人能给我一些提示。
我的问题:我正在尝试创建一个包含不同文件的包。文件有不同的类型(图像、文本文件等)。我希望该包能够工作,以便将文件添加到我的应用程序根目录中,但不包含在我的 Visual Studio 项目中。我已经尝试过,但文件总是添加到项目中。有办法解决这个问题吗?
谢谢
I am just getting started with NuGet and trying to get my head around it. I may be trying to use NuGet for someting it isn't intended for, but I was hoping someone might give me some hints.
My issue: I am trying to create a package with different files. The files is of different type (images, text files, etc.). I want the package to work, so that the files get added to my application root, but isn't included in my visual studio project. I have tried it, but the files is always added to the project. Is there a way around this?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
今天还没有对此的直接支持。安装包后,您放入内容文件夹中的任何内容都会添加到您的项目中。
但是,您应该能够使用 install.ps1 脚本实现此结果,例如:
There is no direct support for this today. Anything that you put in the content folder gets added to your project when the package is installed.
However, you should be able to achieve this result using an install.ps1 script, e.g.:
您可以将文件放在 nuget 数据包中的另一个文件夹(不是内容)中,并将 .targets 文件添加到 nuget 数据包中,在构建时复制文件。
MyProject.nuget 文件:
MyProject.targets 文件:
当您构建最终应用程序时,文件将被复制到构建目标文件夹。
You can put your files in another folder (not content) in the nuget packet and add a .targets file to your nuget packet copy the files at build time.
MyProject.nuget file:
MyProject.targets file:
When you build your final Application the files will be copy'ed to the build target folder.