3ce8eaefaa
* master: Adding a Wpf and Winforms templates registry key (#218) Update coresetup to preview-27218-01 (#216) Update WindowsDesktop Framework (#215) Update coresetup to preview-27217-02 (#214) Update coresetup to preview-27217-01 Update coresetup to preview-27216-02 (#211) make GivenDotnetUsesDotnetTools test optional based on AspNetCore availability (#207) Update DependencyVersions.props Include the WindowsDesktop sharedframework in install 'Finish' page. (#208) Update readme; core-sdk:master (#209) Update WindowsDesktop Update toolset Update coresetup to preview-27214-02 change debug to Debug to match managed part add entry for freebsd to badge processing update stage0 sdk to 3.0 preview Update coresetup to preview-27206-02 (#202) initial support for freebsd
88 lines
3.1 KiB
C#
88 lines
3.1 KiB
C#
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using System.Xml.Linq;
|
|
using FluentAssertions;
|
|
using Microsoft.DotNet.PlatformAbstractions;
|
|
|
|
namespace Microsoft.DotNet.Tools.Test.Utilities
|
|
{
|
|
public class RepoDirectoriesProvider
|
|
{
|
|
public readonly static string RepoRoot;
|
|
|
|
public readonly static string TestWorkingFolder;
|
|
public readonly static string DotnetUnderTest;
|
|
public readonly static string DotnetRidUnderTest;
|
|
public readonly static string Stage2AspNetCore;
|
|
|
|
static RepoDirectoriesProvider()
|
|
{
|
|
|
|
#if NET451
|
|
string directory = AppDomain.CurrentDomain.BaseDirectory;
|
|
#else
|
|
string directory = AppContext.BaseDirectory;
|
|
#endif
|
|
|
|
while (directory != null)
|
|
{
|
|
var gitDirOrFile = Path.Combine(directory, ".git");
|
|
if (Directory.Exists(gitDirOrFile) || File.Exists(gitDirOrFile))
|
|
{
|
|
break;
|
|
}
|
|
directory = Directory.GetParent(directory)?.FullName;
|
|
}
|
|
|
|
RepoRoot = directory;
|
|
|
|
TestWorkingFolder = Environment.GetEnvironmentVariable("CORESDK_TEST_FOLDER");
|
|
if (string.IsNullOrEmpty(TestWorkingFolder))
|
|
{
|
|
TestWorkingFolder = Path.Combine(AppContext.BaseDirectory, "Tests");
|
|
}
|
|
|
|
DotnetUnderTest = Environment.GetEnvironmentVariable("DOTNET_UNDER_TEST");
|
|
string dotnetExtension = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : "";
|
|
if (string.IsNullOrEmpty(DotnetUnderTest))
|
|
{
|
|
if (RepoRoot == null)
|
|
{
|
|
DotnetUnderTest = "dotnet" + dotnetExtension;
|
|
}
|
|
else
|
|
{
|
|
string configuration = new DirectoryInfo(AppContext.BaseDirectory).Parent.Name;
|
|
DotnetUnderTest = Path.Combine(RepoRoot, "artifacts", "bin", "redist", configuration, "dotnet", "dotnet" + dotnetExtension);
|
|
}
|
|
}
|
|
|
|
string AspNetCoreDir = Path.Combine(
|
|
Path.GetDirectoryName(DotnetUnderTest),
|
|
"shared",
|
|
"Microsoft.AspNetCore.App");
|
|
|
|
if (Directory.Exists(AspNetCoreDir))
|
|
{
|
|
Stage2AspNetCore =
|
|
Directory.EnumerateDirectories(AspNetCoreDir).First();
|
|
}
|
|
|
|
// TODO: Resolve dotnet folder even if DotnetUnderTest doesn't have full path
|
|
var sdkFolders = Directory.GetDirectories(Path.Combine(Path.GetDirectoryName(DotnetUnderTest), "sdk"));
|
|
sdkFolders.Length.Should().Be(1, "Only one SDK folder is expected in the layout");
|
|
|
|
var sdkFolder = sdkFolders.Single();
|
|
var versionFile = Path.Combine(sdkFolder, ".version");
|
|
|
|
var lines = File.ReadAllLines(versionFile);
|
|
DotnetRidUnderTest = lines[2].Trim();
|
|
}
|
|
|
|
}
|
|
}
|