/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Compilers/Test/Core/DotNetCoreSdk.cs
45 строк
1 KB
Joey Robichaud
Move DotNetCoreSdk to shared test utilities
31 мар 2021, 21:37
31 мар 2021, 21:37
563bd03
Код
Авторство
О чём код?
// 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.IO; using System.Linq; namespace Roslyn.Test.Utilities { public static class DotNetCoreSdk { public sealed class IsAvailable : ExecutionCondition { public override bool ShouldSkip => ExePath == null; public override string SkipReason => "The location of dotnet SDK can't be determined (DOTNET_INSTALL_DIR environment variable is unset)"; } public static string? ExePath { get; } static DotNetCoreSdk() { var dotNetExeName = "dotnet" + (Path.DirectorySeparatorChar == '/' ? "" : ".exe"); bool DotNetExeExists(string? directory) => directory != null && File.Exists(Path.Combine(directory, dotNetExeName)); var dotNetInstallDir = Environment.GetEnvironmentVariable("DOTNET_INSTALL_DIR"); if (!DotNetExeExists(dotNetInstallDir)) { dotNetInstallDir = Environment.GetEnvironmentVariable("PATH")! .Split(Path.PathSeparator) .FirstOrDefault(DotNetExeExists); } if (dotNetInstallDir != null) { ExePath = Path.Combine(dotNetInstallDir, dotNetExeName); } } } }