private void BuildSolutionOnlyWithoutOutput(string solutionPath, bool isFramework) { try { System.Diagnostics.Process process = new System.Diagnostics.Process(); System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; var msBuildLocation = _analyzerConfiguration.BuildSettings.MSBuildPath; if (string.IsNullOrEmpty(msBuildLocation)) { msBuildLocation = _msBuildDetector.GetFirstMatchingMsBuildFromPath(); } //Add quotes around solution name to make sure spaces don't cause the command to fail var escapedSolutionPath = "\"" + solutionPath + "\""; var arguments = new List <string>(_analyzerConfiguration.BuildSettings.BuildArguments); if (isFramework) { startInfo.FileName = msBuildLocation; arguments.Insert(0, escapedSolutionPath); startInfo.Arguments = string.Join(" ", arguments); } else { startInfo.FileName = "dotnet"; arguments.Insert(0, escapedSolutionPath); arguments.Insert(0, "build"); startInfo.Arguments = string.Join(" ", arguments); } process.StartInfo = startInfo; process.Start(); process.WaitForExit(); } catch (Exception ex) { Logger.LogError(ex, "Unable to build. Project type used is not supported"); throw; } }
public void TestVS2022() { string actualMsBuildPath = Path.Combine(testvs2022Path, Constants.vs2022MSBuildPath); string msbuildpath = msBuildDetector.GetFirstMatchingMsBuildFromPath(programFilesPath: Path.Combine(testvs2022Path, Constants.programFiles), programFilesX86Path: Path.Combine(testvs2022Path, Constants.programFilesx86)); Assert.AreEqual(actualMsBuildPath, msbuildpath); }