private static void BeginTestExecution(string solutionDir, string testFileDir) { ClearTempPath(); var type = GetLookupType(testFileDir); var solution = SolutionFile.Load(solutionDir); Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("\nDetermening files To compile"); Console.WriteLine("-------------------------------"); var buildFiles = BuildMonkey.Using(new NRefactorySourceExaminer(), solution, new SourceFromFileRepository()) .WhatFilesAreRequiredToBuild(type); CopyBuildFilesToTempDir(buildFiles); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("\nCompiling files:"); Console.WriteLine("-------------------------------"); var buildFilesCompiler = new BuildFilesCompiler(); var result = buildFilesCompiler.Compile(buildFiles); ProcessResult(result); }
/// <summary> /// Adds a project file and all its dependencies to a solution in the dependencies solution folder. /// </summary> public static void AddProjectReferenceDependencyAndAllDependenciesChecked(string solutionFilePath, string dependencyProjectFilePath) { var solutionFile = SolutionFile.Load(solutionFilePath); UtilitiesExtra.AddProjectReferenceDependencyAndAllDependenciesChecked(solutionFile, solutionFilePath, dependencyProjectFilePath); solutionFile.Save(solutionFilePath); }
public void ShouldRetrieveAllProjectsFromSolutionFile() { const string projectSampleLocation = @"TestData/WellItCouldWork.sln"; var solution = SolutionFile.Load(projectSampleLocation); Assert.That(solution.ContainsAProjectCalled("WellItCouldWork.csproj")); Assert.That(solution.Name, Is.EqualTo("WellItCouldWork.sln")); Assert.That(solution.Path, Is.EqualTo(Environment.CurrentDirectory + "\\TestData")); }
private void button2_Click(object sender, EventArgs e) { SolutionFile solutionFile = new SolutionFile(textBox1.Text); treeView1.Nodes.Clear(); listView1.Items.Clear(); listView1.Columns.Clear(); if (!solutionFile.Load()) { return; } Solution solution = solutionFile.Solution; TreeNode root = treeView1.Nodes.Add(solution.Name); root.Tag = solution; TreeNode platformsNode = root.Nodes.Add("Platforms"); foreach (Platform platform in solution.Platforms) { TreeNode newNode = platformsNode.Nodes.Add(platform.Name); newNode.Tag = platform; } TreeNode configsNode = root.Nodes.Add("Configurations"); foreach (Configuration configuration in solution.Configurations) { TreeNode newNode = configsNode.Nodes.Add(configuration.Name); newNode.Tag = configuration; } TreeNode prjsNode = root.Nodes.Add("Projects"); foreach (Project project in solution.Projects) { TreeNode prjNode = prjsNode.Nodes.Add(project.Name); prjNode.Tag = project; TreeNode platforms = prjNode.Nodes.Add("Plarforms"); foreach (Platform platform in project.Platforms) { TreeNode newNode = platforms.Nodes.Add(platform.Name); newNode.Tag = platform; } TreeNode configs = prjNode.Nodes.Add("Configurations"); foreach (Configuration configuration in project.Configurations) { TreeNode newNode = configs.Nodes.Add(configuration.Name); newNode.Tag = configuration; } } }
public void RemoveExtraneousDependencies(string solutionFilePath, TextWriter writer, bool dryRun = true) { var solutionFile = SolutionFile.Load(solutionFilePath); var projectFilePaths = solutionFile.GetNonDependencyProjectFilePaths(solutionFilePath).ToArray(); // Write out input information. writer.WriteLine($"Target solution file path:\n{solutionFilePath}"); foreach (var projectFilePath in projectFilePaths.OrderBy(x => x)) { writer.WriteLine($"Target project file path:\n{projectFilePath}"); } // Get all project reference dependency file paths. var allProjectReferenceDependencyFilePaths = ProjectFileUtilities.GetProjectReferenceDependencyFilePathsRecursive(projectFilePaths); // Remove any of the target project paths. var projectReferenceDependencyFilePaths = allProjectReferenceDependencyFilePaths.Except(projectFilePaths).ToList(); // Evaluate now. // Write out all project reference dependency file paths. writer.WriteLine($"\nTarget project dependencies (count: {projectReferenceDependencyFilePaths.Count()}):"); foreach (var projectReferenceDependencyFilePath in projectReferenceDependencyFilePaths.SortAlphabetically()) { writer.WriteLine(projectReferenceDependencyFilePath); } // Get all projects included in the solution. var solutionProjectReferenceDependencyFilePaths = solutionFile.GetProjectReferenceDependencyFilePaths(solutionFilePath).ToList(); // Evaluate now since enumerable will be changed later. // Write out all projects included in the solution. writer.WriteLine($"\nSolution projects: (count: {solutionProjectReferenceDependencyFilePaths.Count()}):"); foreach (var solutionProjectReferenceDependencyFilePath in solutionProjectReferenceDependencyFilePaths.SortAlphabetically()) { writer.WriteLine(solutionProjectReferenceDependencyFilePath); } // Get all extraneous dependency project references. var extraneousSolutionProjectReferenceDependencyFilePaths = solutionProjectReferenceDependencyFilePaths.Except(projectReferenceDependencyFilePaths); // List all extraneoius dependency project references. writer.WriteLine($"\nExtraneous solution projects (count: {extraneousSolutionProjectReferenceDependencyFilePaths.Count()}):"); foreach (var extraneousSolutionProjectReferenceDependencyFilePath in extraneousSolutionProjectReferenceDependencyFilePaths.SortAlphabetically()) { writer.WriteLine(extraneousSolutionProjectReferenceDependencyFilePath); } writer.WriteLine(); // Remove extraneous dependencies. if (dryRun) { writer.WriteLine("Dry run: no actions taken."); } else { writer.WriteLine("Removing extraneous dependencies..."); foreach (var extraneousDependency in extraneousSolutionProjectReferenceDependencyFilePaths.SortAlphabetically()) { solutionFile.RemoveProjectReference(solutionFilePath, extraneousDependency); writer.WriteLine($"Removed '{extraneousDependency}'."); } solutionFile.Save(solutionFilePath); } }
public void AddMissingProjectDependencies(string solutionFilePath, TextWriter writer, bool dryRun = true) { // Write out input information. writer.WriteLine($"Target solution file path:\n{solutionFilePath}"); // Get all projects in the solution. var solutionFile = SolutionFile.Load(solutionFilePath); var solutionProjectReferenceFilePaths = solutionFile.GetProjectReferenceFilePaths(solutionFilePath).ToList(); // Evaluate now. // Write out all solution projects. writer.WriteLine($"\nSolution projects: (count: {solutionProjectReferenceFilePaths.Count()}):"); foreach (var solutionProjectReferenceFilePath in solutionProjectReferenceFilePaths.SortAlphabetically()) { writer.WriteLine(solutionProjectReferenceFilePath); } // Get all dependencies of all projects, recursively. var projectReferenceDependencyFilePaths = ProjectFileUtilities.GetProjectReferenceDependencyFilePathsRecursive(solutionProjectReferenceFilePaths); // Write out all project reference dependency file paths. writer.WriteLine($"\nSolution project dependencies (count: {projectReferenceDependencyFilePaths.Count()}):"); foreach (var projectReferenceDependencyFilePath in projectReferenceDependencyFilePaths.SortAlphabetically()) { writer.WriteLine(projectReferenceDependencyFilePath); } // Get all project reference dependencies that must be added to the solution. var missingProjectReferenceDependencyFilePaths = projectReferenceDependencyFilePaths.Except(solutionProjectReferenceFilePaths); // Write out all missing project reference dependency file paths. writer.WriteLine($"\nMissing projects: (count: {missingProjectReferenceDependencyFilePaths.Count()}):"); foreach (var missingProjectReferenceDependencyFilePath in missingProjectReferenceDependencyFilePaths.SortAlphabetically()) { writer.WriteLine(missingProjectReferenceDependencyFilePath); } writer.WriteLine(); // Add missing dependencies. if (dryRun) { writer.WriteLine("Dry run: no actions taken."); } else { writer.WriteLine("Adding missing dependencies..."); foreach (var missingProjectReferenceDependencyFilePath in missingProjectReferenceDependencyFilePaths) { solutionFile.AddProjectReferenceDependencyChecked(solutionFilePath, missingProjectReferenceDependencyFilePath); writer.WriteLine($"Added '{missingProjectReferenceDependencyFilePath}'."); } solutionFile.Save(solutionFilePath); } }