Esempio n. 1
0
        public static FileInfo GetSolutionFilePath(string projectFilePath)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            FileInfo   solutionFile   = null;
            VsItemInfo startupProject = PackageHelper.GetStartupProject();

            if (startupProject != null)
            {
                string solutionFullPath = startupProject.GetSolutionFullPath();

                if (solutionFullPath != null)
                {
                    solutionFile = new FileInfo(solutionFullPath);
                }
            }

            if (solutionFile == null || !solutionFile.Exists)
            {
                var directory = new DirectoryInfo(projectFilePath);

                while (!TryGetSolutionFile(directory, out solutionFile))
                {
                    directory = directory.Parent;
                }
            }

            return(solutionFile);
        }
Esempio n. 2
0
        /// <summary>
        /// Returns the solution file (based on the startup project).
        /// </summary>
        /// <returns></returns>
        public FileInfo GetSolutionFileInfo()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (_solutionFile == null)
            {
                VsItemInfo startupProject = GetStartupProject();

                if (startupProject != null)
                {
                    string solutionFullPath = startupProject.GetSolutionFullPath();

                    if (solutionFullPath != null)
                    {
                        _solutionFile = new FileInfo(solutionFullPath);
                    }
                }
            }
            return(_solutionFile);
        }
Esempio n. 3
0
        /// <summary>
        /// Returns the startup project (based on the build manager).
        /// </summary>
        /// <returns></returns>
        public VsItemInfo GetStartupProject()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (_startupProject == null)
            {
                IVsSolutionBuildManager solutionBuildManager = GetVsSolutionBuildManager();

                if (solutionBuildManager != null)
                {
                    bool success = PackageHelper.Success(solutionBuildManager.get_StartupProject(out IVsHierarchy value));

                    if (success && value != null)
                    {
                        _startupProject = new VsItemInfo(value);
                    }
                }
            }
            return(_startupProject);
        }
Esempio n. 4
0
        public static VsItemInfo GetStartupProject()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            VsItemInfo startupProject = null;
            IVsSolutionBuildManager solutionBuildManager = GetVsSolutionBuildManager();

            if (solutionBuildManager != null)
            {
                IVsHierarchy value   = null;
                bool         success = Success(solutionBuildManager.get_StartupProject(out value));

                if (success && value != null)
                {
                    startupProject = new VsItemInfo(value);
                }
            }

            return(startupProject);
        }