如何在VS 2010中添加生成的代码文件作为依赖文件?

时间:2011-04-25 13:13:56

标签: visual-studio-2010 code-generation t4

我正在使用T4模板自动化我的项目。为此,我必须使用T4模板和一些不应被T4模板覆盖的手写代码来编写一些重复的代码。我想将生成的代码文件添加为手写文件的依赖文件。我遵循手写文件的class1.cs和生成文件的class1.generated.cs的约定。如何在项目中将此生成的文件作为class1.cs的依赖文件添加?

1 个答案:

答案 0 :(得分:1)

要以编程方式执行此操作,您必须直接修改.csproj文件。有关详细信息,请参阅此问题: In Visual Studio (2008) is there a way to have a custom dependent file on another custom file?

如果要通过IDE执行此操作,请使用Visual Studio 2010的VSCommonds加载项。