Add solution folder to visual studio project template

后端 未结 5 718
忘掉有多难
忘掉有多难 2021-01-06 17:18

Is it possible to add a solution folders with the project template? If it\'s not built in functionality, is it possible to create a custom task for this?

5条回答
  •  孤城傲影
    2021-01-06 18:03

    You can do it using template wizards. I guess that you already know how to implement it.

    So, inside RunFinished method, write these lines:

        var destFolder = Directory.GetParent(path).Parent;
        System.IO.Directory.CreateDirectory(destFolder.FullName + "\\.nuget");
        ((Solution2) _dte.Solution).AddSolutionFolder(destFolder.FullName + "\\.nuget");
    

    For Solution2 class you have to reference EnvDTE80.dll. _dte must be set from RunStarted method.

    private DTE _dte;
    public void RunStarted(object automationObject, Dictionary replacementsDictionary, WizardRunKind runKind, object[] customParams)
    {
         _dte = (DTE)automationObject;
    }
    

提交回复
热议问题