How to deploy T4 include files with NuGet package

会有一股神秘感。 提交于 2019-12-04 11:55:22

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

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.

See: http://docs.nuget.org/docs/reference/nuspec-reference

The T4 include directive doesn't recognise msbuild properties, but the assembly one does. So you can use a base template class and reference an assembly from within your NuGet package.

With NuGet 2.5 (probably not available at the time of the original post) you can create an msbuild .props file. Assign $(MSBuildThisFileDirectory) combined the relative path to the assembly to a new msbuild property. The new property can then used in the T4 template of projects which are using the NuGet package.

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