private void Latest_Host_Is_Backwards_Compatible_With_Older_Runtime(TestProjectFixture previousVersionFixture) { if (!IsRidSupported()) { return; } TestProjectFixture fixture = previousVersionFixture.Copy(); string appExe = fixture.TestProject.AppExe; Assert.NotEqual(fixture.Framework, sharedTestState.FixtureLatest.Framework); Assert.NotEqual(fixture.RepoDirProvider.MicrosoftNETCoreAppVersion, sharedTestState.FixtureLatest.RepoDirProvider.MicrosoftNETCoreAppVersion); // Baseline (no changes) Command.Create(appExe) .EnvironmentVariable("COREHOST_TRACE", "1") .CaptureStdErr() .CaptureStdOut() .Execute() .Should() .Pass() .And .HaveStdOutContaining("Hello World") .And .HaveStdErrContaining($"--- Invoked apphost [version: {fixture.RepoDirProvider.MicrosoftNETCoreAppVersion}"); // Use the newer apphost // This emulates the case when: // 1) Newer runtime installed // 2) Newer runtime uninstalled (installer preserves newer apphost) File.Copy(sharedTestState.FixtureLatest.TestProject.AppExe, fixture.TestProject.AppExe, true); Command.Create(appExe) .EnvironmentVariable("COREHOST_TRACE", "1") .CaptureStdErr() .CaptureStdOut() .Execute() .Should() .Pass() .And .HaveStdOutContaining("Hello World") .And .HaveStdErrContaining($"--- Invoked apphost [version: {sharedTestState.FixtureLatest.RepoDirProvider.MicrosoftNETCoreAppVersion}"); // Use the newer apphost and hostFxr // This emulates the case when: // 1) Newer runtime installed // 2) A roll-forward to the newer runtime did not occur File.Copy(sharedTestState.FixtureLatest.TestProject.HostFxrDll, fixture.TestProject.HostFxrDll, true); Command.Create(appExe) .EnvironmentVariable("COREHOST_TRACE", "1") .CaptureStdErr() .CaptureStdOut() .Execute() .Should() .Pass() .And .HaveStdOutContaining("Hello World") .And .HaveStdErrContaining($"--- Invoked apphost [version: {sharedTestState.FixtureLatest.RepoDirProvider.MicrosoftNETCoreAppVersion}"); }
public void Multiple_SharedFxLookup_NetCoreApp_MinorRollForward_Wins_Over_UberFx() { var fixture = SharedFxLookupPortableAppFixture .Copy(); var dotnet = fixture.BuiltDotnet; var appDll = fixture.TestProject.AppDll; string runtimeConfig = Path.Combine(fixture.TestProject.OutputDirectory, "SharedFxLookupPortableApp.runtimeconfig.json"); SharedFramework.SetRuntimeConfigJson(runtimeConfig, "7777.0.0", null, useUberFramework: true); // Modify the Uber values SharedFramework.CreateUberFrameworkArtifacts(_builtSharedFxDir, _builtSharedUberFxDir, "0.0.0.1", "0.0.0.2"); // Add versions in the exe folders SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9999.1.0"); SharedFramework.AddAvailableSharedUberFxVersions(_builtSharedUberFxDir, _exeSharedUberFxBaseDir, "9999.0.0", "7777.0.0"); string uberFile = Path.Combine(_exeSharedUberFxBaseDir, "7777.0.0", "System.Collections.Immutable.dll"); string netCoreAppFile = Path.Combine(_exeSharedFxBaseDir, "9999.1.0", "System.Collections.Immutable.dll"); // The System.Collections.Immutable.dll is located in the UberFramework and NetCoreApp // Version: NetCoreApp 9999.0.0 // UberFramework 7777.0.0 // 'Roll forward on no candidate fx' enabled through config // Exe: NetCoreApp 9999.1.0 // UberFramework 7777.0.0 // Expected: 9999.1.0 // 7777.0.0 dotnet.Exec(appDll) .WorkingDirectory(_currentWorkingDir) .EnvironmentVariable("COREHOST_TRACE", "1") .CaptureStdOut() .CaptureStdErr() .Execute() .Should().Pass() .And.HaveStdErrContaining($"Replacing deps entry [{uberFile}, AssemblyVersion:0.0.0.1, FileVersion:0.0.0.2] with [{netCoreAppFile}"); }
public void SdkLookup_Global_Json_Single_Digit_Patch_Rollup() { var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture .Copy(); var dotnet = fixture.BuiltDotnet; // Set specified CLI version = 9999.3.4-global-dummy SetGlobalJsonVersion("SingleDigit-global.json"); // Add some dummy versions AddAvailableSdkVersions(_exeSdkBaseDir, "9999.4.1", "9999.3.4-dummy"); // Specified CLI version: 9999.3.4-global-dummy // CWD: empty // User: empty // 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() .Should() .Fail() .And .HaveStdErrContaining("A compatible SDK version for global.json version"); // Add specified CLI version AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.3"); // Specified CLI version: 9999.3.4-global-dummy // CWD: empty // User: empty // 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() .Should() .Fail() .And .HaveStdErrContaining("A compatible SDK version for global.json version"); // Add specified CLI version AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.4"); // Specified CLI version: 9999.3.4-global-dummy // CWD: empty // User: empty // 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 specified CLI version AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.5-dummy"); // Specified CLI 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 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 specified CLI version AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.600"); // Specified CLI 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 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 specified CLI version AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.4-global-dummy"); // Specified CLI 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 // 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) .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"); }
public void SharedMultilevelFxLookup_Must_Verify_Folders_in_the_Correct_Order() { if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { // Multi-level lookup is only supported on Windows. return; } var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture .Copy(); var dotnet = fixture.BuiltDotnet; var appDll = fixture.TestProject.AppDll; // Set desired version = 9999.0.0 string runtimeConfig = Path.Combine(fixture.TestProject.OutputDirectory, "SharedFxLookupPortableApp.runtimeconfig.json"); SharedFramework.SetRuntimeConfigJson(runtimeConfig, "9999.0.0"); // Add version in the reg dir SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _regSharedFxBaseDir, "9999.0.0"); // Version: 9999.0.0 // Cwd: empty // User: empty // Exe: empty // Reg: 9999.0.0 // Expected: 9999.0.0 from reg dir dotnet.Exec(appDll) .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .EnvironmentVariable("COREHOST_TRACE", "1") .EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1") .EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir) .CaptureStdOut() .CaptureStdErr() .Execute() .Should() .Pass() .And .HaveStdErrContaining(Path.Combine(_regSelectedMessage, "9999.0.0")); // Add a dummy version in the user dir SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _userSharedFxBaseDir, "9999.0.0"); // Version: 9999.0.0 // Cwd: empty // User: 9999.0.0 --> should not be picked // Exe: empty // Reg: 9999.0.0 // Expected: 9999.0.0 from reg dir dotnet.Exec(appDll) .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .EnvironmentVariable("COREHOST_TRACE", "1") .EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1") .EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir) .CaptureStdOut() .CaptureStdErr() .Execute() .Should() .Pass() .And .HaveStdErrContaining(Path.Combine(_regSelectedMessage, "9999.0.0")); // Add a dummy version in the cwd dir SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _cwdSharedFxBaseDir, "9999.0.0"); // Version: 9999.0.0 // Cwd: 9999.0.0 --> should not be picked // User: 9999.0.0 --> should not be picked // Exe: empty // Reg: 9999.0.0 // Expected: 9999.0.0 from reg dir dotnet.Exec(appDll) .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .EnvironmentVariable("COREHOST_TRACE", "1") .EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1") .EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir) .CaptureStdOut() .CaptureStdErr() .Execute() .Should() .Pass() .And .HaveStdErrContaining(Path.Combine(_regSelectedMessage, "9999.0.0")); // Add version in the exe dir SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9999.0.0"); // Version: 9999.0.0 // Cwd: 9999.0.0 --> should not be picked // User: 9999.0.0 --> should not be picked // Exe: 9999.0.0 // Reg: 9999.0.0 // Expected: 9999.0.0 from exe dir dotnet.Exec(appDll) .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .EnvironmentVariable("COREHOST_TRACE", "1") .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.0")); // Verify we have the expected runtime versions dotnet.Exec("--list-runtimes") .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .EnvironmentVariable("COREHOST_TRACE", "1") .EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1") .EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir) .CaptureStdOut() .CaptureStdErr() .Execute() .Should() .Pass() .And .HaveStdOutContaining("Microsoft.NETCore.App 9999.0.0"); }
public void SdkLookup_Must_Verify_Folders_in_the_Correct_Order() { var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture .Copy(); var dotnet = fixture.BuiltDotnet; // Add a dummy version in the exe dir AddAvailableSdkVersions(_exeSdkBaseDir, "9999.0.0-dummy"); // Specified CLI version: none // User: empty // Exe: 9999.0.0 // Expected: 9999.0.0 from exe dir dotnet.Exec("help") .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .Environment(s_DefaultEnvironment) .CaptureStdOut() .CaptureStdErr() .Execute() .Should() .Pass() .And .HaveStdErrContaining(_exeSelectedMessage); // Add a dummy version in the user dir AddAvailableSdkVersions(_userSdkBaseDir, "9999.0.0-dummy"); // Specified CLI version: none // CWD: empty // User: 9999.0.0 // Exe: 9999.0.0 // Expected: 9999.0.0 from user dir dotnet.Exec("help") .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .Environment(s_DefaultEnvironment) .CaptureStdOut() .CaptureStdErr() .Execute() .Should() .Pass() .And .HaveStdErrContaining(_userSelectedMessage); // Add a dummy version in the cwd AddAvailableSdkVersions(_cwdSdkBaseDir, "9999.0.0-dummy"); // Specified CLI version: none // CWD: 9999.0.0 --> should not be picked // User: 9999.0.0 // Exe: 9999.0.0 // Expected: 9999.0.0 from User dotnet.Exec("help") .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .Environment(s_DefaultEnvironment) .CaptureStdOut() .CaptureStdErr() .Execute() .Should() .Pass() .And .HaveStdErrContaining(_userSelectedMessage); // Remove dummy folders from user dir DeleteAvailableSdkVersions(_userSdkBaseDir, "9999.0.0-dummy"); }
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 SDK version = 9999.3.4-global-dummy SetGlobalJsonVersion("SingleDigit-global.json"); // 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", "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"); // Add SDK versions AddAvailableSdkVersions(_exeSdkBaseDir, "9999.4.1", "9999.3.4-dummy"); // 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", "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"); // Add SDK versions AddAvailableSdkVersions(_regSdkBaseDir, "9999.3.3"); // Specified SDK version: 9999.3.4-global-dummy // Cwd: empty // User: empty // 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", "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"); // Add SDK versions AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.4"); // Specified SDK version: 9999.3.4-global-dummy // Cwd: empty // User: empty // 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", "1") .EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir) .CaptureStdOut() .CaptureStdErr() .Execute() .Should() .Pass() .And .HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.3.4", _dotnetSdkDllMessageTerminator)); // Add SDK versions AddAvailableSdkVersions(_regSdkBaseDir, "9999.3.5-dummy"); // Specified SDK version: 9999.3.4-global-dummy // Cwd: empty // User: empty // 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", "1") .EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir) .CaptureStdOut() .CaptureStdErr() .Execute() .Should() .Pass() .And .HaveStdErrContaining(Path.Combine(_regSelectedMessage, "9999.3.5-dummy", _dotnetSdkDllMessageTerminator)); // Add SDK versions AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.600"); // Specified SDK version: 9999.3.4-global-dummy // Cwd: empty // User: empty // 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", "1") .EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir) .CaptureStdOut() .CaptureStdErr() .Execute() .Should() .Pass() .And .HaveStdErrContaining(Path.Combine(_regSelectedMessage, "9999.3.5-dummy", _dotnetSdkDllMessageTerminator)); // Add SDK versions AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.4-global-dummy"); // Specified SDK version: 9999.3.4-global-dummy // Cwd: empty // User: empty // 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", "1") .EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir) .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", "1") .EnvironmentVariable("_DOTNET_TEST_SDK_SELF_REGISTERED_DIR", _regDir) .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"); }
public void SharedFxLookup_Must_Verify_Folders_in_the_Correct_Order() { var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture .Copy(); var dotnet = fixture.BuiltDotnet; var appDll = fixture.TestProject.AppDll; // Set desired version = 9999.0.0 string runtimeConfig = Path.Combine(fixture.TestProject.OutputDirectory, "SharedFxLookupPortableApp.runtimeconfig.json"); SharedFramework.SetRuntimeConfigJson(runtimeConfig, "9999.0.0"); // Add version in the exe dir SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9999.0.0"); // Version: 9999.0.0 // User: empty // Exe: 9999.0.0 // Expected: 9999.0.0 from exe dir dotnet.Exec(appDll) .WorkingDirectory(_currentWorkingDir) .EnvironmentVariable("COREHOST_TRACE", "1") .WithUserProfile(_userDir) .CaptureStdOut() .CaptureStdErr() .Execute() .Should() .Pass() .And .HaveStdErrContaining(_exeSelectedMessage); // Add a dummy version in the user dir SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _userSharedFxBaseDir, "9999.0.0"); // Version: 9999.0.0 // User: 9999.0.0 --> should not be picked // Exe: 9999.0.0 // Expected: 9999.0.0 from user dir dotnet.Exec(appDll) .WorkingDirectory(_currentWorkingDir) .EnvironmentVariable("COREHOST_TRACE", "1") .WithUserProfile(_userDir) .CaptureStdOut() .CaptureStdErr() .Execute() .Should() .Pass() .And .HaveStdErrContaining(_exeSelectedMessage); // Add a dummy version in the cwd SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _cwdSharedFxBaseDir, "9999.0.0"); // Version: 9999.0.0 // CWD: 9999.0.0 --> should not be picked // User: 9999.0.0 // Exe: 9999.0.0 // Expected: 9999.0.0 from user Exe dotnet.Exec(appDll) .WorkingDirectory(_currentWorkingDir) .EnvironmentVariable("COREHOST_TRACE", "1") .WithUserProfile(_userDir) .CaptureStdOut() .CaptureStdErr() .Execute() .Should() .Pass() .And .HaveStdErrContaining(_exeSelectedMessage); // Verify we have the expected runtime versions dotnet.Exec("--list-runtimes") .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .CaptureStdOut() .Execute() .Should() .Pass() .And .HaveStdOutContaining("Microsoft.NETCore.App 9999.0.0"); }
public void SdkLookup_Global_Json_Patch_Rollup() { var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture .Copy(); var dotnet = fixture.BuiltDotnet; // Set specified CLI version = 9999.0.0-global-dummy SetGlobalJsonVersion(); // Add some dummy versions AddAvailableSdkVersions(_exeSdkBaseDir, "9999.0.1", "9999.0.0-dummy"); // Specified CLI version: 9999.0.0-global-dummy // CWD: empty // User: empty // Exe: 9999.0.1, 9999.0.0-dummy // Expected: 9999.0.1 from exe dir dotnet.Exec("help") .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .Environment(s_DefaultEnvironment) .CaptureStdOut() .CaptureStdErr() .Execute() .Should() .Pass() .And .HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.0.1", _dotnetSdkDllMessageTerminator)); // Add specified CLI version AddAvailableSdkVersions(_exeSdkBaseDir, "9999.0.4"); // Specified CLI version: 9999.0.0-global-dummy // CWD: empty // User: empty // Exe: 9999.0.1, 9999.0.0-dummy, 9999.0.4 // Expected: 9999.0.4 from exe dir dotnet.Exec("help") .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .Environment(s_DefaultEnvironment) .CaptureStdOut() .CaptureStdErr() .Execute() .Should() .Pass() .And .HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.0.4", _dotnetSdkDllMessageTerminator)); // Add specified CLI version AddAvailableSdkVersions(_exeSdkBaseDir, "9999.0.6-dummy"); // Specified CLI version: 9999.0.0-global-dummy // CWD: empty // User: empty // Exe: 9999.0.1, 9999.0.0-dummy, 9999.0.4, 9999.0.6-dummy // Expected: 9999.0.6-dummy from exe dir dotnet.Exec("help") .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .Environment(s_DefaultEnvironment) .CaptureStdOut() .CaptureStdErr() .Execute() .Should() .Pass() .And .HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.0.6-dummy", _dotnetSdkDllMessageTerminator)); // Add specified CLI version AddAvailableSdkVersions(_exeSdkBaseDir, "9999.0.0-global-dummy"); // Specified CLI version: 9999.0.0-global-dummy // CWD: empty // User: empty // Exe: 9999.0.1, 9999.0.0-dummy, 9999.0.4, 9999.0.6-dummy, 9999.0.0-global-dummy // Expected: 9999.0.0-global-dummy from exe dir dotnet.Exec("help") .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .Environment(s_DefaultEnvironment) .CaptureStdOut() .CaptureStdErr() .Execute() .Should() .Pass() .And .HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.0.0-global-dummy", _dotnetSdkDllMessageTerminator)); }
public void SharedFxLookup_Must_Verify_Folders_in_the_Correct_Order() { var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture .Copy(); var dotnet = fixture.BuiltDotnet; var appDll = fixture.TestProject.AppDll; // Set desired version = 9999.0.0 string runtimeConfig = Path.Combine(fixture.TestProject.OutputDirectory, "SharedFxLookupPortableApp.runtimeconfig.json"); SetRuntimeConfigJson(runtimeConfig, "9999.0.0"); // Add a dummy version in the exe dir AddAvailableSharedFxVersions(_exeSharedFxBaseDir, "9999.0.0"); // Version: 9999.0.0 // CWD: empty // User: empty // Exe: 9999.0.0 // Expected: 9999.0.0 from exe dir dotnet.Exec(appDll) .WorkingDirectory(_currentWorkingDir) .EnvironmentVariable("COREHOST_TRACE", "1") .CaptureStdOut() .CaptureStdErr() .Execute() .Should() .Pass() .And .HaveStdErrContaining(_exeSelectedMessage); // Add a dummy version in the user dir AddAvailableSharedFxVersions(_userSharedFxBaseDir, "9999.0.0"); // Version: 9999.0.0 // CWD: empty // User: 9999.0.0 // Exe: 9999.0.0 // Expected: 9999.0.0 from user dir dotnet.Exec(appDll) .WorkingDirectory(_currentWorkingDir) .EnvironmentVariable("COREHOST_TRACE", "1") .CaptureStdOut() .CaptureStdErr() .Execute() .Should() .Pass() .And .HaveStdErrContaining(_userSelectedMessage); // Add a dummy version in the cwd AddAvailableSharedFxVersions(_cwdSharedFxBaseDir, "9999.0.0"); // Version: 9999.0.0 // CWD: 9999.0.0 // User: 9999.0.0 // Exe: 9999.0.0 // Expected: 9999.0.0 from cwd dotnet.Exec(appDll) .WorkingDirectory(_currentWorkingDir) .EnvironmentVariable("COREHOST_TRACE", "1") .CaptureStdOut() .CaptureStdErr() .Execute() .Should() .Pass() .And .HaveStdErrContaining(_cwdSelectedMessage); // Remove dummy folders from user dir DeleteAvailableSharedFxVersions(_userSharedFxBaseDir, "9999.0.0"); }
public void SdkLookup_Global_Json_Single_Digit_Patch_Rollup() { var fixture = PortableAppFixture .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.HaveStdErrContaining("aka.ms/dotnet-download") .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"); }