Example #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);
        }
Example #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);
        }