From ae8854a58d2b3224bfffac5e0f8f179a7a9ae889 Mon Sep 17 00:00:00 2001 From: Reuben Bond Date: Fri, 5 Apr 2024 12:02:45 -0700 Subject: [PATCH] Add support for git worktrees in tests --- tests/Aspire.Hosting.Tests/MSBuildTests.cs | 3 ++- tests/Shared/WorkloadTesting/BuildEnvironment.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/Aspire.Hosting.Tests/MSBuildTests.cs b/tests/Aspire.Hosting.Tests/MSBuildTests.cs index 8a4fa439fa..e20373ff1e 100644 --- a/tests/Aspire.Hosting.Tests/MSBuildTests.cs +++ b/tests/Aspire.Hosting.Tests/MSBuildTests.cs @@ -127,7 +127,8 @@ private static string GetRepoRoot() { string directory = AppContext.BaseDirectory; - while (directory != null && !Directory.Exists(Path.Combine(directory, ".git"))) + // To support git worktrees, check for either a directory or a file named ".git" + while (directory != null && !Directory.Exists(Path.Combine(directory, ".git")) && !File.Exists(Path.Combine(directory, ".git"))) { directory = Directory.GetParent(directory)!.FullName; } diff --git a/tests/Shared/WorkloadTesting/BuildEnvironment.cs b/tests/Shared/WorkloadTesting/BuildEnvironment.cs index c4f7b43f49..d7999a0c71 100644 --- a/tests/Shared/WorkloadTesting/BuildEnvironment.cs +++ b/tests/Shared/WorkloadTesting/BuildEnvironment.cs @@ -31,7 +31,8 @@ public BuildEnvironment(bool expectSdkWithWorkload = true, Action