【问题标题】:Adding Solution Items in a project template wizard在项目模板向导中添加解决方案项
【发布时间】:2012-03-14 17:45:06
【问题描述】:

我正在尝试使用项目模板向导将文件添加到 Visual Studio“解决方案项”文件夹。我可以自己创建文件夹,但是当我添加文件时,它什么也没做。

我的代码(从ProjectFinishedGenerating 执行)是

    fullPath = @"path_to_existing_file";
    _solutionFolder.AddFromFile(fullPath);

其中 _solutionFolder 是与解决方案文件夹对应的 Project 实例。

【问题讨论】:

标签: visual-studio-2010 vs-extensibility project-template


【解决方案1】:

我遇到了同样的障碍。您需要将其添加到 ProjectItems:

var _solutionFolder = _vsSolution.AddSolutionFolder(folder);
_solutionFolder.ProjectItems.AddFromFile(fullPath);

注意,我没有尝试过上面的代码。我正在根据我的代码(在插件中运行)对其进行调整:

Dim project As EnvDTE.Project = _vsSolution.AddSolutionFolder(folderName)
_folder = CType(project.Object, SolutionFolder)
_folder.Parent.ProjectItems.AddFromFile(file)

【讨论】:

  • 没有 AddSolutionFolder 方法。
猜你喜欢
  • 2023-03-10
  • 1970-01-01
  • 2013-02-25
  • 2013-02-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-13
  • 2012-07-06
相关资源
最近更新 更多