如何以编程方式向项目添加现有项目? [英] How to Add an Existing Item to a Project Programmatically?

查看:98
本文介绍了如何以编程方式向项目添加现有项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何以编程方式将项目添加到项目中?

类似

public void AddExistingItem(string projectPath, string existingItemPath)
{
    //I'm making up the Project class here as an example
    Project p = new Project(projectPath);
    p.AddExistingItem(existingItemPath);
}

我想模仿Visual Studio的添加现有项"功能.

解决方案

添加对EnvDTE.dll的引用,然后使用此页面上阅读,您必须设置如果您添加对EnvDTE.dll的引用,则将该程序集的Interop Types 属性嵌入到false中.

How can I programmatically add an item to a project?

Something similar to

public void AddExistingItem(string projectPath, string existingItemPath)
{
    //I'm making up the Project class here as an example
    Project p = new Project(projectPath);
    p.AddExistingItem(existingItemPath);
}

I want to mimic Visual Studio's Add Existing Item functionality.

解决方案

Add a reference to EnvDTE.dll, and then use ProjectItems.AddFromFile method
As you can read on this page, you must set the Embed Interop Types property of the assembly to false if you add a reference to EnvDTE.dll

这篇关于如何以编程方式向项目添加现有项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆