【问题标题】:Dependencies of the solution folders解决方案文件夹的依赖关系
【发布时间】:2014-12-29 22:41:14
【问题描述】:

我创建了一些 Visual Studio 扩展并以编程方式创建解决方案文件夹。 但我不知道如何从另一个解决方案文件夹创建依赖项一个解决方案文件夹? 任何人都可以帮助我解决这个问题吗?谢谢!

|--- SolutionFolder
|          |--- SolutionFolder
|          |--- SolutionFolder
|--- SolutionFolder

这是我的代码:

(object sender, EventArgs args) =>
{
    Guid slnFldrGuid = new Guid("2150E333-8FDC-42A3-9474-1A3956D46DE8");
    Guid iidProject = typeof(IVsHierarchy).GUID;

    IVsSolution solution = GetService<IVsSolution, SVsSolution>();
    IVsHierarchy parent = UIShellUtilities.GetSelectedHierarchy();
    IVsHierarchy nested = null;

    IntPtr project = IntPtr.Zero;
    int canceled = 0;

    if ((null != solution) && (null != parent))
    {
        IVsProjectFactory factory = null;

        ErrorHandler.ThrowOnFailure(solution.GetProjectFactory(
            0, new Guid[] { slnFldrGuid }, null, out factory));

        try 
        {
            ErrorHandler.ThrowOnFailure(factory.CreateProject(
                null, null, "New My Folder", 0, ref iidProject,  out project, out canceled));

            if (project != IntPtr.Zero)
            {
                nested = Marshal.GetTypedObjectForIUnknown(project, typeof(IVsHierarchy)) as IVsHierarchy;

                Debug.Assert(nested != null, "Nested hierarchy could not be created");
                Debug.Assert(canceled == 0);
            }
        } finally
        {
            if (project != IntPtr.Zero)
                Marshal.Release(project);
        }

        uint itemid = VSConstants.VSITEMID_ROOT;

        // Link into the nested VS hierarchy.
        //ErrorHandler.ThrowOnFailure(nested.SetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ParentHierarchy, parent));
        //ErrorHandler.ThrowOnFailure(nested.SetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ParentHierarchyItemid, (object)itemid));
    }                        
}

【问题讨论】:

    标签: c# visual-studio-2010 directory solution vsx


    【解决方案1】:

    使用自动化模型 EnvDTE 创建嵌套解决方案文件夹要容易得多,它也可以从包中使用。

    见:

    如何在另一个解决方案文件夹中创建一个解决方案文件夹 http://blogs.msmvps.com/carlosq/2013/12/03/how-to-create-a-solution-folder-inside-another-solution-folder/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-05
      • 1970-01-01
      相关资源
      最近更新 更多