/// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public bool RunSolution(bool debug)
        {
            try{
                //EnvDTE80.Events2 a;
                //a.DebuggerEvents.OnEnterRunMode

                EnvDTE80.Solution2      s = this.Application.Solution as EnvDTE80.Solution2;
                EnvDTE80.SolutionBuild2 b = this.Application.Solution.SolutionBuild as EnvDTE80.SolutionBuild2;
                if (debug)
                {
                    b.Debug();
                    Wait(5);
                    while (this.Application.Debugger.CurrentMode == EnvDTE.dbgDebugMode.dbgRunMode)
                    {
                        Wait(1);
                    }
                }
                else
                {
                    b.Run();
                }
                return(true);
            }
            catch (System.Exception ex) {
                System.Windows.Forms.MessageBox.Show(ex.Message);
                return(false);
            }
        }
Exemplo n.º 2
0
        public void CreateTestProject(string fullyQualifiedSolutionFileName, string projectName, TestProjectType testProjectType)
        {
            #region Argument Validation
            if (String.IsNullOrEmpty(fullyQualifiedSolutionFileName) || String.IsNullOrEmpty(fullyQualifiedSolutionFileName.Trim()))
            {
                throw new ArgumentNullException("fullyQualifiedSolutionFileName", "The solution file location is required.");
            }

            if (String.IsNullOrEmpty(projectName) || String.IsNullOrEmpty(projectName.Trim()))
            {
                throw new ArgumentNullException("projectName", "The project name is required.");
            }

            if (!System.IO.File.Exists(fullyQualifiedSolutionFileName))
            {
                throw new ArgumentException(String.Format("The file {0} specified does not exist.", fullyQualifiedSolutionFileName));
            }

            //if (testProjectType == null) testProjectType = TestProjectType.Unit;
            #endregion

            System.Type vsType = System.Type.GetTypeFromProgID("VisualStudio.DTE.10.0");
            Object      vs     = System.Activator.CreateInstance(vsType, true);

            EnvDTE80.DTE2 dte8Obj = (EnvDTE80.DTE2)vs;

            EnvDTE80.Solution2 vhaSolution = (EnvDTE80.Solution2)dte8Obj.Solution;
            //EnvDTE100.Solution4 vhaSolution = (EnvDTE100.Solution4)dte8Obj.Solution
            vhaSolution.Open(fullyQualifiedSolutionFileName);

            //TODO: Externalize company name
            string             cmpnyName            = "MCAF";
            string             testProjectName      = String.Format("{0}.{1}.{2}{3}", cmpnyName, projectName, testProjectType.ToString(), "Test");
            string             testTemplateLocation = vhaSolution.GetProjectTemplate("TestProject.zip", "CSharp");
            System.IO.FileInfo rootSolutionFolder   = new System.IO.FileInfo(fullyQualifiedSolutionFileName);

            //TODO: Externalize test directory name
            string testDirName = String.Format("{0}\\{1}\\{2}\\{3}", rootSolutionFolder.DirectoryName, "test", testProjectType.ToString(), testProjectName);

            if (!System.IO.Directory.Exists(testDirName))
            {
                //may throw an exception if the dir can't be created...
                System.IO.Directory.CreateDirectory(testDirName);
            }

            string csTemplatePath = vhaSolution.GetProjectTemplate("ConsoleApplication.zip", "CSharp");

            vhaSolution.AddFromTemplate(csTemplatePath, testDirName, testProjectName + ".proj", false);

            //EnvDTE.Project vhaTestProj = vhaSolution.AddFromTemplate(testTemplateLocation, testDirName, testProjectName + ".proj", false);
            //vhaTestProj.Save(String.Format("{0}\\{1}.proj", testDirName, testProjectName));
            vhaSolution.SaveAs(fullyQualifiedSolutionFileName);
        }
Exemplo n.º 3
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");
        }
Exemplo n.º 4
0
        public void OpenSolution(string path, bool saveExistingSolutionIfExists = false)
        {
            var dte = GetDTE();

            if (dte.Solution.IsOpen)
            {
                CloseSolution(saveExistingSolutionIfExists);
            }

            dte.Solution.Open(path);

            _solution = (EnvDTE80.Solution2)dte.Solution;
            _fileName = path;
        }
Exemplo n.º 5
0
        Project FindDockerFolderProject(EnvDTE80.Solution2 s)
        {
            foreach (Project p in s.Projects)
            {
                if (p.Globals.VariableExists["docker-app-solution-folder"])
                {
                    return(p);
                }
            }
            var proj = s.AddSolutionFolder("Docker");

            proj.Globals["docker-app-solution-folder"] = true;
            proj.Globals.VariablePersists["docker-app-solution-folder"] = true;
            return(proj);
        }
Exemplo n.º 6
0
        static public SolutionBuild2 GetSolutionBuild2(DTE dte)
        {
            DTE2 dte2 = SolutionUtility.GetDTE2(dte);

            if (dte2 == null)
            {
                return(null);
            }

            EnvDTE80.Solution2 solution = (EnvDTE80.Solution2)dte2.Solution;
            if (solution == null)
            {
                return(null);
            }

            return((EnvDTE80.SolutionBuild2)solution.SolutionBuild);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Creates and loads a new solution in the host process, optionally saving the existing solution if one exists.
        /// </summary>
        public void CreateSolution(string solutionName, bool saveExistingSolutionIfExists = false)
        {
            var dte = GetDTE();

            if (dte.Solution.IsOpen)
            {
                CloseSolution(saveExistingSolutionIfExists);
            }

            var solutionPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            IntegrationHelper.DeleteDirectoryRecursively(solutionPath);

            dte.Solution.Create(solutionPath, solutionName);

            _solution = (EnvDTE80.Solution2)dte.Solution;
            _fileName = Path.Combine(solutionPath, $"{solutionName}.sln");
        }
Exemplo n.º 8
0
        /// <summary>
        /// Creates and loads a new solution in the host process, optionally saving the existing solution if one exists.
        /// </summary>
        public void CreateSolution(string solutionName, bool saveExistingSolutionIfExists = false)
        {
            var dte = GetDTE();

            if (dte.Solution.IsOpen)
            {
                CloseSolution(saveExistingSolutionIfExists);
            }

            var solutionPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
            IntegrationHelper.DeleteDirectoryRecursively(solutionPath);

            dte.Solution.Create(solutionPath, solutionName);

            _solution = (EnvDTE80.Solution2)dte.Solution;
            _fileName = Path.Combine(solutionPath, $"{solutionName}.sln");
        }
Exemplo n.º 9
0
        public void OpenSolution(string path, bool saveExistingSolutionIfExists = false)
        {
            var dte = GetDTE();

            if (dte.Solution.IsOpen)
            {
                CloseSolution(saveExistingSolutionIfExists);
            }

            dte.Solution.Open(path);

            _solution = (EnvDTE80.Solution2)dte.Solution;
            _fileName = path;
        }