将导入添加到项目文件 [英] add import to project file

查看:85
本文介绍了将导入添加到项目文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个解决方案向导,在其中添加了几个项目.其中之一是WiX项目,为此我需要在项目文件中添加另一个导入标签.我怎么做?在我的项目中,我有一个名为proj的EnvDTE.Project对象.我尝试做((WixProjectNode)proj.Object),但它似乎没有提供任何有用的方法或属性.我还尝试像这样卸载,修改和加载项目:
aUIHierarchyItem.Select(vsUISelectionType.vsUISelectionTypeSelect);
dte.ExecuteCommand(``Project.UnloadProject'',string.Empty); <我只会得到:
命令'Project.UnloadProject';不可用.
消息.那么,如何将导入添加到我的WiX项目中呢?作为最后的办法,我可以创建自己的WiX项目模板,但如果可能的话,我希望避免这种情况.

I'm writing a solution wizard inside which I add several projects. One of them is WiX project for which I need to add another import tag in project file. How do I do that? Inside my project I have an EnvDTE.Project object named proj. I tried to do ((WixProjectNode)proj.Object) but it doesn't seem to provide any useful methods or properties. I also tried unloading, modifying and loading project like that:
            aUIHierarchyItem.Select(vsUISelectionType.vsUISelectionTypeSelect);
            dte.ExecuteCommand("Project.UnloadProject", string.Empty);
but I only get:
            Command "Project.UnloadProject" is not available.
message. So how do I go about adding import to my WiX project? As a last resort I can create my own WiX project template but I would like to avoid that if at all possible.

推荐答案

您好,汤姆
您可以使用 Project.AddNewImport方法添加新导入.但是,您需要先卸载项目,然后使用File.Save命令保存MSBuild脚本,然后再重新加载项目.
Hello, Tom
You could use Project.AddNewImport Method to add the New import. But you need to unload the project first and use File.Save Command to save the MSBuild Script before you reload your project.
命令"Project.UnloadProject"不可用. 表示未选择项目文件.在执行Project.UnloadProject之前,必须确保选择了正确的Node.
And Command "Project.UnloadProject" is not available. means that the project file are not selected. You must make sure that you have selected the right Node before you execute the Project.UnloadProject.


这篇关于将导入添加到项目文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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