如何部署T4包括文件的NuGet包文件、NuGet

2023-09-07 09:17:32 作者:Ednburgh 北海

我有一些T4包括我想重用在多个项目中的文件。所以,我创建了一个的NuGet包,并放置在包中的工具文件夹中的文件。现在,它们安装在包\ PackageName.xxx \ Tools文件夹,我可以在我的T4文件在项目中添加一个include指令。 但这个缺点是,有在路径中的versionNumber当我创建包的新版本,这将改变。这需要对子级我更新都包含在项目中的指令。 任何的提示为一个很好的方法?

I have some T4 include files which I want to reuse in several projects. So I have created a NuGet package and placed the files in the Tools folder of the package. Now they are installed in the packages\PackageName.x.x.x\Tools folder and I can add an include directive in my T4 files in the project. But the disadvantage of this is, that there is a versionnumber in the path which will change when I create a new version of the packages. That whould require me to update all include directives in the project. Anyone a hint for a good approach for this?

谢谢,夏侯

推荐答案

如果这些T4模板都应该产生内库code,那么你可以把它们放到内容目录。

If these T4 templates are supposed to generate code inside libraries then you could put them into the content directory.

它们将被添加到具有参考的NuGet包的库。因此,重命名工具的内容(或添加一个新的文件夹的内容),你应该没问题。您还可以添加子文件夹到该文件夹​​。或者把的.cs文件在里面。

They will be added to the library having the reference to the nuget package. So rename tools to content (or add a new folder content) and you should be ok. You can also add subfolders to that folder. Or put .cs files in there.

请参阅: http://docs.nuget.org/docs/reference/nuspec-参考