예제 #1
0
        }//Constructor()

        public void CreateNewProject()
        {
            /* ------------------------------------------------------
             * Create Visual Studio instance and make VS window visible
             * ------------------------------------------------------ */
            Type t = System.Type.GetTypeFromProgID(ProgID);

            dte                    = (EnvDTE.DTE)System.Activator.CreateInstance(t);
            dte.SuppressUI         = false;
            dte.UserControl        = true; // true = leaves VS window open after code execution
            dte.MainWindow.Visible = true;

            /* ------------------------------------------------------
             * Create directories for new Visual Studio solution
             * ------------------------------------------------------ */
            //Helper.DeleteDirectory(BASEFOLDER);
            Directory.CreateDirectory(BASEFOLDER);
            Directory.CreateDirectory(BASEFOLDER);

            /* ------------------------------------------------------
             * Create and save new solution
             * ------------------------------------------------------ */
            sol = dte.Solution;
            sol.Create(BASEFOLDER, _solutionName + ".sln");
            sol.SaveAs(BASEFOLDER + "\\" + _solutionName);

            /* ------------------------------------------------------
             * Create new TwinCAT project, based on TwinCAT Project file (delivered with TwinCAT XAE)
             * ------------------------------------------------------ */
            pro = sol.AddFromTemplate(TcTemplatePath, BASEFOLDER + "\\" + _tcProjectName, _tcProjectName);
        }
예제 #2
0
        public void CreateTestSolution(string fullyQualifiedPath, string unqualifiedName)
        {
            EnvDTE.Solution soln = System.Activator.CreateInstance(Type.GetTypeFromProgID("VisualStudio.Solution")) as EnvDTE.Solution;
            soln.DTE.MainWindow.Visible = true;
            EnvDTE80.Solution2 soln2 = soln as EnvDTE80.Solution2;
            soln2.Create(fullyQualifiedPath, unqualifiedName);
            string csTemplatePath = soln2.GetProjectTemplate("ConsoleApplication.zip", "CSharp");

            soln.AddFromTemplate(csTemplatePath, fullyQualifiedPath, unqualifiedName, false);
            int x = soln.AddIns.Count;

            soln2.SaveAs(fullyQualifiedPath + unqualifiedName + ".sln");
        }