Include in project programmatically

半腔热情 提交于 2019-12-20 03:43:16

问题


How do we include a file in a project using code?

I want to include this file:

I also want the equivalent of this:

In code ... Is it possible?


回答1:


You can do this a few ways.

Command Line:

devenv /command "File.AddExistingSolutionItem fullpath\filename"

Project File:

The project file is XML. You can open and modify it like any file.

Code:

Use Microsoft.Build.Evaluation.Project to inspect and modify project files. The .AddItem() method is what you're looking for.



来源:https://stackoverflow.com/questions/15180527/include-in-project-programmatically

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