How to Exclude a T4 Template from a NuGet Package

前提是你 提交于 2019-12-05 16:52:45
NuGet.exe Pack Client.csproj -Exclude **/*.tt

Turns out the easy solution is to use the -Exclude option when creating the package via the command line.

NuGet.exe Pack Client.csproj -Exclude *.tt

The new package will look exactly as specified in the question.

If you are using Azure DevOps, I tried for a long time either trying using a custom nuget pack command with the -exclude, which did not work, or tried adding a .nuspec file and excluding the content from there. However, nothing worked.

How I fixed it in our project is clicking on each .tt file and setting the "Build Action" from "Content" to "None". It didn't seem to have an affect on the project in any way.

Maybe someone has a better solution, but I struggled with it for 1-2 days until I decided to screw it and just change the build action.

In my case the problem was inside csproj file, I had to fix

<Content Include="SomeFile.txt" />

to

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