mirror of https://github.com/dotnet/tye.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.4 KiB
37 lines
1.4 KiB
// Licensed to the .NET Foundation under one or more agreements.
|
|
// The .NET Foundation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Text;
|
|
|
|
namespace E2ETest
|
|
{
|
|
public static class TestHelpers
|
|
{
|
|
// https://github.com/dotnet/aspnetcore/blob/5a0526dfd991419d5bce0d8ea525b50df2e37b04/src/Testing/src/TestPathUtilities.cs
|
|
// This can get into a bad pattern for having crazy paths in places. Eventually, especially if we use helix,
|
|
// we may want to avoid relying on sln position.
|
|
public static string GetSolutionRootDirectory(string solution)
|
|
{
|
|
var applicationBasePath = AppContext.BaseDirectory;
|
|
var directoryInfo = new DirectoryInfo(applicationBasePath);
|
|
|
|
do
|
|
{
|
|
var projectFileInfo = new FileInfo(Path.Combine(directoryInfo.FullName, $"{solution}.sln"));
|
|
if (projectFileInfo.Exists)
|
|
{
|
|
return projectFileInfo.DirectoryName;
|
|
}
|
|
|
|
directoryInfo = directoryInfo.Parent;
|
|
}
|
|
while (directoryInfo.Parent != null);
|
|
|
|
throw new Exception($"Solution file {solution}.sln could not be found in {applicationBasePath} or its parent directories.");
|
|
}
|
|
}
|
|
}
|
|
|