/// <summary>
        /// Deletes the TFS related files for a Solution and related Projects.
        /// </summary>
        /// <param name="solutionFilePath">The solution file path.</param>
        /// <returns>A status string listing which files were removed.</returns>
        /// <exception cref="System.IO.FileNotFoundException">File Not Found Exception</exception>
        public string DeleteTfsRelatedFilesForSolutionAndRelatedProjects(string solutionFilePath)
        {
            #region Preconditions
            if (!File.Exists(solutionFilePath)) { throw new FileNotFoundException(solutionFilePath); }
            #endregion

            string fullSolutionPath = Path.GetFullPath(solutionFilePath);

            string solutionPath = Path.GetDirectoryName(fullSolutionPath);
            string solutionFileNameWithoutExtension = Path.GetFileNameWithoutExtension(fullSolutionPath);

            string results = "Deleting Tfs Related Files for Solution: " + solutionFilePath + Environment.NewLine;
            results += "--------------------------------------------------------" + Environment.NewLine + Environment.NewLine;

            Environment.CurrentDirectory = solutionPath;

            results += DeleteTfsSolutionOrProjectFiles(solutionFileNameWithoutExtension, ".");

            Solution solution = new Solution(solutionFilePath);

            foreach (SolutionProject project in solution.Projects)
            {
                results += DeleteTfsSolutionOrProjectFiles(project.ProjectName, project.RelativePath);
            }

            return results + Environment.NewLine;
        }
        /// <summary>
        /// Removes the TFS project entries for all Project files in a Solution.
        /// </summary>
        /// <param name="solutionFilePath">The solution file path.</param>
        /// <returns>A status string listing which Project files were cleaned.</returns>
        /// <exception cref="System.IO.FileNotFoundException">File Not Found exception</exception>
        public string RemoveTfsProjectEntriesForAllProjectsInSolution(string solutionFilePath)
        {
            #region Preconditions
            if (!File.Exists(solutionFilePath)) { throw new FileNotFoundException(solutionFilePath); }
            #endregion

            string results = "Removing Tfs Related Project Entries for the Solution: " + solutionFilePath + Environment.NewLine;
            results += "--------------------------------------------------------" + Environment.NewLine + Environment.NewLine;

            string fullSolutionPath = Path.GetFullPath(solutionFilePath);

            string solutionPath = Path.GetDirectoryName(fullSolutionPath);
            string solutionFileNameWithoutExtension = Path.GetFileNameWithoutExtension(fullSolutionPath);

            Environment.CurrentDirectory = solutionPath;

            Solution solution = new Solution(fullSolutionPath);

            foreach (SolutionProject project in solution.Projects)
            {
                results += RemoveTfsRelatedEntriesForProjectFile(project.RelativePath);
            }

            return results + Environment.NewLine;
        }
コード例 #3
0
        private void ReferenceAnalyzerLoadSolution()
        {
            if (string.IsNullOrEmpty(ReferenceAnalyzerTextSolutionFile.Text))
            {
                MessageBox.Show("Please select a Solution file...");
                return;
            }

            string solutionFilePath = ReferenceAnalyzerTextSolutionFile.Text;

            #region Preconditions
            if (!File.Exists(solutionFilePath)) { throw new FileNotFoundException(solutionFilePath); }
            #endregion

            this.Cursor = Cursors.WaitCursor;
            statusStrip.BackColor = STATUS_BAR_ACTIVE_COLOR;

            string solutionFolderPath = Path.GetDirectoryName(solutionFilePath);

            Environment.CurrentDirectory = solutionFolderPath;

            Solution solution = new Solution(solutionFilePath);

            int projectCount = solution.Projects.Count;
            int index = 1;

            foreach (SolutionProject project in solution.Projects)
            {
                // reset the environment directory to the solution for loading the project
                Environment.CurrentDirectory = solutionFolderPath;

                UpdateStatus(string.Format("Processing Project {1} out of {2}: {0}", project.ProjectName, index, projectCount));
                index++;

                ProjectReferenceInfo projectReferenceInfo = ReferenceMethods.GetReferenceDetailsForProject(project);

                _referenceAnalysisProjectReferenceInfoList.Add(projectReferenceInfo);
            }

            // collect all unique references by type
            List<ReferenceDetails> allProjectReferences = _referenceAnalysisProjectReferenceInfoList.SelectMany(info => info.ProjectReferences).Distinct().OrderBy(info => info.AssemblyName).ToList();
            List<ReferenceDetails> allFrameworkReferences = _referenceAnalysisProjectReferenceInfoList.SelectMany(info => info.FrameworkReferences).Distinct().OrderBy(info => info.AssemblyName).ToList();
            List<ReferenceDetails> allLibraryReferences = _referenceAnalysisProjectReferenceInfoList.SelectMany(info => info.LibraryReferences).Distinct().OrderBy(info => info.AssemblyName).ToList();

            projectReferencesBindingSource.DataSource = allProjectReferences;
            frameworkReferencesBindingSource.DataSource = allFrameworkReferences;
            libraryReferencesBindingSource.DataSource = allLibraryReferences;

            UpdateStatus("Analyzing References...");
            string analysisResults = ReferenceMethods.AnalyzeReferences(_referenceAnalysisProjectReferenceInfoList);

            ReferenceAnalyzerTextAnalysisResults.Text = analysisResults;

            this.Cursor = Cursors.Default;
            statusStrip.BackColor = STATUS_BAR_INACTIVE_COLOR;
            UpdateStatus("Finished analyzing references.");
        }