File: tests\Aspire.Hosting.Tests\Utils\MSBuildUtils.cs
Web Access
Project: src\tests\Aspire.Hosting.Testing.Tests\Aspire.Hosting.Testing.Tests.csproj (Aspire.Hosting.Testing.Tests)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
 
namespace Aspire.Hosting.Tests;
 
public class MSBuildUtils
{
    public static string GetRepoRoot()
    {
        string directory = AppContext.BaseDirectory;
 
        // 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;
        }
 
        return directory!;
    }
}