mirror of
https://github.com/BepInEx/dotnet-runtime.git
synced 2026-11-23 15:55:04 -10:00
Multilevel lookup includes a custom SDK installation directory (dotnet/core-setup#4857)
Multilevel lookup includes a custom SDK installation directory * Avoid duplicate global dirs. * Define: 'RRF_SUBKEY_WOW6432KEY' if not defined. * Adding tests for MultiLevel Lookup and the SDK Self-Registred dirtectory. * Disable self-registered SDK installation directory for win_arm64; win-arm * Adding true multi-level SDK and Runtime look-up; moving non-multi-level SDK version resoution tests. * Multi-level lookup tests are for Windows only; separating and duplicating SharedFX multi-level and non-multi-level lookup tests. Commit migrated from https://github.com/dotnet/core-setup/commit/2f528e5f158aa41789f7967cf8e8b868a8173d95
This commit is contained in:
1 parent
f037b09c10
commit
71753658e6
7 files changed
+2306
-1023
No files matched your search
@@ -12,6 +12,9 @@
|
||||
#include <ShlObj.h>
|
||||
#include <ctime>
|
||||
|
||||
#if !defined(RRF_SUBKEY_WOW6432KEY)
|
||||
#define RRF_SUBKEY_WOW6432KEY 0x00020000
|
||||
#endif
|
||||
|
||||
bool GetModuleFileNameWrapper(HMODULE hModule, pal::string_t* recv)
|
||||
{
|
||||
@@ -197,18 +200,6 @@ bool pal::get_default_servicing_directory(string_t* recv)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pal::get_global_dotnet_dirs(std::vector<pal::string_t>* dirs)
|
||||
{
|
||||
pal::string_t dir;
|
||||
if (!get_default_installation_dir(&dir))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
dirs->push_back(dir);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pal::get_default_installation_dir(pal::string_t* recv)
|
||||
{
|
||||
pal::char_t* program_files_dir;
|
||||
@@ -227,9 +218,77 @@ bool pal::get_default_installation_dir(pal::string_t* recv)
|
||||
}
|
||||
|
||||
append_path(recv, _X("dotnet"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool get_sdk_self_registered_dir(pal::string_t* recv)
|
||||
{
|
||||
#if !defined(_TARGET_AMD64_) && !defined(_TARGET_X86_)
|
||||
// Self-registered SDK installation directory is only supported for x64 and x86 architectures.
|
||||
return false;
|
||||
#else
|
||||
recv->clear();
|
||||
|
||||
// ***Used only for testing***
|
||||
pal::string_t environmentOverride;
|
||||
if (pal::getenv(_X("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR"), &environmentOverride))
|
||||
{
|
||||
recv->assign(environmentOverride);
|
||||
return true;
|
||||
}
|
||||
// ***************************
|
||||
|
||||
DWORD size = 0;
|
||||
const HKEY hkey = HKEY_LOCAL_MACHINE;
|
||||
// The registry search occurs in the 32-bit registry in all cases.
|
||||
const DWORD flags = RRF_RT_REG_SZ | RRF_SUBKEY_WOW6432KEY;
|
||||
pal::string_t sub_key = pal::string_t(_X("SOFTWARE\\dotnet\\Setup\\InstalledVersions\\")) + get_arch() + pal::string_t(_X("\\sdk"));
|
||||
pal::char_t* value = _X("InstallLocation");
|
||||
|
||||
// Determine the size of the buffer
|
||||
LONG result = ::RegGetValueW(hkey, sub_key.c_str(), value, flags, nullptr, nullptr, &size);
|
||||
if (result != ERROR_SUCCESS || size == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the key's value
|
||||
std::vector<pal::char_t> buffer(size/sizeof(pal::char_t));
|
||||
result = ::RegGetValueW(hkey, sub_key.c_str(), value, flags, nullptr, &buffer[0], &size);
|
||||
if (result != ERROR_SUCCESS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
recv->assign(buffer.data());
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool pal::get_global_dotnet_dirs(std::vector<pal::string_t>* dirs)
|
||||
{
|
||||
pal::string_t default_dir;
|
||||
pal::string_t custom_dir;
|
||||
bool dir_found = false;
|
||||
if (get_sdk_self_registered_dir(&custom_dir))
|
||||
{
|
||||
dirs->push_back(custom_dir);
|
||||
dir_found = true;
|
||||
}
|
||||
if (get_default_installation_dir(&default_dir))
|
||||
{
|
||||
// Avoid duplicate global dirs.
|
||||
if (!dir_found || !are_paths_equal_with_normalized_casing(custom_dir, default_dir))
|
||||
{
|
||||
dirs->push_back(default_dir);
|
||||
dir_found = true;
|
||||
}
|
||||
}
|
||||
return dir_found;
|
||||
}
|
||||
|
||||
// To determine the OS version, we are going to use RtlGetVersion API
|
||||
// since GetVersion call can be shimmed on Win8.1+.
|
||||
typedef NTSTATUS (WINAPI *pFuncRtlGetVersion)(RTL_OSVERSIONINFOW *);
|
||||
|
||||
@@ -34,14 +34,17 @@ namespace HostApiInvokerApp
|
||||
// Enable tracing so that test assertion failures are easier to diagnose.
|
||||
Environment.SetEnvironmentVariable("COREHOST_TRACE", "1");
|
||||
|
||||
// If requested, test multilevel lookup using fake ProgramFiles location.
|
||||
// If requested, test multilevel lookup using fake Global SDK directories:
|
||||
// 1. using a fake ProgramFiles location
|
||||
// 2. using a fake SDK Self-Registered location
|
||||
// Note that this has to be set here and not in the calling test process because
|
||||
// %ProgramFiles% gets reset on process creation.
|
||||
string testMultilevelLookupProgramFiles = Environment.GetEnvironmentVariable(
|
||||
"TEST_MULTILEVEL_LOOKUP_PROGRAM_FILES");
|
||||
string testMultilevelLookupProgramFiles = Environment.GetEnvironmentVariable("TEST_MULTILEVEL_LOOKUP_PROGRAM_FILES");
|
||||
string testMultilevelLookupSelfRegistered = Environment.GetEnvironmentVariable("TEST_MULTILEVEL_LOOKUP_SELF_REGISTERED");
|
||||
|
||||
if (testMultilevelLookupProgramFiles != null)
|
||||
if (testMultilevelLookupProgramFiles != null && testMultilevelLookupSelfRegistered != null)
|
||||
{
|
||||
Environment.SetEnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", testMultilevelLookupSelfRegistered);
|
||||
Environment.SetEnvironmentVariable("ProgramFiles", testMultilevelLookupProgramFiles);
|
||||
Environment.SetEnvironmentVariable("ProgramFiles(x86)", testMultilevelLookupProgramFiles);
|
||||
Environment.SetEnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1");
|
||||
|
||||
+239
-179
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.DotNet.InternalAbstractions;
|
||||
using Xunit;
|
||||
|
||||
@@ -22,13 +23,16 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.MultilevelSDKLookup
|
||||
|
||||
private string _currentWorkingDir;
|
||||
private string _userDir;
|
||||
private string _executableDir;
|
||||
private string _exeDir;
|
||||
private string _regDir;
|
||||
private string _cwdSdkBaseDir;
|
||||
private string _userSdkBaseDir;
|
||||
private string _exeSdkBaseDir;
|
||||
private string _regSdkBaseDir;
|
||||
private string _cwdSelectedMessage;
|
||||
private string _userSelectedMessage;
|
||||
private string _exeSelectedMessage;
|
||||
private string _regSelectedMessage;
|
||||
private string _sdkDir;
|
||||
private string _multilevelDir;
|
||||
|
||||
@@ -51,23 +55,26 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.MultilevelSDKLookup
|
||||
|
||||
_currentWorkingDir = Path.Combine(_multilevelDir, "cwd");
|
||||
_userDir = Path.Combine(_multilevelDir, "user");
|
||||
_executableDir = Path.Combine(_multilevelDir, "exe");
|
||||
_exeDir = Path.Combine(_multilevelDir, "exe");
|
||||
_regDir = Path.Combine(_multilevelDir, "reg");
|
||||
|
||||
// It's necessary to copy the entire publish folder to the exe dir because
|
||||
// we'll need to build from it. The CopyDirectory method automatically creates the dest dir
|
||||
SharedFramework.CopyDirectory(builtDotnet, _executableDir);
|
||||
SharedFramework.CopyDirectory(builtDotnet, _exeDir);
|
||||
|
||||
RepoDirectories = new RepoDirectoriesProvider(builtDotnet: _executableDir);
|
||||
RepoDirectories = new RepoDirectoriesProvider(builtDotnet: _exeDir);
|
||||
|
||||
// SdkBaseDirs contain all available version folders
|
||||
_cwdSdkBaseDir = Path.Combine(_currentWorkingDir, "sdk");
|
||||
_userSdkBaseDir = Path.Combine(_userDir, ".dotnet", RepoDirectories.BuildArchitecture, "sdk");
|
||||
_exeSdkBaseDir = Path.Combine(_executableDir, "sdk");
|
||||
_exeSdkBaseDir = Path.Combine(_exeDir, "sdk");
|
||||
_regSdkBaseDir = Path.Combine(_regDir, "sdk");
|
||||
|
||||
// Create directories
|
||||
Directory.CreateDirectory(_cwdSdkBaseDir);
|
||||
Directory.CreateDirectory(_userSdkBaseDir);
|
||||
Directory.CreateDirectory(_exeSdkBaseDir);
|
||||
Directory.CreateDirectory(_regSdkBaseDir);
|
||||
|
||||
// Restore and build PortableApp from exe dir
|
||||
PreviouslyBuiltAndRestoredPortableTestProjectFixture = new TestProjectFixture("PortableApp", RepoDirectories)
|
||||
@@ -77,7 +84,7 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.MultilevelSDKLookup
|
||||
|
||||
// Set a dummy framework version (9999.0.0) in the exe sharedFx location. We will
|
||||
// always pick the framework from this to avoid interference with the sharedFxLookup
|
||||
string exeDirDummyFxVersion = Path.Combine(_executableDir, "shared", "Microsoft.NETCore.App", "9999.0.0");
|
||||
string exeDirDummyFxVersion = Path.Combine(_exeDir, "shared", "Microsoft.NETCore.App", "9999.0.0");
|
||||
string builtSharedFxDir = fixture.BuiltDotnet.GreatestVersionSharedFxPath;
|
||||
SharedFramework.CopyDirectory(builtSharedFxDir, exeDirDummyFxVersion);
|
||||
|
||||
@@ -99,6 +106,7 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.MultilevelSDKLookup
|
||||
_cwdSelectedMessage = $"Using dotnet SDK dll=[{_cwdSdkBaseDir}";
|
||||
_userSelectedMessage = $"Using dotnet SDK dll=[{_userSdkBaseDir}";
|
||||
_exeSelectedMessage = $"Using dotnet SDK dll=[{_exeSdkBaseDir}";
|
||||
_regSelectedMessage = $"Using dotnet SDK dll=[{_regSdkBaseDir}";
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@@ -112,97 +120,103 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.MultilevelSDKLookup
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SdkLookup_Global_Json_Single_Digit_Patch_Rollup()
|
||||
public void SdkMultilevelLookup_Global_Json_Single_Digit_Patch_Rollup()
|
||||
{
|
||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
// Multi-level lookup is only supported on Windows.
|
||||
return;
|
||||
}
|
||||
|
||||
var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture
|
||||
.Copy();
|
||||
|
||||
var dotnet = fixture.BuiltDotnet;
|
||||
|
||||
// Set specified CLI version = 9999.3.4-global-dummy
|
||||
// Set specified SDK version = 9999.3.4-global-dummy
|
||||
SetGlobalJsonVersion("SingleDigit-global.json");
|
||||
|
||||
// Specified CLI version: 9999.3.4-global-dummy
|
||||
// CWD: empty
|
||||
// Specified SDK version: 9999.3.4-global-dummy
|
||||
// Cwd: empty
|
||||
// User: empty
|
||||
// Exe: empty
|
||||
// Reg: empty
|
||||
// Expected: no compatible version and a specific error messages
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1")
|
||||
.EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir)
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute(fExpectedToFail: true)
|
||||
.Should()
|
||||
.Fail()
|
||||
.And
|
||||
.HaveStdErrContaining("A compatible installed dotnet SDK for global.json version")
|
||||
.And
|
||||
.HaveStdErrContaining("It was not possible to find any installed dotnet SDKs")
|
||||
.And
|
||||
.NotHaveStdErrContaining("Checking if resolved SDK dir");
|
||||
.HaveStdErrContaining("A compatible installed dotnet SDK for global.json version");
|
||||
|
||||
// Add some dummy versions
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.4.1", "9999.3.4-dummy");
|
||||
|
||||
// Specified CLI version: 9999.3.4-global-dummy
|
||||
// CWD: empty
|
||||
// Specified SDK version: 9999.3.4-global-dummy
|
||||
// Cwd: empty
|
||||
// User: empty
|
||||
// Exe: 9999.4.1, 9999.3.4-dummy
|
||||
// Reg: empty
|
||||
// Expected: no compatible version and a specific error message
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1")
|
||||
.EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir)
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute(fExpectedToFail: true)
|
||||
.Should()
|
||||
.Fail()
|
||||
.And
|
||||
.HaveStdErrContaining("A compatible installed dotnet SDK for global.json version")
|
||||
.And
|
||||
.NotHaveStdErrContaining("It was not possible to find any installed dotnet SDKs");
|
||||
.HaveStdErrContaining("A compatible installed dotnet SDK for global.json version");
|
||||
|
||||
// Add specified CLI version
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.3");
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_regSdkBaseDir, "9999.3.3");
|
||||
|
||||
// Specified CLI version: 9999.3.4-global-dummy
|
||||
// CWD: empty
|
||||
// Specified SDK version: 9999.3.4-global-dummy
|
||||
// Cwd: empty
|
||||
// User: empty
|
||||
// Exe: 9999.4.1, 9999.3.4-dummy, 9999.3.3
|
||||
// Exe: 9999.4.1, 9999.3.4-dummy
|
||||
// Reg: 9999.3.3
|
||||
// Expected: no compatible version and a specific error message
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1")
|
||||
.EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir)
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute(fExpectedToFail: true)
|
||||
.Should()
|
||||
.Fail()
|
||||
.And
|
||||
.HaveStdErrContaining("A compatible installed dotnet SDK for global.json version")
|
||||
.And
|
||||
.NotHaveStdErrContaining("It was not possible to find any installed dotnet SDKs");
|
||||
.HaveStdErrContaining("A compatible installed dotnet SDK for global.json version");
|
||||
|
||||
// Add specified CLI version
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.4");
|
||||
|
||||
// Specified CLI version: 9999.3.4-global-dummy
|
||||
// CWD: empty
|
||||
// Specified SDK version: 9999.3.4-global-dummy
|
||||
// Cwd: empty
|
||||
// User: empty
|
||||
// Exe: 9999.4.1, 9999.3.4-dummy, 9999.3.3, 9999.3.4
|
||||
// Exe: 9999.4.1, 9999.3.4-dummy, 9999.3.4
|
||||
// Reg: 9999.3.3
|
||||
// Expected: 9999.3.4 from exe dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1")
|
||||
.EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir)
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
@@ -211,61 +225,67 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.MultilevelSDKLookup
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.3.4", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Add specified CLI version
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.5-dummy");
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_regSdkBaseDir, "9999.3.5-dummy");
|
||||
|
||||
// Specified CLI version: 9999.3.4-global-dummy
|
||||
// CWD: empty
|
||||
// Specified SDK version: 9999.3.4-global-dummy
|
||||
// Cwd: empty
|
||||
// User: empty
|
||||
// Exe: 9999.4.1, 9999.3.4-dummy, 9999.3.3, 9999.3.4, 9999.3.5-dummy
|
||||
// Expected: 9999.3.5-dummy from exe dir
|
||||
// Exe: 9999.4.1, 9999.3.4-dummy, 9999.3.4
|
||||
// Reg: 9999.3.3, 9999.3.5-dummy
|
||||
// Expected: 9999.3.5-dummy from reg dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1")
|
||||
.EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir)
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.3.5-dummy", _dotnetSdkDllMessageTerminator));
|
||||
.HaveStdErrContaining(Path.Combine(_regSelectedMessage, "9999.3.5-dummy", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Add specified CLI version
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.600");
|
||||
|
||||
// Specified CLI version: 9999.3.4-global-dummy
|
||||
// CWD: empty
|
||||
// Specified SDK version: 9999.3.4-global-dummy
|
||||
// Cwd: empty
|
||||
// User: empty
|
||||
// Exe: 9999.4.1, 9999.3.4-dummy, 9999.3.3, 9999.3.4, 9999.3.5-dummy, 9999.3.600
|
||||
// Expected: 9999.3.5-dummy from exe dir
|
||||
// Exe: 9999.4.1, 9999.3.4-dummy, 9999.3.4, 9999.3.600
|
||||
// Reg: 9999.3.3, 9999.3.5-dummy
|
||||
// Expected: 9999.3.5-dummy from reg dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1")
|
||||
.EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir)
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.3.5-dummy", _dotnetSdkDllMessageTerminator));
|
||||
.HaveStdErrContaining(Path.Combine(_regSelectedMessage, "9999.3.5-dummy", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Add specified CLI version
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.4-global-dummy");
|
||||
|
||||
// Specified CLI version: 9999.3.4-global-dummy
|
||||
// CWD: empty
|
||||
// Specified SDK version: 9999.3.4-global-dummy
|
||||
// Cwd: empty
|
||||
// User: empty
|
||||
// Exe: 9999.4.1, 9999.3.4-dummy, 9999.3.3, 9999.3.4, 9999.3.5-dummy, 9999.3.600, 9999.3.4-global-dummy
|
||||
// Exe: 9999.4.1, 9999.3.4-dummy, 9999.3.4, 9999.3.600, 9999.3.4-global-dummy
|
||||
// Reg: 9999.3.3, 9999.3.5-dummy
|
||||
// Expected: 9999.3.4-global-dummy from exe dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1")
|
||||
.EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir)
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
@@ -274,11 +294,13 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.MultilevelSDKLookup
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.3.4-global-dummy", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Verify we have the expected sdk versions
|
||||
// Verify we have the expected SDK versions
|
||||
dotnet.Exec("--list-sdks")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1")
|
||||
.EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir)
|
||||
.CaptureStdOut()
|
||||
.Execute()
|
||||
.Should()
|
||||
@@ -300,116 +322,126 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.MultilevelSDKLookup
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SdkLookup_Global_Json_Two_Part_Patch_Rollup()
|
||||
public void SdkMultilevelLookup_Global_Json_Two_Part_Patch_Rollup()
|
||||
{
|
||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
// Multi-level lookup is only supported on Windows.
|
||||
return;
|
||||
}
|
||||
|
||||
var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture
|
||||
.Copy();
|
||||
|
||||
var dotnet = fixture.BuiltDotnet;
|
||||
|
||||
// Set specified CLI version = 9999.3.304-global-dummy
|
||||
// Set specified SDK version = 9999.3.304-global-dummy
|
||||
SetGlobalJsonVersion("TwoPart-global.json");
|
||||
|
||||
// Specified CLI version: 9999.3.304-global-dummy
|
||||
// CWD: empty
|
||||
// Specified SDK version: 9999.3.304-global-dummy
|
||||
// Cwd: empty
|
||||
// User: empty
|
||||
// Exe: empty
|
||||
// Reg: empty
|
||||
// Expected: no compatible version and a specific error messages
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1")
|
||||
.EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir)
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute(fExpectedToFail: true)
|
||||
.Should()
|
||||
.Fail()
|
||||
.And
|
||||
.HaveStdErrContaining("A compatible installed dotnet SDK for global.json version")
|
||||
.And
|
||||
.HaveStdErrContaining("It was not possible to find any installed dotnet SDKs");
|
||||
.HaveStdErrContaining("A compatible installed dotnet SDK for global.json version");
|
||||
|
||||
// Add some dummy versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.57", "9999.3.4-dummy");
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_regSdkBaseDir, "9999.3.57", "9999.3.4-dummy");
|
||||
|
||||
// Specified CLI version: 9999.3.304-global-dummy
|
||||
// CWD: empty
|
||||
// Specified SDK version: 9999.3.304-global-dummy
|
||||
// Cwd: empty
|
||||
// User: empty
|
||||
// Exe: 9999.3.57, 9999.3.4-dummy
|
||||
// Exe: empty
|
||||
// Reg: 9999.3.57, 9999.3.4-dummy
|
||||
// Expected: no compatible version and a specific error message
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1")
|
||||
.EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir)
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute(fExpectedToFail: true)
|
||||
.Should()
|
||||
.Fail()
|
||||
.And
|
||||
.HaveStdErrContaining("A compatible installed dotnet SDK for global.json version")
|
||||
.And
|
||||
.NotHaveStdErrContaining("It was not possible to find any installed dotnet SDKs");
|
||||
.HaveStdErrContaining("A compatible installed dotnet SDK for global.json version");
|
||||
|
||||
// Add specified CLI version
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.300", "9999.7.304-global-dummy");
|
||||
|
||||
// Specified CLI version: 9999.3.304-global-dummy
|
||||
// CWD: empty
|
||||
// Specified SDK version: 9999.3.304-global-dummy
|
||||
// Cwd: empty
|
||||
// User: empty
|
||||
// Exe: 9999.3.57, 9999.3.4-dummy, 9999.3.300, 9999.7.304-global-dummy
|
||||
// Exe: 9999.3.300, 9999.7.304-global-dummy
|
||||
// Reg: 9999.3.57, 9999.3.4-dummy
|
||||
// Expected: no compatible version and a specific error message
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1")
|
||||
.EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir)
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute(fExpectedToFail: true)
|
||||
.Should()
|
||||
.Fail()
|
||||
.And
|
||||
.HaveStdErrContaining("A compatible installed dotnet SDK for global.json version")
|
||||
.And
|
||||
.NotHaveStdErrContaining("It was not possible to find any installed dotnet SDKs");
|
||||
.HaveStdErrContaining("A compatible installed dotnet SDK for global.json version");
|
||||
|
||||
// Add specified CLI version
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.304");
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_regSdkBaseDir, "9999.3.304");
|
||||
|
||||
// Specified CLI version: 9999.3.304-global-dummy
|
||||
// CWD: empty
|
||||
// Specified SDK version: 9999.3.304-global-dummy
|
||||
// Cwd: empty
|
||||
// User: empty
|
||||
// Exe: 99999.3.57, 9999.3.4-dummy, 9999.3.300, 9999.7.304-global-dummy, 9999.3.304
|
||||
// Expected: 9999.3.304 from exe dir
|
||||
// Exe: 9999.3.300, 9999.7.304-global-dummy
|
||||
// Reg: 9999.3.57, 9999.3.4-dummy, 9999.3.304
|
||||
// Expected: 9999.3.304 from reg dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1")
|
||||
.EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir)
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.3.304", _dotnetSdkDllMessageTerminator));
|
||||
.HaveStdErrContaining(Path.Combine(_regSelectedMessage, "9999.3.304", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Add specified CLI version
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.399", "9999.3.399-dummy", "9999.3.400");
|
||||
|
||||
// Specified CLI version: 9999.3.304-global-dummy
|
||||
// CWD: empty
|
||||
// Specified SDK version: 9999.3.304-global-dummy
|
||||
// Cwd: empty
|
||||
// User: empty
|
||||
// Exe: 9999.3.57, 9999.3.4-dummy, 9999.3.300, 9999.7.304-global-dummy, 9999.3.304, 9999.3.399, 9999.3.399-dummy, 9999.3.400
|
||||
// Exe: 9999.3.300, 9999.7.304-global-dummy, 9999.3.399, 9999.3.399-dummy, 9999.3.400
|
||||
// Reg: 9999.3.57, 9999.3.4-dummy, 9999.3.304
|
||||
// Expected: 9999.3.399 from exe dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1")
|
||||
.EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir)
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
@@ -418,19 +450,22 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.MultilevelSDKLookup
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.3.399", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Add specified CLI version
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.2400, 9999.3.3004");
|
||||
AddAvailableSdkVersions(_regSdkBaseDir, "9999.3.2400, 9999.3.3004");
|
||||
|
||||
// Specified CLI version: 9999.3.304-global-dummy
|
||||
// CWD: empty
|
||||
// Specified SDK version: 9999.3.304-global-dummy
|
||||
// Cwd: empty
|
||||
// User: empty
|
||||
// Exe: 9999.3.57, 9999.3.4-dummy, 9999.3.300, 9999.7.304-global-dummy, 9999.3.304, 9999.3.399, 9999.3.399-dummy, 9999.3.400, 9999.3.2400, 9999.3.3004
|
||||
// Exe: 9999.3.300, 9999.7.304-global-dummy, 9999.3.399, 9999.3.399-dummy, 9999.3.400, 9999.3.2400, 9999.3.3004
|
||||
// Reg: 9999.3.57, 9999.3.4-dummy, 9999.3.304, 9999.3.2400, 9999.3.3004
|
||||
// Expected: 9999.3.399 from exe dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1")
|
||||
.EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir)
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
@@ -439,32 +474,36 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.MultilevelSDKLookup
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.3.399", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Add specified CLI version
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.304-global-dummy");
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_regSdkBaseDir, "9999.3.304-global-dummy");
|
||||
|
||||
// Specified CLI version: 9999.3.304-global-dummy
|
||||
// CWD: empty
|
||||
// Specified SDK version: 9999.3.304-global-dummy
|
||||
// Cwd: empty
|
||||
// User: empty
|
||||
// Exe: 9999.3.57, 9999.3.4-dummy, 9999.3.300, 9999.7.304-global-dummy, 9999.3.304, 9999.3.399, 9999.3.399-dummy, 9999.3.400, 9999.3.2400, 9999.3.3004, 9999.3.304-global-dummy
|
||||
// Expected: 9999.3.304-global-dummy from exe dir
|
||||
// Exe: 9999.3.300, 9999.7.304-global-dummy, 9999.3.399, 9999.3.399-dummy, 9999.3.400, 9999.3.2400, 9999.3.3004
|
||||
// Reg: 9999.3.57, 9999.3.4-dummy, 9999.3.304, 9999.3.2400, 9999.3.3004, 9999.3.304-global-dummy
|
||||
// Expected: 9999.3.304-global-dummy from reg dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1")
|
||||
.EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir)
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.3.304-global-dummy", _dotnetSdkDllMessageTerminator));
|
||||
.HaveStdErrContaining(Path.Combine(_regSelectedMessage, "9999.3.304-global-dummy", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Verify we have the expected sdk versions
|
||||
// Verify we have the expected SDK versions
|
||||
dotnet.Exec("--list-sdks")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1")
|
||||
.EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir)
|
||||
.CaptureStdOut()
|
||||
.Execute()
|
||||
.Should()
|
||||
@@ -494,49 +533,57 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.MultilevelSDKLookup
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SdkLookup_Negative_Version()
|
||||
public void SdkMultilevelLookup_Precedential_Order()
|
||||
{
|
||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
// Multi-level lookup is only supported on Windows.
|
||||
return;
|
||||
}
|
||||
|
||||
var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture
|
||||
.Copy();
|
||||
|
||||
var dotnet = fixture.BuiltDotnet;
|
||||
|
||||
// Add a negative CLI version
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "-1.-1.-1");
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_regSdkBaseDir, "9999.0.4");
|
||||
|
||||
// Specified CLI version: none
|
||||
// CWD: empty
|
||||
// Specified SDK version: none
|
||||
// Cwd: empty
|
||||
// User: empty
|
||||
// Exe: -1.-1.-1
|
||||
// Expected: no compatible version and a specific error messages
|
||||
// Exe: empty
|
||||
// Reg: 9999.0.4
|
||||
// Expected: 9999.0.4 from reg dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1")
|
||||
.EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir)
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute(fExpectedToFail: true)
|
||||
.Execute()
|
||||
.Should()
|
||||
.Fail()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdErrContaining("It was not possible to find any installed dotnet SDKs")
|
||||
.And
|
||||
.HaveStdErrContaining("Did you mean to run dotnet SDK commands? Please install dotnet SDK from");
|
||||
.HaveStdErrContaining(Path.Combine(_regSelectedMessage, "9999.0.4", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Add specified CLI version
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.0.4");
|
||||
|
||||
// Specified CLI version: none
|
||||
// CWD: empty
|
||||
// Specified SDK version: none
|
||||
// Cwd: empty
|
||||
// User: empty
|
||||
// Exe: -1.-1.-1, 9999.0.4
|
||||
// Exe: 9999.0.4
|
||||
// Reg: 9999.0.4
|
||||
// Expected: 9999.0.4 from exe dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1")
|
||||
.EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir)
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
@@ -544,61 +591,60 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.MultilevelSDKLookup
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.0.4", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Verify we have the expected sdk versions
|
||||
dotnet.Exec("--list-sdks")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdOutContaining("9999.0.4");
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void SdkLookup_Must_Pick_The_Highest_Semantic_Version()
|
||||
public void SdkMultilevelLookup_Must_Pick_The_Highest_Semantic_Version()
|
||||
{
|
||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
// Multi-level lookup is only supported on Windows.
|
||||
return;
|
||||
}
|
||||
|
||||
var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture
|
||||
.Copy();
|
||||
|
||||
var dotnet = fixture.BuiltDotnet;
|
||||
|
||||
// Add dummy versions in the exe dir
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.0.0", "9999.0.3-dummy");
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_regSdkBaseDir, "9999.0.0", "9999.0.3-dummy");
|
||||
|
||||
// Specified CLI version: none
|
||||
// CWD: empty
|
||||
// Specified SDK version: none
|
||||
// Cwd: empty
|
||||
// User: empty
|
||||
// Exe: 9999.0.0, 9999.0.3-dummy
|
||||
// Expected: 9999.0.3-dummy from exe dir
|
||||
// Exe: empty
|
||||
// Reg: 9999.0.0, 9999.0.3-dummy
|
||||
// Expected: 9999.0.3-dummy from reg dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1")
|
||||
.EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir)
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.0.3-dummy", _dotnetSdkDllMessageTerminator));
|
||||
.HaveStdErrContaining(Path.Combine(_regSelectedMessage, "9999.0.3-dummy", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Add dummy versions in the exe dir
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.0.3");
|
||||
|
||||
// Specified CLI version: none
|
||||
// CWD: empty
|
||||
// Specified SDK version: none
|
||||
// Cwd: empty
|
||||
// User: empty
|
||||
// Exe: 9999.0.0, 9999.0.3-dummy, 9999.0.3
|
||||
// Exe: 9999.0.3
|
||||
// Reg: 9999.0.0, 9999.0.3-dummy
|
||||
// Expected: 9999.0.3 from exe dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1")
|
||||
.EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir)
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
@@ -607,60 +653,69 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.MultilevelSDKLookup
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.0.3", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Add dummy versions
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_userSdkBaseDir, "9999.0.200");
|
||||
AddAvailableSdkVersions(_cwdSdkBaseDir, "10000.0.0");
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.0.100");
|
||||
AddAvailableSdkVersions(_regSdkBaseDir, "9999.0.100");
|
||||
|
||||
// Specified CLI version: none
|
||||
// CWD: 10000.0.0 --> should not be picked
|
||||
// Specified SDK version: none
|
||||
// Cwd: 10000.0.0 --> should not be picked
|
||||
// User: 9999.0.200 --> should not be picked
|
||||
// Exe: 9999.0.0, 9999.0.3-dummy, 9999.0.3, 9999.0.100
|
||||
// Expected: 9999.0.100 from exe dir
|
||||
// Exe: 9999.0.3
|
||||
// Reg: 9999.0.0, 9999.0.3-dummy, 9999.0.100
|
||||
// Expected: 9999.0.100 from reg dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1")
|
||||
.EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir)
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.0.100", _dotnetSdkDllMessageTerminator));
|
||||
.HaveStdErrContaining(Path.Combine(_regSelectedMessage, "9999.0.100", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Add a dummy version in the exe dir
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.0.80");
|
||||
|
||||
// Specified CLI version: none
|
||||
// CWD: 10000.0.0 --> should not be picked
|
||||
// Specified SDK version: none
|
||||
// Cwd: 10000.0.0 --> should not be picked
|
||||
// User: 9999.0.200 --> should not be picked
|
||||
// Exe: 9999.0.0, 9999.0.3-dummy, 9999.0.3, 9999.0.100, 9999.0.80
|
||||
// Expected: 9999.0.100 from exe dir
|
||||
// Exe: 9999.0.3, 9999.0.80
|
||||
// Reg: 9999.0.0, 9999.0.3-dummy, 9999.0.100
|
||||
// Expected: 9999.0.100 from reg dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1")
|
||||
.EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir)
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.0.100", _dotnetSdkDllMessageTerminator));
|
||||
.HaveStdErrContaining(Path.Combine(_regSelectedMessage, "9999.0.100", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Add a dummy version in the user dir
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.0.5500000");
|
||||
|
||||
// Specified CLI version: none
|
||||
// CWD: 10000.0.0 --> should not be picked
|
||||
// Specified SDK version: none
|
||||
// Cwd: 10000.0.0 --> should not be picked
|
||||
// User: 9999.0.200 --> should not be picked
|
||||
// Exe: 9999.0.0, 9999.0.3-dummy, 9999.0.3, 9999.0.100, 9999.0.80, 9999.0.5500000
|
||||
// Exe: 9999.0.3, 9999.0.80, 9999.0.5500000
|
||||
// Reg: 9999.0.0, 9999.0.3-dummy, 9999.0.100
|
||||
// Expected: 9999.0.5500000 from exe dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1")
|
||||
.EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir)
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
@@ -669,31 +724,36 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.MultilevelSDKLookup
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.0.5500000", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Add a dummy version in the user dir
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.0.52000000");
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_regSdkBaseDir, "9999.0.52000000");
|
||||
|
||||
// Specified CLI version: none
|
||||
// CWD: 10000.0.0 --> should not be picked
|
||||
// Specified SDK version: none
|
||||
// Cwd: 10000.0.0 --> should not be picked
|
||||
// User: 9999.0.200 --> should not be picked
|
||||
// Exe: 9999.0.0, 9999.0.3-dummy, 9999.0.3, 9999.0.100, 9999.0.80, 9999.0.5500000, 9999.0.52000000
|
||||
// Expected: 9999.0.52000000 from exe dir
|
||||
// Exe: 9999.0.3, 9999.0.80, 9999.0.5500000
|
||||
// Reg: 9999.0.0, 9999.0.3-dummy, 9999.0.100, 9999.0.52000000
|
||||
// Expected: 9999.0.52000000 from reg dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1")
|
||||
.EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir)
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.0.52000000", _dotnetSdkDllMessageTerminator));
|
||||
.HaveStdErrContaining(Path.Combine(_regSelectedMessage, "9999.0.52000000", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Verify we have the expected sdk versions
|
||||
// Verify we have the expected SDK versions
|
||||
dotnet.Exec("--list-sdks")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1")
|
||||
.EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir)
|
||||
.CaptureStdOut()
|
||||
.Execute()
|
||||
.Should()
|
||||
|
||||
+175
-820
File diff suppressed because it is too large.
Load diff
@@ -149,11 +149,14 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeHostApis
|
||||
public string AppDll => _fixture.TestProject.AppDll;
|
||||
public string ExeDir => Path.Combine(_fixture.TestProject.ProjectDirectory, "ed");
|
||||
public string ProgramFiles => Path.Combine(ExeDir, "pf");
|
||||
public string SelfRegistered => Path.Combine(ExeDir, "sr");
|
||||
public string WorkingDir => Path.Combine(_fixture.TestProject.ProjectDirectory, "wd");
|
||||
public string GlobalSdkDir => Path.Combine(ProgramFiles, "dotnet", "sdk");
|
||||
public string ProgramFilesGlobalSdkDir => Path.Combine(ProgramFiles, "dotnet", "sdk");
|
||||
public string SelfRegisteredGlobalSdkDir => Path.Combine(SelfRegistered, "sdk");
|
||||
public string LocalSdkDir => Path.Combine(ExeDir, "sdk");
|
||||
public string GlobalJson => Path.Combine(WorkingDir, "global.json");
|
||||
public string[] GlobalSdks = new[] { "4.5.6", "1.2.3", "2.3.4-preview" };
|
||||
public string[] ProgramFilesGlobalSdks = new[] { "4.5.6", "1.2.3", "2.3.4-preview" };
|
||||
public string[] SelfRegisteredGlobalSdks = new[] { "3.0.0", "15.1.4-preview", "5.6.7" };
|
||||
public string[] LocalSdks = new[] { "0.1.2", "5.6.7-preview", "1.2.3" };
|
||||
|
||||
public SdkResolutionFixture(SharedTestState state)
|
||||
@@ -166,11 +169,14 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeHostApis
|
||||
// on a given machine from impacting the test.
|
||||
File.WriteAllText(GlobalJson, "{}");
|
||||
|
||||
foreach (string sdk in GlobalSdks)
|
||||
foreach (string sdk in ProgramFilesGlobalSdks)
|
||||
{
|
||||
Directory.CreateDirectory(Path.Combine(GlobalSdkDir, sdk));
|
||||
Directory.CreateDirectory(Path.Combine(ProgramFilesGlobalSdkDir, sdk));
|
||||
}
|
||||
foreach (string sdk in SelfRegisteredGlobalSdks)
|
||||
{
|
||||
Directory.CreateDirectory(Path.Combine(SelfRegisteredGlobalSdkDir, sdk));
|
||||
}
|
||||
|
||||
foreach (string sdk in LocalSdks)
|
||||
{
|
||||
Directory.CreateDirectory(Path.Combine(LocalSdkDir, sdk));
|
||||
@@ -194,15 +200,19 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeHostApis
|
||||
string expectedList = string.Join(';', new[]
|
||||
{
|
||||
Path.Combine(f.LocalSdkDir, "0.1.2"),
|
||||
Path.Combine(f.GlobalSdkDir, "1.2.3"),
|
||||
Path.Combine(f.ProgramFilesGlobalSdkDir, "1.2.3"),
|
||||
Path.Combine(f.LocalSdkDir, "1.2.3"),
|
||||
Path.Combine(f.GlobalSdkDir, "2.3.4-preview"),
|
||||
Path.Combine(f.GlobalSdkDir, "4.5.6"),
|
||||
Path.Combine(f.ProgramFilesGlobalSdkDir, "2.3.4-preview"),
|
||||
Path.Combine(f.SelfRegisteredGlobalSdkDir, "3.0.0"),
|
||||
Path.Combine(f.ProgramFilesGlobalSdkDir, "4.5.6"),
|
||||
Path.Combine(f.LocalSdkDir, "5.6.7-preview"),
|
||||
Path.Combine(f.SelfRegisteredGlobalSdkDir, "5.6.7"),
|
||||
Path.Combine(f.SelfRegisteredGlobalSdkDir, "15.1.4-preview"),
|
||||
});
|
||||
|
||||
f.Dotnet.Exec(f.AppDll, new[] { "hostfxr_get_available_sdks", f.ExeDir })
|
||||
.EnvironmentVariable("TEST_MULTILEVEL_LOOKUP_PROGRAM_FILES", f.ProgramFiles)
|
||||
.EnvironmentVariable("TEST_MULTILEVEL_LOOKUP_SELF_REGISTERED", f.SelfRegistered)
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
|
||||
@@ -0,0 +1,734 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.DotNet.InternalAbstractions;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.SDKLookup
|
||||
{
|
||||
public class GivenThatICareAboutSDKLookup : IDisposable
|
||||
{
|
||||
private static IDictionary<string, string> s_DefaultEnvironment = new Dictionary<string, string>()
|
||||
{
|
||||
{"COREHOST_TRACE", "1" },
|
||||
// The SDK being used may be crossgen'd for a different architecture than we are building for.
|
||||
// Turn off ready to run, so an x64 crossgen'd SDK can be loaded in an x86 process.
|
||||
{"COMPlus_ReadyToRun", "0" },
|
||||
};
|
||||
|
||||
private RepoDirectoriesProvider RepoDirectories;
|
||||
private TestProjectFixture PreviouslyBuiltAndRestoredPortableTestProjectFixture;
|
||||
|
||||
private string _currentWorkingDir;
|
||||
private string _userDir;
|
||||
private string _executableDir;
|
||||
private string _cwdSdkBaseDir;
|
||||
private string _userSdkBaseDir;
|
||||
private string _exeSdkBaseDir;
|
||||
private string _cwdSelectedMessage;
|
||||
private string _userSelectedMessage;
|
||||
private string _exeSelectedMessage;
|
||||
private string _sdkDir;
|
||||
private string _baseDir;
|
||||
|
||||
private const string _dotnetSdkDllMessageTerminator = "dotnet.dll]";
|
||||
|
||||
public GivenThatICareAboutSDKLookup()
|
||||
{
|
||||
// From the artifacts dir, it's possible to find where the sharedFrameworkPublish folder is. We need
|
||||
// to locate it because we'll copy its contents into other folders
|
||||
string artifactsDir = Environment.GetEnvironmentVariable("TEST_ARTIFACTS");
|
||||
string builtDotnet = Path.Combine(artifactsDir, "sharedFrameworkPublish");
|
||||
|
||||
// The dotnetSDKLookup dir will contain some folders and files that will be
|
||||
// necessary to perform the tests
|
||||
string baseDir = Path.Combine(artifactsDir, "dotnetSDKLookup");
|
||||
_baseDir = SharedFramework.CalculateUniqueTestDirectory(baseDir);
|
||||
|
||||
// The three tested locations will be the cwd, the user folder and the exe dir. cwd and user are no longer supported.
|
||||
// All dirs will be placed inside the base folder
|
||||
|
||||
_currentWorkingDir = Path.Combine(_baseDir, "cwd");
|
||||
_userDir = Path.Combine(_baseDir, "user");
|
||||
_executableDir = Path.Combine(_baseDir, "exe");
|
||||
|
||||
// It's necessary to copy the entire publish folder to the exe dir because
|
||||
// we'll need to build from it. The CopyDirectory method automatically creates the dest dir
|
||||
SharedFramework.CopyDirectory(builtDotnet, _executableDir);
|
||||
|
||||
RepoDirectories = new RepoDirectoriesProvider(builtDotnet: _executableDir);
|
||||
|
||||
// SdkBaseDirs contain all available version folders
|
||||
_cwdSdkBaseDir = Path.Combine(_currentWorkingDir, "sdk");
|
||||
_userSdkBaseDir = Path.Combine(_userDir, ".dotnet", RepoDirectories.BuildArchitecture, "sdk");
|
||||
_exeSdkBaseDir = Path.Combine(_executableDir, "sdk");
|
||||
|
||||
// Create directories
|
||||
Directory.CreateDirectory(_cwdSdkBaseDir);
|
||||
Directory.CreateDirectory(_userSdkBaseDir);
|
||||
Directory.CreateDirectory(_exeSdkBaseDir);
|
||||
|
||||
// Restore and build PortableApp from exe dir
|
||||
PreviouslyBuiltAndRestoredPortableTestProjectFixture = new TestProjectFixture("PortableApp", RepoDirectories)
|
||||
.EnsureRestored(RepoDirectories.CorehostPackages)
|
||||
.BuildProject();
|
||||
var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture;
|
||||
|
||||
// Set a dummy framework version (9999.0.0) in the exe sharedFx location. We will
|
||||
// always pick the framework from this to avoid interference with the sharedFxLookup
|
||||
string exeDirDummyFxVersion = Path.Combine(_executableDir, "shared", "Microsoft.NETCore.App", "9999.0.0");
|
||||
string builtSharedFxDir = fixture.BuiltDotnet.GreatestVersionSharedFxPath;
|
||||
SharedFramework.CopyDirectory(builtSharedFxDir, exeDirDummyFxVersion);
|
||||
|
||||
// The actual SDK version can be obtained from the built fixture. We'll use it to
|
||||
// locate the sdkDir from which we can get the files contained in the version folder
|
||||
string sdkBaseDir = Path.Combine(fixture.SdkDotnet.BinPath, "sdk");
|
||||
|
||||
var sdkVersionDirs = Directory.EnumerateDirectories(sdkBaseDir)
|
||||
.Select(p => Path.GetFileName(p));
|
||||
|
||||
string greatestVersionSdk = sdkVersionDirs
|
||||
.Where(p => !string.Equals(p, "NuGetFallbackFolder", StringComparison.OrdinalIgnoreCase))
|
||||
.OrderByDescending(p => p.ToLower())
|
||||
.First();
|
||||
|
||||
_sdkDir = Path.Combine(sdkBaseDir, greatestVersionSdk);
|
||||
|
||||
// Trace messages used to identify from which folder the SDK was picked
|
||||
_cwdSelectedMessage = $"Using dotnet SDK dll=[{_cwdSdkBaseDir}";
|
||||
_userSelectedMessage = $"Using dotnet SDK dll=[{_userSdkBaseDir}";
|
||||
_exeSelectedMessage = $"Using dotnet SDK dll=[{_exeSdkBaseDir}";
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
PreviouslyBuiltAndRestoredPortableTestProjectFixture.Dispose();
|
||||
|
||||
if (!TestProject.PreserveTestRuns())
|
||||
{
|
||||
Directory.Delete(_baseDir, true);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SdkLookup_Global_Json_Single_Digit_Patch_Rollup()
|
||||
{
|
||||
var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture
|
||||
.Copy();
|
||||
|
||||
var dotnet = fixture.BuiltDotnet;
|
||||
|
||||
// Set specified SDK version = 9999.3.4-global-dummy
|
||||
SetGlobalJsonVersion("SingleDigit-global.json");
|
||||
|
||||
// Specified SDK version: 9999.3.4-global-dummy
|
||||
// Exe: empty
|
||||
// Expected: no compatible version and a specific error messages
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute(fExpectedToFail: true)
|
||||
.Should()
|
||||
.Fail()
|
||||
.And
|
||||
.HaveStdErrContaining("A compatible installed dotnet SDK for global.json version")
|
||||
.And
|
||||
.HaveStdErrContaining("It was not possible to find any installed dotnet SDKs")
|
||||
.And
|
||||
.NotHaveStdErrContaining("Checking if resolved SDK dir");
|
||||
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.4.1", "9999.3.4-dummy");
|
||||
|
||||
// Specified SDK version: 9999.3.4-global-dummy
|
||||
// Exe: 9999.4.1, 9999.3.4-dummy
|
||||
// Expected: no compatible version and a specific error message
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute(fExpectedToFail: true)
|
||||
.Should()
|
||||
.Fail()
|
||||
.And
|
||||
.HaveStdErrContaining("A compatible installed dotnet SDK for global.json version")
|
||||
.And
|
||||
.NotHaveStdErrContaining("It was not possible to find any installed dotnet SDKs");
|
||||
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.3");
|
||||
|
||||
// Specified SDK version: 9999.3.4-global-dummy
|
||||
// Exe: 9999.4.1, 9999.3.4-dummy, 9999.3.3
|
||||
// Expected: no compatible version and a specific error message
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute(fExpectedToFail: true)
|
||||
.Should()
|
||||
.Fail()
|
||||
.And
|
||||
.HaveStdErrContaining("A compatible installed dotnet SDK for global.json version")
|
||||
.And
|
||||
.NotHaveStdErrContaining("It was not possible to find any installed dotnet SDKs");
|
||||
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.4");
|
||||
|
||||
// Specified SDK version: 9999.3.4-global-dummy
|
||||
// Exe: 9999.4.1, 9999.3.4-dummy, 9999.3.3, 9999.3.4
|
||||
// Expected: 9999.3.4 from exe dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.3.4", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.5-dummy");
|
||||
|
||||
// Specified SDK version: 9999.3.4-global-dummy
|
||||
// Exe: 9999.4.1, 9999.3.4-dummy, 9999.3.3, 9999.3.4, 9999.3.5-dummy
|
||||
// Expected: 9999.3.5-dummy from exe dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.3.5-dummy", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.600");
|
||||
|
||||
// Specified SDK version: 9999.3.4-global-dummy
|
||||
// Exe: 9999.4.1, 9999.3.4-dummy, 9999.3.3, 9999.3.4, 9999.3.5-dummy, 9999.3.600
|
||||
// Expected: 9999.3.5-dummy from exe dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.3.5-dummy", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.4-global-dummy");
|
||||
|
||||
// Specified SDK version: 9999.3.4-global-dummy
|
||||
// Exe: 9999.4.1, 9999.3.4-dummy, 9999.3.3, 9999.3.4, 9999.3.5-dummy, 9999.3.600, 9999.3.4-global-dummy
|
||||
// Expected: 9999.3.4-global-dummy from exe dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.3.4-global-dummy", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Verify we have the expected SDK versions
|
||||
dotnet.Exec("--list-sdks")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdOutContaining("9999.3.4-dummy")
|
||||
.And
|
||||
.HaveStdOutContaining("9999.3.4-global-dummy")
|
||||
.And
|
||||
.HaveStdOutContaining("9999.4.1")
|
||||
.And
|
||||
.HaveStdOutContaining("9999.3.3")
|
||||
.And
|
||||
.HaveStdOutContaining("9999.3.4")
|
||||
.And
|
||||
.HaveStdOutContaining("9999.3.600")
|
||||
.And
|
||||
.HaveStdOutContaining("9999.3.5-dummy");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SdkLookup_Global_Json_Two_Part_Patch_Rollup()
|
||||
{
|
||||
var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture
|
||||
.Copy();
|
||||
|
||||
var dotnet = fixture.BuiltDotnet;
|
||||
|
||||
// Set specified SDK version = 9999.3.304-global-dummy
|
||||
SetGlobalJsonVersion("TwoPart-global.json");
|
||||
|
||||
// Specified SDK version: 9999.3.304-global-dummy
|
||||
// Exe: empty
|
||||
// Expected: no compatible version and a specific error messages
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute(fExpectedToFail: true)
|
||||
.Should()
|
||||
.Fail()
|
||||
.And
|
||||
.HaveStdErrContaining("A compatible installed dotnet SDK for global.json version")
|
||||
.And
|
||||
.HaveStdErrContaining("It was not possible to find any installed dotnet SDKs");
|
||||
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.57", "9999.3.4-dummy");
|
||||
|
||||
// Specified SDK version: 9999.3.304-global-dummy
|
||||
// Exe: 9999.3.57, 9999.3.4-dummy
|
||||
// Expected: no compatible version and a specific error message
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute(fExpectedToFail: true)
|
||||
.Should()
|
||||
.Fail()
|
||||
.And
|
||||
.HaveStdErrContaining("A compatible installed dotnet SDK for global.json version")
|
||||
.And
|
||||
.NotHaveStdErrContaining("It was not possible to find any installed dotnet SDKs");
|
||||
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.300", "9999.7.304-global-dummy");
|
||||
|
||||
// Specified SDK version: 9999.3.304-global-dummy
|
||||
// Exe: 9999.3.57, 9999.3.4-dummy, 9999.3.300, 9999.7.304-global-dummy
|
||||
// Expected: no compatible version and a specific error message
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute(fExpectedToFail: true)
|
||||
.Should()
|
||||
.Fail()
|
||||
.And
|
||||
.HaveStdErrContaining("A compatible installed dotnet SDK for global.json version")
|
||||
.And
|
||||
.NotHaveStdErrContaining("It was not possible to find any installed dotnet SDKs");
|
||||
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.304");
|
||||
|
||||
// Specified SDK version: 9999.3.304-global-dummy
|
||||
// Exe: 99999.3.57, 9999.3.4-dummy, 9999.3.300, 9999.7.304-global-dummy, 9999.3.304
|
||||
// Expected: 9999.3.304 from exe dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.3.304", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.399", "9999.3.399-dummy", "9999.3.400");
|
||||
|
||||
// Specified SDK version: 9999.3.304-global-dummy
|
||||
// Exe: 9999.3.57, 9999.3.4-dummy, 9999.3.300, 9999.7.304-global-dummy, 9999.3.304, 9999.3.399, 9999.3.399-dummy, 9999.3.400
|
||||
// Expected: 9999.3.399 from exe dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.3.399", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.2400, 9999.3.3004");
|
||||
|
||||
// Specified SDK version: 9999.3.304-global-dummy
|
||||
// Exe: 9999.3.57, 9999.3.4-dummy, 9999.3.300, 9999.7.304-global-dummy, 9999.3.304, 9999.3.399, 9999.3.399-dummy, 9999.3.400, 9999.3.2400, 9999.3.3004
|
||||
// Expected: 9999.3.399 from exe dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.3.399", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.304-global-dummy");
|
||||
|
||||
// Specified SDK version: 9999.3.304-global-dummy
|
||||
// Exe: 9999.3.57, 9999.3.4-dummy, 9999.3.300, 9999.7.304-global-dummy, 9999.3.304, 9999.3.399, 9999.3.399-dummy, 9999.3.400, 9999.3.2400, 9999.3.3004, 9999.3.304-global-dummy
|
||||
// Expected: 9999.3.304-global-dummy from exe dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.3.304-global-dummy", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Verify we have the expected SDK versions
|
||||
dotnet.Exec("--list-sdks")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdOutContaining("9999.3.57")
|
||||
.And
|
||||
.HaveStdOutContaining("9999.3.4-dummy")
|
||||
.And
|
||||
.HaveStdOutContaining("9999.3.300")
|
||||
.And
|
||||
.HaveStdOutContaining("9999.7.304-global-dummy")
|
||||
.And
|
||||
.HaveStdOutContaining("9999.3.399")
|
||||
.And
|
||||
.HaveStdOutContaining("9999.3.399-dummy")
|
||||
.And
|
||||
.HaveStdOutContaining("9999.3.400")
|
||||
.And
|
||||
.HaveStdOutContaining("9999.3.2400")
|
||||
.And
|
||||
.HaveStdOutContaining("9999.3.3004")
|
||||
.And
|
||||
.HaveStdOutContaining("9999.3.304")
|
||||
.And
|
||||
.HaveStdOutContaining("9999.3.304-global-dummy");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SdkLookup_Negative_Version()
|
||||
{
|
||||
var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture
|
||||
.Copy();
|
||||
|
||||
var dotnet = fixture.BuiltDotnet;
|
||||
|
||||
// Add a negative SDK version
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "-1.-1.-1");
|
||||
|
||||
// Specified SDK version: none
|
||||
// Exe: -1.-1.-1
|
||||
// Expected: no compatible version and a specific error messages
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute(fExpectedToFail: true)
|
||||
.Should()
|
||||
.Fail()
|
||||
.And
|
||||
.HaveStdErrContaining("It was not possible to find any installed dotnet SDKs")
|
||||
.And
|
||||
.HaveStdErrContaining("Did you mean to run dotnet SDK commands? Please install dotnet SDK from");
|
||||
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.0.4");
|
||||
|
||||
// Specified SDK version: none
|
||||
// Exe: -1.-1.-1, 9999.0.4
|
||||
// Expected: 9999.0.4 from exe dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.0.4", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Verify we have the expected SDK versions
|
||||
dotnet.Exec("--list-sdks")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdOutContaining("9999.0.4");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SdkLookup_Must_Pick_The_Highest_Semantic_Version()
|
||||
{
|
||||
var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture
|
||||
.Copy();
|
||||
|
||||
var dotnet = fixture.BuiltDotnet;
|
||||
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.0.0", "9999.0.3-dummy");
|
||||
|
||||
// Specified SDK version: none
|
||||
// Cwd: empty
|
||||
// User: empty
|
||||
// Exe: 9999.0.0, 9999.0.3-dummy
|
||||
// Expected: 9999.0.3-dummy from exe dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.0.3-dummy", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.0.3");
|
||||
|
||||
// Specified SDK version: none
|
||||
// Cwd: empty
|
||||
// User: empty
|
||||
// Exe: 9999.0.0, 9999.0.3-dummy, 9999.0.3
|
||||
// Expected: 9999.0.3 from exe dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.0.3", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_userSdkBaseDir, "9999.0.200");
|
||||
AddAvailableSdkVersions(_cwdSdkBaseDir, "10000.0.0");
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.0.100");
|
||||
|
||||
// Specified SDK version: none
|
||||
// Cwd: 10000.0.0 --> should not be picked
|
||||
// User: 9999.0.200 --> should not be picked
|
||||
// Exe: 9999.0.0, 9999.0.3-dummy, 9999.0.3, 9999.0.100
|
||||
// Expected: 9999.0.100 from exe dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.0.100", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.0.80");
|
||||
|
||||
// Specified SDK version: none
|
||||
// Cwd: 10000.0.0 --> should not be picked
|
||||
// User: 9999.0.200 --> should not be picked
|
||||
// Exe: 9999.0.0, 9999.0.3-dummy, 9999.0.3, 9999.0.100, 9999.0.80
|
||||
// Expected: 9999.0.100 from exe dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.0.100", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.0.5500000");
|
||||
|
||||
// Specified SDK version: none
|
||||
// Cwd: 10000.0.0 --> should not be picked
|
||||
// User: 9999.0.200 --> should not be picked
|
||||
// Exe: 9999.0.0, 9999.0.3-dummy, 9999.0.3, 9999.0.100, 9999.0.80, 9999.0.5500000
|
||||
// Expected: 9999.0.5500000 from exe dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.0.5500000", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Add SDK versions
|
||||
AddAvailableSdkVersions(_exeSdkBaseDir, "9999.0.52000000");
|
||||
|
||||
// Specified SDK version: none
|
||||
// Cwd: 10000.0.0 --> should not be picked
|
||||
// User: 9999.0.200 --> should not be picked
|
||||
// Exe: 9999.0.0, 9999.0.3-dummy, 9999.0.3, 9999.0.100, 9999.0.80, 9999.0.5500000, 9999.0.52000000
|
||||
// Expected: 9999.0.52000000 from exe dir
|
||||
dotnet.Exec("help")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.0.52000000", _dotnetSdkDllMessageTerminator));
|
||||
|
||||
// Verify we have the expected SDK versions
|
||||
dotnet.Exec("--list-sdks")
|
||||
.WorkingDirectory(_currentWorkingDir)
|
||||
.WithUserProfile(_userDir)
|
||||
.Environment(s_DefaultEnvironment)
|
||||
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0")
|
||||
.CaptureStdOut()
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdOutContaining("9999.0.0")
|
||||
.And
|
||||
.HaveStdOutContaining("9999.0.3-dummy")
|
||||
.And
|
||||
.HaveStdOutContaining("9999.0.3")
|
||||
.And
|
||||
.HaveStdOutContaining("9999.0.100")
|
||||
.And
|
||||
.HaveStdOutContaining("9999.0.80")
|
||||
.And
|
||||
.HaveStdOutContaining("9999.0.5500000")
|
||||
.And
|
||||
.HaveStdOutContaining("9999.0.52000000");
|
||||
}
|
||||
|
||||
// This method adds a list of new sdk version folders in the specified
|
||||
// sdkBaseDir. The files are copied from the _sdkDir. Also, the dotnet.runtimeconfig.json
|
||||
// file is overwritten in order to use a dummy framework version (9999.0.0)
|
||||
// Remarks:
|
||||
// - If the sdkBaseDir does not exist, then a DirectoryNotFoundException
|
||||
// is thrown.
|
||||
// - If a specified version folder already exists, then it is deleted and replaced
|
||||
// with the contents of the _builtSharedFxDir.
|
||||
private void AddAvailableSdkVersions(string sdkBaseDir, params string[] availableVersions)
|
||||
{
|
||||
DirectoryInfo sdkBaseDirInfo = new DirectoryInfo(sdkBaseDir);
|
||||
|
||||
if (!sdkBaseDirInfo.Exists)
|
||||
{
|
||||
throw new DirectoryNotFoundException();
|
||||
}
|
||||
|
||||
string dummyRuntimeConfig = Path.Combine(RepoDirectories.RepoRoot, "src", "test", "Assets", "TestUtils",
|
||||
"SDKLookup", "dotnet.runtimeconfig.json");
|
||||
|
||||
foreach (string version in availableVersions)
|
||||
{
|
||||
string newSdkDir = Path.Combine(sdkBaseDir, version);
|
||||
SharedFramework.CopyDirectory(_sdkDir, newSdkDir);
|
||||
|
||||
string runtimeConfig = Path.Combine(newSdkDir, "dotnet.runtimeconfig.json");
|
||||
File.Copy(dummyRuntimeConfig, runtimeConfig, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Put a global.json file in the cwd in order to specify a CLI
|
||||
public void SetGlobalJsonVersion(string globalJsonFileName)
|
||||
{
|
||||
string destFile = Path.Combine(_currentWorkingDir, "global.json");
|
||||
string srcFile = Path.Combine(RepoDirectories.RepoRoot, "src", "test", "Assets", "TestUtils",
|
||||
"SDKLookup", globalJsonFileName);
|
||||
|
||||
File.Copy(srcFile, destFile, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user