Skip to content

Commit

Permalink
Add test coverage for amd64 MSBuild.exe (dfederm#69)
Browse files Browse the repository at this point in the history
* Adapt

* Update E2ETests.cs

* Always use amd64 flavor of MSBuild.exe

* Fix bad merge

---------

Co-authored-by: David Federman <[email protected]>
  • Loading branch information
stan-sz and dfederm authored Apr 1, 2024
1 parent bd20381 commit c0b50a6
Showing 1 changed file with 2 additions and 38 deletions.
40 changes: 2 additions & 38 deletions src/Tests/E2ETests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ private static (string ExePath, string Verb) GetMsBuildExeAndVerb()

if (!string.IsNullOrEmpty(vsInstallDir))
{
string msbuildExePath = Path.Combine(vsInstallDir, @"MSBuild\Current\Bin\MSBuild.exe");
string msbuildExePath = Path.Combine(vsInstallDir, @"MSBuild\Current\Bin\amd64\MSBuild.exe");
if (!File.Exists(msbuildExePath))
{
throw new InvalidOperationException($"Could not find MSBuild.exe path for unit tests: {msbuildExePath}");
Expand All @@ -500,43 +500,7 @@ private static (string ExePath, string Verb) GetMsBuildExeAndVerb()
return ("dotnet", "build");
}

// From: https://docs.microsoft.com/en-us/dotnet/standard/io/how-to-copy-directories
private static void DirectoryCopy(string sourceDirName, string destDirName)
{
// Get the subdirectories for the specified directory.
var dir = new DirectoryInfo(sourceDirName);

if (!dir.Exists)
{
throw new DirectoryNotFoundException($"Source directory does not exist or could not be found: {sourceDirName}");
}

var subdirs = dir.GetDirectories();

// If the destination directory doesn't exist, create it.
if (!Directory.Exists(destDirName))
{
Directory.CreateDirectory(destDirName);
}

// Get the files in the directory and copy them to the new location.
var files = dir.GetFiles();
foreach (var file in files)
{
var destFile = Path.Combine(destDirName, file.Name);
file.CopyTo(destFile, false);
}

// Copy subdirectories and their contents to new location.
foreach (var subdir in subdirs)
{
var destSubdirName = Path.Combine(destDirName, subdir.Name);
DirectoryCopy(subdir.FullName, destSubdirName);
}
}

private async Task RunMSBuildAsync(string projectFile, Warning[] expectedWarnings, string[]? expectedConsoleOutputs = null, bool expectUnusedMsvcLibrariesLog = false,
bool enableReferenceTrimmerDiagnostics = false)
private async Task RunMSBuildAsync(string projectFile, Warning[] expectedWarnings, string[]? expectedConsoleOutputs = null, bool expectUnusedMsvcLibrariesLog = false, bool enableReferenceTrimmerDiagnostics = false)
{
var testDataSourcePath = Path.GetFullPath(Path.Combine("TestData", TestContext?.TestName ?? string.Empty));

Expand Down

0 comments on commit c0b50a6

Please sign in to comment.