aspnetcore/test/Microsoft.AspNetCore.WebSoc.../Helpers.cs

29 lines
900 B
C#

using System;
using System.IO;
namespace Microsoft.AspNetCore.WebSockets.ConformanceTest
{
public class Helpers
{
public static string GetApplicationPath(string projectName)
{
var applicationBasePath = AppContext.BaseDirectory;
var directoryInfo = new DirectoryInfo(applicationBasePath);
do
{
var solutionFileInfo = new FileInfo(Path.Combine(directoryInfo.FullName, "WebSockets.sln"));
if (solutionFileInfo.Exists)
{
return Path.GetFullPath(Path.Combine(directoryInfo.FullName, "test", projectName));
}
directoryInfo = directoryInfo.Parent;
}
while (directoryInfo.Parent != null);
throw new Exception($"Solution root could not be found using {applicationBasePath}");
}
}
}