From df568681f5c5c14d87ec8ce1b017673a19793982 Mon Sep 17 00:00:00 2001 From: Cj <161484149+CJ-SPT@users.noreply.github.com> Date: Wed, 19 Jun 2024 06:22:18 -0400 Subject: [PATCH] Some clean up --- RecodeItGUI/GUI/Main.Designer.cs | 2 +- RecodeItGUI/GUI/Main.cs | 3 +- .../CrossCompiler/ReCodeItCrossCompiler.cs | 28 +++---------------- .../Models/CrossCompilerProjectModel.cs | 21 +++++++++++++- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/RecodeItGUI/GUI/Main.Designer.cs b/RecodeItGUI/GUI/Main.Designer.cs index 2cafd2f..34c049a 100644 --- a/RecodeItGUI/GUI/Main.Designer.cs +++ b/RecodeItGUI/GUI/Main.Designer.cs @@ -1536,7 +1536,7 @@ partial class ReCodeItForm // CCVisualStudioProjDirText.Location = new Point(6, 105); CCVisualStudioProjDirText.Name = "CCVisualStudioProjDirText"; - CCVisualStudioProjDirText.PlaceholderText = "Visual studio solution directory"; + CCVisualStudioProjDirText.PlaceholderText = "Visual studio solution"; CCVisualStudioProjDirText.ReadOnly = true; CCVisualStudioProjDirText.Size = new Size(501, 31); CCVisualStudioProjDirText.TabIndex = 27; diff --git a/RecodeItGUI/GUI/Main.cs b/RecodeItGUI/GUI/Main.cs index 044205a..4ea9454 100644 --- a/RecodeItGUI/GUI/Main.cs +++ b/RecodeItGUI/GUI/Main.cs @@ -794,7 +794,8 @@ public partial class ReCodeItForm : Form private void CCVisualStudioProjDirButton_Click(object sender, EventArgs e) { - var result = GUIHelpers.OpenFolderDialog("Select your visual studio project directory"); + var result = GUIHelpers.OpenFileDialog("Select a Visual Studio solution file", + "Solution Files (*.sln)|*.sln|All Files (*.*)|*.*"); if (result != string.Empty) { diff --git a/RecodeItLib/CrossCompiler/ReCodeItCrossCompiler.cs b/RecodeItLib/CrossCompiler/ReCodeItCrossCompiler.cs index 0cfae27..1047a9a 100644 --- a/RecodeItLib/CrossCompiler/ReCodeItCrossCompiler.cs +++ b/RecodeItLib/CrossCompiler/ReCodeItCrossCompiler.cs @@ -103,38 +103,18 @@ public class ReCodeItCrossCompiler /// private void StartBuild() { - var path = Path.Combine( - DataProvider.ReCodeItProjectsPath, - ActiveProject.SolutionName); - - var csProjFile = Directory.GetFiles(path, "*.csproj", SearchOption.AllDirectories) - .ToList() - .FirstOrDefault(); - - if (csProjFile == null || csProjFile == string.Empty) - { - Logger.Log("No project files found in the solution directory or sub directories", ConsoleColor.Red); - return; - } - - var dirName = Path.GetDirectoryName(csProjFile); - - var solutionName = ActiveProject.SolutionName + ".sln"; - - var arguements = $"build {Path.Combine(path, solutionName)} " + + var arguements = $"build {ActiveProject.VisualStudioClonedSolutionPath} " + $"/p:Configuration=Debug " + $"/p:Platform=\"Any CPU\""; // clean the project first - ExecuteDotnetCommand("clean", path); + ExecuteDotnetCommand("clean", ActiveProject.VisualStudioClonedSolutionDirectory); // Restore packages - ExecuteDotnetCommand("restore", path); - - Logger.Log(path + ActiveProject.SolutionName + ".sln"); + ExecuteDotnetCommand("restore", ActiveProject.VisualStudioClonedSolutionDirectory); // Then build the project - ExecuteDotnetCommand(arguements, path); + ExecuteDotnetCommand(arguements, ActiveProject.VisualStudioClonedSolutionDirectory); } private static void ExecuteDotnetCommand(string arguments, string workingDirectory) diff --git a/RecodeItLib/Models/CrossCompilerProjectModel.cs b/RecodeItLib/Models/CrossCompilerProjectModel.cs index cd7be59..8574fa5 100644 --- a/RecodeItLib/Models/CrossCompilerProjectModel.cs +++ b/RecodeItLib/Models/CrossCompilerProjectModel.cs @@ -1,4 +1,6 @@ -namespace ReCodeIt.Models; +using ReCodeIt.Utils; + +namespace ReCodeIt.Models; public class CrossCompilerProjectModel { @@ -25,6 +27,23 @@ public class CrossCompilerProjectModel /// public string VisualStudioSolutionPath { get; set; } + /// + /// The path to the working directory vs project + /// + public string VisualStudioSolutionDirectoryPath => Path.GetDirectoryName(VisualStudioSolutionPath)!; + + /// + /// The path the the cloned solution + /// + public string VisualStudioClonedSolutionPath => Path.Combine( + DataProvider.ReCodeItProjectsPath, + SolutionName, + SolutionName + ".sln"); + + public string VisualStudioClonedSolutionDirectory => Path.Combine( + DataProvider.ReCodeItProjectsPath, + SolutionName); + /// /// This is where the final dll is built to ///