From b04d8e7a21dfe1fd87e0da90fc03c2534d770bdd Mon Sep 17 00:00:00 2001 From: Vitek Karas Date: Thu, 11 Apr 2019 02:43:16 -0700 Subject: [PATCH] Remove test duplicates (dotnet/core-setup#5729) Adde some test variants to better covered what the removed tests covered. Commit migrated from https://github.com/dotnet/core-setup/commit/fa51624c4e17fb9f46686c9c599cdedb3dbd1779 --- src/installer/corehost/cli/hostpolicy/args.cpp | 1 - .../FrameworkResolution/FrameworkResolutionBase.cs | 16 +- .../FrameworkResolution/MultipleHives.cs | 20 + .../RollForwardOnNoCandidateFx.cs | 35 + ...RollForwardOnNoCandidateFxMultipleFrameworks.cs | 28 + .../test/HostActivationTests/SharedFxLookup.cs | 829 +-------------------- 6 files changed, 101 insertions(+), 828 deletions(-) diff --git a/src/installer/corehost/cli/hostpolicy/args.cpp b/src/installer/corehost/cli/hostpolicy/args.cpp index ae17526..3855be1 100644 --- a/src/installer/corehost/cli/hostpolicy/args.cpp +++ b/src/installer/corehost/cli/hostpolicy/args.cpp @@ -22,7 +22,6 @@ arguments_t::arguments_t() * Setup the shared store directories. * * o %DOTNET_SHARED_STORE% -- multiple delimited paths - * o $HOME/.dotnet/{x86|x64}/store/arch/tfm or %USERPROFILE%\.dotnet\{x86|x64}\store\\ * o dotnet.exe relative shared store\\ * o Global location * Windows: C:\Program Files (x86) or diff --git a/src/installer/test/HostActivationTests/FrameworkResolution/FrameworkResolutionBase.cs b/src/installer/test/HostActivationTests/FrameworkResolution/FrameworkResolutionBase.cs index 0f2f252..312078f 100644 --- a/src/installer/test/HostActivationTests/FrameworkResolution/FrameworkResolutionBase.cs +++ b/src/installer/test/HostActivationTests/FrameworkResolution/FrameworkResolutionBase.cs @@ -42,6 +42,7 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution public Func RuntimeConfigCustomizer { get; set; } public IDictionary Environment { get; set; } public IEnumerable CommandLine { get; set; } + public string WorkingDirectory { get; set; } public TestSettings WithRuntimeConfigCustomizer(Func customizer) { @@ -72,6 +73,12 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution return this; } + public TestSettings WithWorkingDirectory(string path) + { + WorkingDirectory = path; + return this; + } + public TestSettings With(Func modifier) { return modifier(this); @@ -92,7 +99,14 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution settings.WithCommandLine(app.AppDll); - CommandResult result = dotnet.Exec(settings.CommandLine.First(), settings.CommandLine.Skip(1).ToArray()) + Command command = dotnet.Exec(settings.CommandLine.First(), settings.CommandLine.Skip(1).ToArray()); + + if (settings.WorkingDirectory != null) + { + command = command.WorkingDirectory(settings.WorkingDirectory); + } + + CommandResult result = command .EnvironmentVariable("COREHOST_TRACE", "1") .EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", multiLevelLookup ? "1" : "0") .Environment(settings.Environment) diff --git a/src/installer/test/HostActivationTests/FrameworkResolution/MultipleHives.cs b/src/installer/test/HostActivationTests/FrameworkResolution/MultipleHives.cs index f74b526..87f941d 100644 --- a/src/installer/test/HostActivationTests/FrameworkResolution/MultipleHives.cs +++ b/src/installer/test/HostActivationTests/FrameworkResolution/MultipleHives.cs @@ -38,6 +38,20 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution "6.1.2"); } + [Fact] + public void FrameworkHiveSelection_CurrentDirectoryIsIgnored() + { + RunTest( + SharedState.DotNetMainHive, + SharedState.FrameworkReferenceApp, + new TestSettings() + .WithRuntimeConfigCustomizer(runtimeConfig => runtimeConfig + .WithFramework(MicrosoftNETCoreApp, "5.0.0")) + .WithWorkingDirectory(SharedState.DotNetCurrentHive.BinPath), + result => result.Should().Pass() + .And.HaveResolvedFramework(MicrosoftNETCoreApp, "5.2.0")); + } + private void RunTest( Func runtimeConfig, string resolvedFramework = null) @@ -79,6 +93,8 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution public DotNetCli DotNetGlobalHive { get; } + public DotNetCli DotNetCurrentHive { get; } + public SharedTestState() { DotNetMainHive = DotNet("MainHive") @@ -91,6 +107,10 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution .AddMicrosoftNETCoreAppFramework("6.2.0") .Build(); + DotNetCurrentHive = DotNet("CurrentHive") + .AddMicrosoftNETCoreAppFramework("5.1.0") + .Build(); + FrameworkReferenceApp = CreateFrameworkReferenceApp(); } } diff --git a/src/installer/test/HostActivationTests/FrameworkResolution/RollForwardOnNoCandidateFx.cs b/src/installer/test/HostActivationTests/FrameworkResolution/RollForwardOnNoCandidateFx.cs index cc2c3d2..3bbd2b7 100644 --- a/src/installer/test/HostActivationTests/FrameworkResolution/RollForwardOnNoCandidateFx.cs +++ b/src/installer/test/HostActivationTests/FrameworkResolution/RollForwardOnNoCandidateFx.cs @@ -347,6 +347,8 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution // - Microsoft.NETCore.App 4.1.2 // - Microsoft.NETCore.App 4.1.3-preview.1 // - Microsoft.NETCore.App 4.2.1 + // - Microsoft.NETCore.App 4.5.1-preview.1 + // - Microsoft.NETCore.App 4.5.2 // - Microsoft.NETCore.App 5.1.3-preview.1 // - Microsoft.NETCore.App 5.1.3-preview.2 // - Microsoft.NETCore.App 5.1.4-preview.1 @@ -409,6 +411,37 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution } [Theory] + [InlineData(null, null, "4.5.2")] + [InlineData(null, false, "4.5.2")] + [InlineData(0, null, null)] + [InlineData(0, false, null)] + [InlineData(1, null, "4.5.2")] + [InlineData(1, false, "4.5.2")] + [InlineData(2, null, "4.5.2")] + [InlineData(2, false, "4.5.2")] + public void RollForwardOnMinor_RollOverPreRelease(int? rollForwardOnNoCandidateFx, bool? applyPatches, string resolvedVersion) + { + RunTestWithManyVersions( + runtimeConfig => runtimeConfig + .WithRollForwardOnNoCandidateFx(rollForwardOnNoCandidateFx) + .WithApplyPatches(applyPatches) + .WithFramework(MicrosoftNETCoreApp, "4.4.0"), + commandResult => + { + if (resolvedVersion != null) + { + commandResult.Should().Pass() + .And.HaveResolvedFramework(MicrosoftNETCoreApp, resolvedVersion); + } + else + { + commandResult.Should().Fail() + .And.DidNotFindCompatibleFrameworkVersion(); + } + }); + } + + [Theory] [InlineData(null, null, null)] [InlineData(null, false, null)] [InlineData(0, null, null)] @@ -732,6 +765,8 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution .AddMicrosoftNETCoreAppFramework("4.1.2") .AddMicrosoftNETCoreAppFramework("4.1.3-preview.1") .AddMicrosoftNETCoreAppFramework("4.2.1") + .AddMicrosoftNETCoreAppFramework("4.5.1-preview.1") + .AddMicrosoftNETCoreAppFramework("4.5.2") .AddMicrosoftNETCoreAppFramework("5.1.3-preview.1") .AddMicrosoftNETCoreAppFramework("5.1.3-preview.2") .AddMicrosoftNETCoreAppFramework("5.1.4-preview.1") diff --git a/src/installer/test/HostActivationTests/FrameworkResolution/RollForwardOnNoCandidateFxMultipleFrameworks.cs b/src/installer/test/HostActivationTests/FrameworkResolution/RollForwardOnNoCandidateFxMultipleFrameworks.cs index 3c15236..b3577f0 100644 --- a/src/installer/test/HostActivationTests/FrameworkResolution/RollForwardOnNoCandidateFxMultipleFrameworks.cs +++ b/src/installer/test/HostActivationTests/FrameworkResolution/RollForwardOnNoCandidateFxMultipleFrameworks.cs @@ -395,6 +395,34 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution .And.HaveResolvedFramework(MicrosoftNETCoreApp, "5.6.0")); } + [Fact] + public void RollForwardOnAllFrameworks() + { + RunTest( + runtimeConfig => runtimeConfig + .WithFramework(MiddleWare, "2.0.0") + .WithFramework(HighWare, "7.0.0") + .WithFramework(MicrosoftNETCoreApp, "5.0.0"), + dotnetCustomizer => + { + dotnetCustomizer.Framework(MiddleWare).RuntimeConfig(runtimeConfig => + runtimeConfig.GetFramework(MicrosoftNETCoreApp) + .Version = "5.0.0"); + dotnetCustomizer.Framework(HighWare).RuntimeConfig(runtimeConfig => + { + runtimeConfig.GetFramework(MiddleWare) + .Version = "2.0.0"; + runtimeConfig.GetFramework(MicrosoftNETCoreApp) + .Version = "5.0.0"; + }); + }, + resultValidator: commandResult => + commandResult.Should().Pass() + .And.HaveResolvedFramework(MicrosoftNETCoreApp, "5.1.3") + .And.HaveResolvedFramework(MiddleWare, "2.1.2") + .And.HaveResolvedFramework(HighWare, "7.3.1")); + } + private void RunTest( Func runtimeConfig, Action customizeDotNet = null, diff --git a/src/installer/test/HostActivationTests/SharedFxLookup.cs b/src/installer/test/HostActivationTests/SharedFxLookup.cs index 1a05cc3..63390d4 100644 --- a/src/installer/test/HostActivationTests/SharedFxLookup.cs +++ b/src/installer/test/HostActivationTests/SharedFxLookup.cs @@ -20,28 +20,15 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation private readonly TestProjectFixture SharedFxLookupPortableAppFixture; private readonly string _currentWorkingDir; - private readonly string _userDir; private readonly string _executableDir; - private readonly string _globalDir; - private readonly string _cwdSharedFxBaseDir; - private readonly string _cwdSharedUberFxBaseDir; - private readonly string _userSharedFxBaseDir; - private readonly string _userSharedUberFxBaseDir; private readonly string _exeSharedFxBaseDir; private readonly string _exeSharedUberFxBaseDir; - private readonly string _globalSharedFxBaseDir; - private readonly string _globalSharedUberFxBaseDir; private readonly string _builtSharedFxDir; private readonly string _builtSharedUberFxDir; - private readonly string _exeSelectedMessage; - - private readonly string _exeFoundUberFxMessage; - private readonly string _sharedFxVersion; private readonly string _baseDir; private readonly string _builtDotnet; - private readonly string _hostPolicyDllName; public SharedFxLookup() { @@ -55,43 +42,23 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation string baseDir = Path.Combine(artifactsDir, "dotnetSharedFxLookup"); _baseDir = SharedFramework.CalculateUniqueTestDirectory(baseDir); - // The three tested locations will be the cwd, the user folder and the exe dir. Both cwd and exe dir - // are easily overwritten, so they will be placed inside the multilevel folder. The actual user location will - // be used during tests + // The two tested locations will be the cwd and the exe dir. Both cwd and exe dir + // are easily overwritten, so they will be placed inside the multilevel folder. _currentWorkingDir = Path.Combine(_baseDir, "cwd"); - _userDir = Path.Combine(_baseDir, "user"); _executableDir = Path.Combine(_baseDir, "exe"); - _globalDir = Path.Combine(_baseDir, "global"); RepoDirectories = new RepoDirectoriesProvider(builtDotnet: _executableDir); // SharedFxBaseDirs contain all available version folders - _cwdSharedFxBaseDir = Path.Combine(_currentWorkingDir, "shared", "Microsoft.NETCore.App"); - _userSharedFxBaseDir = Path.Combine(_userDir, ".dotnet", RepoDirectories.BuildArchitecture, "shared", "Microsoft.NETCore.App"); _exeSharedFxBaseDir = Path.Combine(_executableDir, "shared", "Microsoft.NETCore.App"); - _globalSharedFxBaseDir = Path.Combine(_globalDir, "shared", "Microsoft.NETCore.App"); - _cwdSharedUberFxBaseDir = Path.Combine(_currentWorkingDir, "shared", "Microsoft.UberFramework"); - _userSharedUberFxBaseDir = Path.Combine(_userDir, ".dotnet", RepoDirectories.BuildArchitecture, "shared", "Microsoft.UberFramework"); _exeSharedUberFxBaseDir = Path.Combine(_executableDir, "shared", "Microsoft.UberFramework"); - _globalSharedUberFxBaseDir = Path.Combine(_globalDir, "shared", "Microsoft.UberFramework"); // Create directories. 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 - Directory.CreateDirectory(_cwdSharedFxBaseDir); - Directory.CreateDirectory(_userSharedFxBaseDir); - Directory.CreateDirectory(_globalSharedFxBaseDir); - Directory.CreateDirectory(_cwdSharedUberFxBaseDir); - Directory.CreateDirectory(_userSharedUberFxBaseDir); - Directory.CreateDirectory(_globalSharedUberFxBaseDir); + Directory.CreateDirectory(_currentWorkingDir); SharedFramework.CopyDirectory(_builtDotnet, _executableDir); - //Copy dotnet to global directory - File.Copy( - Path.Combine(_builtDotnet, RuntimeInformationExtensions.GetExeFileNameForCurrentPlatform("dotnet")), - Path.Combine(_globalDir, RuntimeInformationExtensions.GetExeFileNameForCurrentPlatform("dotnet")), - true); - // Restore and build SharedFxLookupPortableApp from exe dir SharedFxLookupPortableAppFixture = new TestProjectFixture("SharedFxLookupPortableApp", RepoDirectories) .EnsureRestored(RepoDirectories.CorehostPackages) @@ -105,12 +72,6 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation _builtSharedFxDir = Path.Combine(_builtDotnet, "shared", "Microsoft.NETCore.App", _sharedFxVersion); _builtSharedUberFxDir = Path.Combine(_builtDotnet, "shared", "Microsoft.UberFramework", _sharedFxVersion); SharedFramework.CreateUberFrameworkArtifacts(_builtSharedFxDir, _builtSharedUberFxDir, SystemCollectionsImmutableAssemblyVersion, SystemCollectionsImmutableFileVersion); - - // Trace messages used to identify from which folder the framework was picked - _hostPolicyDllName = Path.GetFileName(fixture.TestProject.HostPolicyDll); - _exeSelectedMessage = $"The expected {_hostPolicyDllName} directory is [{_exeSharedFxBaseDir}"; - - _exeFoundUberFxMessage = $"Chose FX version [{_exeSharedUberFxBaseDir}"; } public void Dispose() @@ -124,768 +85,6 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation } [Fact] - public void SharedFxLookup_Must_Verify_Folders_in_the_Correct_Order() - { - var fixture = SharedFxLookupPortableAppFixture - .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"); - } - - [Fact] - public void SharedFxLookup_Must_Not_Roll_Forward_If_Framework_Version_Is_Specified_Through_Argument() - { - var fixture = SharedFxLookupPortableAppFixture - .Copy(); - - var dotnet = fixture.BuiltDotnet; - var appDll = fixture.TestProject.AppDll; - - // Add some dummy versions - SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9999.0.0", "9999.0.2", "9999.0.0-dummy2", "9999.0.3", "9999.0.0-dummy3"); - - // Version: 9999.0.0 (through --fx-version arg) - // Exe: 9999.0.2, 9999.0.0-dummy2, 9999.0.0, 9999.0.3, 9999.0.0-dummy3 - // global: empty - // Expected: 9999.0.0 from exe dir - dotnet.Exec("--fx-version", "9999.0.0", appDll) - .WorkingDirectory(_currentWorkingDir) - .EnvironmentVariable("COREHOST_TRACE", "1") - .CaptureStdOut() - .CaptureStdErr() - .Execute() - .Should().Pass() - .And.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.0.0")); - - // Version: 9999.0.0-dummy1 (through --fx-version arg) - // Exe: 9999.0.2, 9999.0.0-dummy2,9999.0.0, 9999.0.3, 9999.0.0-dummy3 - // global: empty - // Expected: no compatible version - dotnet.Exec("--fx-version", "9999.0.0-dummy1", appDll) - .WorkingDirectory(_currentWorkingDir) - .EnvironmentVariable("COREHOST_TRACE", "1") - .CaptureStdOut() - .CaptureStdErr() - .Execute(fExpectedToFail: true) - .Should().Fail() - .And.HaveStdErrContaining("It was not possible to find any compatible framework version"); - - // Verify we have the expected runtime versions - dotnet.Exec("--list-runtimes") - .WorkingDirectory(_currentWorkingDir) - .CaptureStdOut() - .Execute() - .Should().Pass() - .And.HaveStdOutContaining("Microsoft.NETCore.App 9999.0.0") - .And.HaveStdOutContaining("Microsoft.NETCore.App 9999.0.0-dummy2") - .And.HaveStdOutContaining("Microsoft.NETCore.App 9999.0.2") - .And.HaveStdOutContaining("Microsoft.NETCore.App 9999.0.3") - .And.HaveStdOutContaining("Microsoft.NETCore.App 9999.0.0-dummy3"); - } - - [Fact] - public void Roll_Forward_On_No_Candidate_Fx_Must_Happen_If_Compatible_Patch_Version_Is_Not_Available() - { - var fixture = SharedFxLookupPortableAppFixture - .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 some dummy versions in the exe - SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "10000.1.1", "10000.1.3"); - - // Version: 9999.0.0 - // 'Roll forward on no candidate fx' enabled with value 2 (major+minor) through env var - // exe: 10000.1.1, 10000.1.3 - // Expected: 10000.1.3 from exe - dotnet.Exec(appDll) - .WorkingDirectory(_currentWorkingDir) - .EnvironmentVariable("DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX", "2") - .EnvironmentVariable("COREHOST_TRACE", "1") - .CaptureStdOut() - .CaptureStdErr() - .Execute() - .Should().Pass() - .And.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "10000.1.3")); - - // Add a dummy version in the exe dir - SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9999.1.1"); - - // Version: 9999.0.0 - // 'Roll forward on no candidate fx' enabled with value 2 (major+minor) through env var - // exe: 9999.1.1, 10000.1.1, 10000.1.3 - // Expected: 9999.1.1 from exe - dotnet.Exec(appDll) - .WorkingDirectory(_currentWorkingDir) - .EnvironmentVariable("DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX", "2") - .EnvironmentVariable("COREHOST_TRACE", "1") - .CaptureStdOut() - .CaptureStdErr() - .Execute() - .Should().Pass() - .And.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.1.1")) - .And.HaveStdOutContaining("Framework Version:9999.1.1"); - - // Verify we have the expected runtime versions - dotnet.Exec("--list-runtimes") - .WorkingDirectory(_currentWorkingDir) - .CaptureStdOut() - .Execute() - .Should().Pass() - .And.HaveStdOutContaining("Microsoft.NETCore.App 9999.1.1") - .And.HaveStdOutContaining("Microsoft.NETCore.App 10000.1.1") - .And.HaveStdOutContaining("Microsoft.NETCore.App 10000.1.3"); - } - - [Fact] - public void Roll_Forward_On_No_Candidate_Fx_Minor_And_Disabled() - { - var fixture = SharedFxLookupPortableAppFixture - .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 some dummy versions in the exe - SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "10000.1.1"); - - // Version: 9999.0.0 - // 'Roll forward on no candidate fx' default value of 1 (minor) - // exe: 10000.1.1 - // Expected: fail with no framework - dotnet.Exec(appDll) - .WorkingDirectory(_currentWorkingDir) - .EnvironmentVariable("COREHOST_TRACE", "1") - .CaptureStdOut() - .CaptureStdErr() - .Execute(fExpectedToFail: true) - .Should().Fail() - .And.HaveStdErrContaining("It was not possible to find any compatible framework version") - .And.HaveStdErrContaining("aka.ms/dotnet-download"); - - // Add a dummy version in the exe dir - SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9999.1.1"); - - // Version: 9999.0.0 - // 'Roll forward on no candidate fx' default value of 1 (minor) - // exe: 9999.1.1, 10000.1.1 - // Expected: 9999.1.1 from exe - dotnet.Exec(appDll) - .WorkingDirectory(_currentWorkingDir) - .EnvironmentVariable("COREHOST_TRACE", "1") - .CaptureStdOut() - .CaptureStdErr() - .Execute() - .Should().Pass() - .And.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.1.1")) - .And.HaveStdOutContaining("Framework Version:9999.1.1"); - - // Version: 9999.0.0 - // 'Roll forward on no candidate fx' disabled through env var - // exe: 9999.1.1, 10000.1.1 - // Expected: fail with no framework - dotnet.Exec(appDll) - .WorkingDirectory(_currentWorkingDir) - .EnvironmentVariable("COREHOST_TRACE", "1") - .EnvironmentVariable("DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX", "0") - .CaptureStdOut() - .CaptureStdErr() - .Execute(fExpectedToFail: true) - .Should().Fail() - .And.HaveStdErrContaining("It was not possible to find any compatible framework version"); - - // Verify we have the expected runtime versions - dotnet.Exec("--list-runtimes") - .WorkingDirectory(_currentWorkingDir) - .CaptureStdOut() - .Execute() - .Should().Pass() - .And.HaveStdOutContaining("Microsoft.NETCore.App 9999.1.1") - .And.HaveStdOutContaining("Microsoft.NETCore.App 10000.1.1"); - } - - [Fact] - public void Roll_Forward_On_No_Candidate_Fx_Production_To_Preview() - { - var fixture = SharedFxLookupPortableAppFixture - .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 preview version in the exe - SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9999.1.1-dummy.9"); - - // Version: 9999.0.0 - // 'Roll forward on no candidate fx' default value of 1 (minor) - // exe: 9999.1.1-dummy.9 - // Expected: 9999.1.1-dummy.9 since there is no production version - dotnet.Exec(appDll) - .WorkingDirectory(_currentWorkingDir) - .EnvironmentVariable("COREHOST_TRACE", "1") - .CaptureStdOut() - .CaptureStdErr() - .Execute() - .Should().Pass() - .And.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.1.1-dummy.9")); - - // Add preview version in the exe - SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9999.1.1-dummy.8"); - - // Version: 9999.0.0 - // 'Roll forward on no candidate fx' default value of 1 (minor) - // exe: 9999.1.1-dummy.8, 9999.1.1-dummy.9 - // Expected: 9999.1.1-dummy.9 since there is no production version and latest preview should be selected - dotnet.Exec(appDll) - .WorkingDirectory(_currentWorkingDir) - .EnvironmentVariable("COREHOST_TRACE", "1") - .CaptureStdOut() - .CaptureStdErr() - .Execute() - .Should().Pass() - .And.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.1.1-dummy.9")); - - // Add preview version in the exe - SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9999.1.1-dummy.10"); - - // Version: 9999.0.0 - // 'Roll forward on no candidate fx' default value of 1 (minor) - // exe: 9999.1.1-dummy.8, 9999.1.1-dummy.9, 9999.1.1-dummy.10 - // Expected: 9999.1.1-dummy.10 since there is no production version and latest preview should be selected - dotnet.Exec(appDll) - .WorkingDirectory(_currentWorkingDir) - .EnvironmentVariable("COREHOST_TRACE", "1") - .CaptureStdOut() - .CaptureStdErr() - .Execute() - .Should().Pass() - .And.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.1.1-dummy.10")); - - // Add a production version with higher value - SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9999.2.1"); - - // Version: 9999.0.0 - // 'Roll forward on no candidate fx' default value of 1 (minor) - // exe: 9999.1.1-dummy1, 9999.2.1 - // Expected: 9999.2.1 since we favor production over preview - dotnet.Exec(appDll) - .WorkingDirectory(_currentWorkingDir) - .EnvironmentVariable("COREHOST_TRACE", "1") - .CaptureStdOut() - .CaptureStdErr() - .Execute() - .Should().Pass() - .And.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.2.1")); - - // Add a preview version with same major.minor as production - SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9999.2.1-dummy1"); - - // Version: 9999.0.0 - // 'Roll forward on no candidate fx' default value of 1 (minor) - // exe: 9999.1.1-dummy1, 9999.2.1, 9999.2.1-dummy1 - // Expected: 9999.2.1 since we favor production over preview - dotnet.Exec(appDll) - .WorkingDirectory(_currentWorkingDir) - .EnvironmentVariable("COREHOST_TRACE", "1") - .CaptureStdOut() - .CaptureStdErr() - .Execute() - .Should().Pass() - .And.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.2.1")); - - // Add a preview version with same major.minor as production but higher patch version - SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9999.2.2-dummy1"); - - // Version: 9999.0.0 - // 'Roll forward on no candidate fx' default value of 1 (minor) - // exe: 9999.1.1-dummy1, 9999.2.1, 9999.2.1-dummy1, 9999.2.2-dummy1 - // Expected: 9999.2.1 since we favor production over preview - dotnet.Exec(appDll) - .WorkingDirectory(_currentWorkingDir) - .EnvironmentVariable("COREHOST_TRACE", "1") - .CaptureStdOut() - .CaptureStdErr() - .Execute() - .Should().Pass() - .And.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.2.1")); - - // Verify we have the expected runtime versions - dotnet.Exec("--list-runtimes") - .WorkingDirectory(_currentWorkingDir) - .CaptureStdOut() - .Execute() - .Should().Pass() - .And.HaveStdOutContaining("Microsoft.NETCore.App 9999.1.1-dummy.8") - .And.HaveStdOutContaining("Microsoft.NETCore.App 9999.1.1-dummy.9") - .And.HaveStdOutContaining("Microsoft.NETCore.App 9999.1.1-dummy.10") - .And.HaveStdOutContaining("Microsoft.NETCore.App 9999.2.1") - .And.HaveStdOutContaining("Microsoft.NETCore.App 9999.2.1-dummy1") - .And.HaveStdOutContaining("Microsoft.NETCore.App 9999.2.2-dummy1"); - } - - [Fact] - public void Roll_Forward_On_No_Candidate_Fx_Preview_To_Production() - { - var fixture = SharedFxLookupPortableAppFixture - .Copy(); - - var dotnet = fixture.BuiltDotnet; - var appDll = fixture.TestProject.AppDll; - - // Set desired version = 9999.0.0-dummy1 - string runtimeConfig = Path.Combine(fixture.TestProject.OutputDirectory, "SharedFxLookupPortableApp.runtimeconfig.json"); - SharedFramework.SetRuntimeConfigJson(runtimeConfig, "9999.0.0-dummy1"); - - // Add dummy versions in the exe - SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9999.0.0", "9999.0.1-dummy1"); - - // Version: 9999.0.0-dummy1 - // exe: 9999.0.0, 9999.0.1-dummy1 - // Expected: fail since we don't roll forward unless match on major.minor.patch and never roll forward to production - dotnet.Exec(appDll) - .WorkingDirectory(_currentWorkingDir) - .EnvironmentVariable("COREHOST_TRACE", "1") - .CaptureStdOut() - .CaptureStdErr() - .Execute(fExpectedToFail: true) - .Should().Fail() - .And.HaveStdErrContaining("It was not possible to find any compatible framework version"); - - // Add preview versions in the exe with name major.minor.patch - SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9999.0.0-dummy2", "9999.0.0-dummy3"); - - // Version: 9999.0.0-dummy1 - // exe: 9999.0.0-dummy2, 9999.0.0-dummy3, 9999.0.0, 9999.0.1-dummy1 - // Expected: 9999.0.0-dummy2 - dotnet.Exec(appDll) - .WorkingDirectory(_currentWorkingDir) - .EnvironmentVariable("COREHOST_TRACE", "1") - .CaptureStdOut() - .CaptureStdErr() - .Execute() - .Should().Pass() - .And.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.0.0-dummy2")) - .And.HaveStdOutContaining("Framework Version:9999.0.0-dummy2"); - - // Verify we have the expected runtime versions - dotnet.Exec("--list-runtimes") - .WorkingDirectory(_currentWorkingDir) - .CaptureStdOut() - .Execute() - .Should().Pass() - .And.HaveStdOutContaining("9999.0.0-dummy2") - .And.HaveStdOutContaining("9999.0.0-dummy3") - .And.HaveStdOutContaining("9999.0.0") - .And.HaveStdOutContaining("9999.0.1-dummy1"); - } - - [Fact] - public void Roll_Forward_On_No_Candidate_Fx_Fails_If_No_Higher_Version_Is_Available() - { - var fixture = SharedFxLookupPortableAppFixture - .Copy(); - - var dotnet = fixture.BuiltDotnet; - var appDll = fixture.TestProject.AppDll; - - // Set desired version = 9999.1.1 - string runtimeConfig = Path.Combine(fixture.TestProject.OutputDirectory, "SharedFxLookupPortableApp.runtimeconfig.json"); - SharedFramework.SetRuntimeConfigJson(runtimeConfig, "9999.1.1"); - - // Add some dummy versions in the exe - SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9998.0.1", "9998.1.0", "9999.0.0", "9999.0.1", "9999.1.0"); - - // Version: 9999.1.1 - // exe: 9998.0.1, 9998.1.0, 9999.0.0, 9999.0.1, 9999.1.0 - // Expected: no compatible version - dotnet.Exec(appDll) - .WorkingDirectory(_currentWorkingDir) - .EnvironmentVariable("COREHOST_TRACE", "1") - .CaptureStdOut() - .CaptureStdErr() - .Execute(fExpectedToFail: true) - .Should().Fail() - .And.HaveStdErrContaining("It was not possible to find any compatible framework version"); - - // Verify we have the expected runtime versions - dotnet.Exec("--list-runtimes") - .WorkingDirectory(_currentWorkingDir) - .CaptureStdOut() - .Execute() - .Should().Pass() - .And.HaveStdOutContaining("Microsoft.NETCore.App 9998.0.1") - .And.HaveStdOutContaining("Microsoft.NETCore.App 9998.1.0") - .And.HaveStdOutContaining("Microsoft.NETCore.App 9999.0.0") - .And.HaveStdOutContaining("Microsoft.NETCore.App 9999.0.1") - .And.HaveStdOutContaining("Microsoft.NETCore.App 9999.1.0"); - } - - [Fact] - public void Multiple_SharedFxLookup_Independent_Roll_Forward() - { - 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); - - // Add versions in the exe folders - SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9999.0.0"); - SharedFramework.AddAvailableSharedUberFxVersions(_builtSharedUberFxDir, _exeSharedUberFxBaseDir, "9999.0.0", "7777.0.0"); - - // Version: NetCoreApp 9999.0.0 - // UberFramework 7777.0.0 - // Exe: NetCoreApp 9999.0.0 - // UberFramework 7777.0.0 - // Expected: 9999.0.0 - // 7777.0.0 - dotnet.Exec(appDll) - .WorkingDirectory(_currentWorkingDir) - .EnvironmentVariable("COREHOST_TRACE", "1") - .CaptureStdOut() - .CaptureStdErr() - .Execute() - .Should().Pass() - .And.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.0.0")) - .And.HaveStdOutContaining("Framework Version:9999.0.0") - .And.HaveStdErrContaining(Path.Combine(_exeFoundUberFxMessage, "7777.0.0")); - - // Add a newer version to verify roll-forward - SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9999.0.1"); - SharedFramework.AddAvailableSharedUberFxVersions(_builtSharedUberFxDir, _exeSharedUberFxBaseDir, "9999.0.0", "7777.0.1"); - - // Version: NetCoreApp 9999.0.0 - // UberFramework 7777.0.0 - // Exe: NetCoreApp 9999.0.0, 9999.0.1 - // UberFramework 7777.0.0, 7777.0.1 - // Expected: 9999.0.1 - // 7777.0.1 - dotnet.Exec(appDll) - .WorkingDirectory(_currentWorkingDir) - .EnvironmentVariable("COREHOST_TRACE", "1") - .CaptureStdOut() - .CaptureStdErr() - .Execute() - .Should().Pass() - .And.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.0.1")) - .And.HaveStdErrContaining(Path.Combine(_exeFoundUberFxMessage, "7777.0.1")); - - // 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") - .And.HaveStdOutContaining("Microsoft.NETCore.App 9999.0.1") - .And.HaveStdOutContaining("Microsoft.UberFramework 7777.0.0") - .And.HaveStdOutContaining("Microsoft.UberFramework 7777.0.1"); - } - - [Fact] - public void Multiple_SharedFxLookup_Do_Not_Propagate() - { - 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); - - // Add versions in the exe folders - SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9999.1.0"); - SharedFramework.AddAvailableSharedUberFxVersions(_builtSharedUberFxDir, _exeSharedUberFxBaseDir, "9999.0.0", "7777.0.0"); - - // Version: NetCoreApp 9999.0.0 - // UberFramework 7777.0.0 - // 'Roll forward on no candidate fx' disabled through env var - // Exe: NetCoreApp 9999.1.0 - // UberFramework 7777.0.0 - // Expected: no compatible version - dotnet.Exec(appDll) - .WorkingDirectory(_currentWorkingDir) - .EnvironmentVariable("COREHOST_TRACE", "1") - .EnvironmentVariable("DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX", "0") - .CaptureStdOut() - .CaptureStdErr() - .Execute(fExpectedToFail: true) - .Should().Fail() - .And.HaveStdErrContaining("It was not possible to find any compatible framework version"); - - // Enable rollForwardOnNoCandidateFx on app's config, which will not be used as the default for Uber's config - SharedFramework.SetRuntimeConfigJson(runtimeConfig, "7777.0.0", rollFwdOnNoCandidateFx: 1, useUberFramework: true); - - // 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: no compatible version - dotnet.Exec(appDll) - .WorkingDirectory(_currentWorkingDir) - .EnvironmentVariable("COREHOST_TRACE", "1") - .EnvironmentVariable("DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX", "0") - .CaptureStdOut() - .CaptureStdErr() - .Execute(fExpectedToFail: true) - .Should().Fail() - .And.HaveStdErrContaining("It was not possible to find any compatible framework version"); - } - - [Fact] - public void Multiple_Fx_References_Cant_Roll_Forward_Because_Incompatible_Config() - { - var fixture = SharedFxLookupPortableAppFixture - .Copy(); - - var dotnet = fixture.BuiltDotnet; - var appDll = fixture.TestProject.AppDll; - - string runtimeConfig = Path.Combine(fixture.TestProject.OutputDirectory, "SharedFxLookupPortableApp.runtimeconfig.json"); - - var additionalfxs = new JArray - { - GetAdditionalFramework("Microsoft.NETCore.App", "9999.1.0", applyPatches: false, rollForwardOnNoCandidateFx: 0) - }; - SharedFramework.SetRuntimeConfigJson(runtimeConfig, "7777.0.0", null, useUberFramework: true, frameworks: additionalfxs); - - // Add versions in the exe folders - SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9999.1.0", "9999.5.5"); - SharedFramework.AddAvailableSharedUberFxVersions(_builtSharedUberFxDir, _exeSharedUberFxBaseDir, "9999.5.5", "7777.0.0"); - - // Verify that both 9999.1.0 and 9999.5.5 can't be selected with roll-forward disabled - // Version: NetCoreApp 9999.5.5 (in framework section) - // NetCoreApp 9999.1.0 (in frameworks section) - // UberFramework 7777.0.0 - // Exe: NetCoreApp 9999.1.0 rollForwardOnNoCandidateFx:0 applyPatches:false - // NetCoreApp 9999.5.5 - // UberFramework 7777.0.0 - // Expected: no compatible version - dotnet.Exec(appDll) - .WorkingDirectory(_currentWorkingDir) - .EnvironmentVariable("COREHOST_TRACE", "1") - .CaptureStdOut() - .CaptureStdErr() - .Execute(fExpectedToFail: true) - .Should().Fail() - .And.HaveStdErrContaining("cannot roll-forward to the previously referenced version '9999.5.5"); - } - - [Fact] - public void Multiple_Fx_References_Can_Roll_Forward_Without_Retry() - { - var fixture = SharedFxLookupPortableAppFixture - .Copy(); - - var dotnet = fixture.BuiltDotnet; - var appDll = fixture.TestProject.AppDll; - - string runtimeConfig = Path.Combine(fixture.TestProject.OutputDirectory, "SharedFxLookupPortableApp.runtimeconfig.json"); - - var additionalfxs = new JArray - { - GetAdditionalFramework("Microsoft.NETCore.App", "9999.1.1", applyPatches: false, rollForwardOnNoCandidateFx: 1) - }; - SharedFramework.SetRuntimeConfigJson(runtimeConfig, "7777.0.0", null, useUberFramework: true, frameworks: additionalfxs); - - // Add versions in the exe folders - SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9999.1.0", "9999.5.5"); - SharedFramework.AddAvailableSharedUberFxVersions(_builtSharedUberFxDir, _exeSharedUberFxBaseDir, "9999.5.5", "7777.0.0"); - - // Version: NetCoreApp 9999.5.5 (in framework section) - // NetCoreApp 9999.1.0 (in frameworks section) - // UberFramework 7777.0.0 - // Exe: NetCoreApp 9999.1.0 rollForwardOnNoCandidateFx:1 applyPatches:false - // NetCoreApp 9999.5.5 - // UberFramework 7777.0.0 - // Expected: 9999.5.5 - // 7777.0.0 - dotnet.Exec(appDll) - .WorkingDirectory(_currentWorkingDir) - .EnvironmentVariable("COREHOST_TRACE", "1") - .CaptureStdOut() - .CaptureStdErr() - .Execute() - .Should().Pass() - .And.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.5.5")) - .And.HaveStdOutContaining("Framework Version:9999.5.5") - .And.HaveStdErrContaining(Path.Combine(_exeFoundUberFxMessage, "7777.0.0")) - .And.NotHaveStdErrContaining("Restarting all framework resolution"); - } - - [Fact] - public void Multiple_Fx_References_Can_Roll_Forward_With_Retry() - { - var fixture = SharedFxLookupPortableAppFixture - .Copy(); - - var dotnet = fixture.BuiltDotnet; - var appDll = fixture.TestProject.AppDll; - - string runtimeConfig = Path.Combine(fixture.TestProject.OutputDirectory, "SharedFxLookupPortableApp.runtimeconfig.json"); - - var additionalfxs = new JArray - { - GetAdditionalFramework("Microsoft.UberFramework", "7777.0.0", null, null) - }; - // Specify Uber as additional fx so we find NetCoreApp 9999.1.1 and then need to do a re-try for 9999.5.5 - SharedFramework.SetRuntimeConfigJson(runtimeConfig, "9999.1.1", null, null, frameworks: additionalfxs); - - // Add versions in the exe folders - SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9999.1.1", "9999.5.5"); - SharedFramework.AddAvailableSharedUberFxVersions(_builtSharedUberFxDir, _exeSharedUberFxBaseDir, "9999.5.5", "7777.0.0"); - - // Version: NetCoreApp 9999.1.1 (in framework section) - // UberFramework 7777.0.0 (in frameworks section) - // NetCoreApp 9999.5.5 (in uber's config) - // Exe: NetCoreApp 9999.1.1 - // NetCoreApp 9999.5.5 - // UberFramework 7777.0.0 - // Expected: 9999.5.5 - // 7777.0.0 - dotnet.Exec(appDll) - .WorkingDirectory(_currentWorkingDir) - .EnvironmentVariable("COREHOST_TRACE", "1") - .CaptureStdOut() - .CaptureStdErr() - .Execute() - .Should().Pass() - .And.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.5.5")) - .And.HaveStdOutContaining("Framework Version:9999.5.5") - .And.HaveStdErrContaining(Path.Combine(_exeFoundUberFxMessage, "7777.0.0")) - .And.HaveStdErrContaining("Restarting all framework resolution because the previously resolved framework 'Microsoft.NETCore.App', version '9999.1.1' must be re-resolved with the new version '9999.5.5'"); - } - - [Fact] - public void Multiple_Fx_References_Cant_Roll_Forward_Because_Disabled_Through_CommandLine() - { - var fixture = SharedFxLookupPortableAppFixture - .Copy(); - - var dotnet = fixture.BuiltDotnet; - var appDll = fixture.TestProject.AppDll; - - string runtimeConfig = Path.Combine(fixture.TestProject.OutputDirectory, "SharedFxLookupPortableApp.runtimeconfig.json"); - - var additionalfxs = new JArray - { - GetAdditionalFramework("Microsoft.NETCore.App", "9999.1.1", applyPatches: false, rollForwardOnNoCandidateFx: 1) - }; - SharedFramework.SetRuntimeConfigJson(runtimeConfig, "7777.0.0", null, useUberFramework: true, frameworks: additionalfxs); - - // Add versions in the exe folders - SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9999.1.0", "9999.5.5"); - SharedFramework.AddAvailableSharedUberFxVersions(_builtSharedUberFxDir, _exeSharedUberFxBaseDir, "9999.5.5", "7777.0.0"); - - // Version: NetCoreApp 9999.5.5 (in framework section) - // NetCoreApp 9999.1.0 (in frameworks section) - // UberFramework 7777.0.0 - // Exe: NetCoreApp 9999.1.0 rollForwardOnNoCandidateFx:1 applyPatches:false - // NetCoreApp 9999.5.5 - // UberFramework 7777.0.0 - // --roll-forward-on-no-candidate-fx=0 should override config settings - // Expected: 9999.5.5 - // 7777.0.0 - - dotnet.Exec( - "exec", - "--roll-forward-on-no-candidate-fx", "0", - appDll) - .WorkingDirectory(_currentWorkingDir) - .EnvironmentVariable("COREHOST_TRACE", "1") - .CaptureStdOut() - .CaptureStdErr() - .Execute(fExpectedToFail: true) - .Should().Fail() - .And.HaveStdErrContaining("cannot roll-forward to the previously referenced version '9999.5.5"); - } - - [Fact] public void Multiple_SharedFxLookup_NetCoreApp_MinorRollForward_Wins_Over_UberFx() { var fixture = SharedFxLookupPortableAppFixture @@ -1009,27 +208,5 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation .And.HaveStdErrContaining($"CoreCLR path = '{Path.Combine(sharedFxPath, coreClrLibraryName)}'") .And.HaveStdErrContaining($"The resolved JIT path is '{Path.Combine(sharedFxPath, clrJitLibraryName)}'"); } - - static private JObject GetAdditionalFramework(string fxName, string fxVersion, bool? applyPatches, int? rollForwardOnNoCandidateFx) - { - var jobject = new JObject(new JProperty("name", fxName)); - - if (fxVersion != null) - { - jobject.Add(new JProperty("version", fxVersion)); - } - - if (applyPatches.HasValue) - { - jobject.Add(new JProperty("applyPatches", applyPatches.Value)); - } - - if (rollForwardOnNoCandidateFx.HasValue) - { - jobject.Add(new JProperty("rollForwardOnNoCandidateFx", rollForwardOnNoCandidateFx)); - } - - return jobject; - } } } -- 2.7.4