VsTeXProject.VisualStudio.Project.ProjectNode.SetupProjectGlobalPropertiesThatAllProjectSystemsMustSet C# (CSharp) Method

SetupProjectGlobalPropertiesThatAllProjectSystemsMustSet() private method

Setup the global properties for project instance.
        private void SetupProjectGlobalPropertiesThatAllProjectSystemsMustSet()
        {
            string solutionDirectory = null;
            string solutionFile = null;
            string userOptionsFile = null;

            var solution = Site.GetService(typeof (SVsSolution)) as IVsSolution;
            if (solution != null)
            {
                // We do not want to throw. If we cannot set the solution related constants we set them to empty string.
                solution.GetSolutionInfo(out solutionDirectory, out solutionFile, out userOptionsFile);
            }

            if (solutionDirectory == null)
            {
                solutionDirectory = string.Empty;
            }

            if (solutionFile == null)
            {
                solutionFile = string.Empty;
            }

            var solutionFileName = solutionFile.Length == 0 ? string.Empty : Path.GetFileName(solutionFile);

            var solutionName = solutionFile.Length == 0 ? string.Empty : Path.GetFileNameWithoutExtension(solutionFile);

            var solutionExtension = string.Empty;
            if (solutionFile.Length > 0 && Path.HasExtension(solutionFile))
            {
                solutionExtension = Path.GetExtension(solutionFile);
            }

            buildProject.SetGlobalProperty(GlobalProperty.SolutionDir.ToString(), solutionDirectory);
            buildProject.SetGlobalProperty(GlobalProperty.SolutionPath.ToString(), solutionFile);
            buildProject.SetGlobalProperty(GlobalProperty.SolutionFileName.ToString(), solutionFileName);
            buildProject.SetGlobalProperty(GlobalProperty.SolutionName.ToString(), solutionName);
            buildProject.SetGlobalProperty(GlobalProperty.SolutionExt.ToString(), solutionExtension);

            // Other misc properties
            buildProject.SetGlobalProperty(GlobalProperty.BuildingInsideVisualStudio.ToString(), "true");
            buildProject.SetGlobalProperty(GlobalProperty.Configuration.ToString(), ProjectConfig.Debug);
            buildProject.SetGlobalProperty(GlobalProperty.Platform.ToString(), ProjectConfig.AnyCPU);

            // DevEnvDir property
            object installDirAsObject = null;

            var shell = Site.GetService(typeof (SVsShell)) as IVsShell;
            if (shell != null)
            {
                // We do not want to throw. If we cannot set the solution related constants we set them to empty string.
                shell.GetProperty((int) __VSSPROPID.VSSPROPID_InstallDirectory, out installDirAsObject);
            }

            var installDir = (string) installDirAsObject;

            if (string.IsNullOrEmpty(installDir))
            {
                installDir = string.Empty;
            }
            else
            {
                // Ensure that we have traimnling backslash as this is done for the langproj macros too.
                if (installDir[installDir.Length - 1] != Path.DirectorySeparatorChar)
                {
                    installDir += Path.DirectorySeparatorChar;
                }
            }

            buildProject.SetGlobalProperty(GlobalProperty.DevEnvDir.ToString(), installDir);
        }
ProjectNode