public void SharedFx_With_Higher_Version_Wins_Against_Additional_Deps() { var fixture = GlobalLightupClientFixture .Copy(); var fixtureLib = sharedTestState.LightupLibFixture_Published .Copy(); CopyLightupLib(fixture, fixtureLib); var dotnet = fixture.BuiltDotnet; var appDll = fixture.TestProject.AppDll; // Set desired version = 7777.0.0 string runtimeConfig = Path.Combine(fixture.TestProject.OutputDirectory, "LightupClient.runtimeconfig.json"); SharedFramework.SetRuntimeConfigJson(runtimeConfig, "7777.0.0", null, useUberFramework: true); // Add versions in the exe folder SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _fxBaseDir, "9999.0.0"); SharedFramework.AddAvailableSharedUberFxVersions(_builtSharedUberFxDir, _uberFxBaseDir, "9999.0.0", "7777.0.0"); // Copy NetCoreApp's copy of the assembly to the app location string netcoreAssembly = Path.Combine(_fxBaseDir, "9999.0.0", "System.Collections.Immutable.dll"); string appAssembly = Path.Combine(fixture.TestProject.OutputDirectory, "System.Collections.Immutable.dll"); File.Copy(netcoreAssembly, appAssembly); // Create a deps.json file in the folder "additionalDeps\shared\Microsoft.NETCore.App\9999.0.0" string additionalDepsRootPath = Path.Combine(_fxBaseDir, "additionalDeps"); JObject versionInfo = new JObject(); versionInfo.Add(new JProperty("assemblyVersion", "0.0.0.1")); versionInfo.Add(new JProperty("fileVersion", "0.0.0.2")); string additionalDepsPath = CreateAdditionalDeps(additionalDepsRootPath, versionInfo); // Version: NetCoreApp 9999.0.0 // UberFramework 7777.0.0 // Existing:NetCoreApp 9999.0.0 // UberFramework 7777.0.0 // Expected: 9999.0.0 // 7777.0.0 // Expected: the uber framework's version of System.Collections.Immutable is used instead of the additional-deps string uberAssembly = Path.Combine(_uberFxBaseDir, "7777.0.0", "System.Collections.Immutable.dll"); dotnet.Exec("exec", "--additional-deps", additionalDepsPath, appDll) .EnableTracingAndCaptureOutputs() .Execute() .Should().Pass() .And.HaveStdErrContaining($"Using specified additional deps.json: '{additionalDepsPath}'") .And.HaveStdErrContaining($"Adding tpa entry: {uberAssembly}") .And.HaveStdErrContaining($"Adding tpa entry: {appAssembly}") .And.HaveStdErrContaining($"Replacing deps entry [{appAssembly}") .And.HaveStdErrContaining($"with [{uberAssembly}, AssemblyVersion:{SystemCollectionsImmutableAssemblyVersion}, FileVersion:{SystemCollectionsImmutableFileVersion}]") // Verify final selection in TRUSTED_PLATFORM_ASSEMBLIES .And.HaveStdErrContaining($"{uberAssembly}{Path.PathSeparator}") .And.NotHaveStdErrContaining($"{appAssembly}{Path.PathSeparator}"); }
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"); }
public void SharedFx_Wins_Against_App_On_RollForward_And_Version_Tie() { var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture .Copy(); var dotnet = fixture.BuiltDotnet; var appDll = fixture.TestProject.AppDll; // Set desired version = 7777.0.0 string runtimeConfig = Path.Combine(fixture.TestProject.OutputDirectory, "SharedFxLookupPortableApp.runtimeconfig.json"); SharedFramework.SetRuntimeConfigJson(runtimeConfig, "7777.0.0", null, useUberFramework: true); // Add versions in the exe folder SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9999.0.0"); SharedFramework.AddAvailableSharedUberFxVersions(_builtSharedUberFxDir, _exeSharedUberFxBaseDir, "9999.0.0", null, "7777.1.0"); // Copy NetCoreApp's copy of the assembly to the app location string netcoreAssembly = Path.Combine(_exeSharedFxBaseDir, "9999.0.0", "System.Collections.Immutable.dll"); string appAssembly = Path.Combine(fixture.TestProject.OutputDirectory, "System.Collections.Immutable.dll"); File.Copy(netcoreAssembly, appAssembly); // Modify the app's deps.json to add System.Collections.Immmutable string appDepsJson = Path.Combine(fixture.TestProject.OutputDirectory, "SharedFxLookupPortableApp.deps.json"); JObject versionInfo = new JObject(); versionInfo.Add(new JProperty("assemblyVersion", SystemCollectionsImmutableAssemblyVersion)); versionInfo.Add(new JProperty("fileVersion", SystemCollectionsImmutableFileVersion)); SharedFramework.AddReferenceToDepsJson(appDepsJson, "SharedFxLookupPortableApp/1.0.0", "System.Collections.Immutable", "1.0.0", versionInfo); // Version: NetCoreApp 9999.0.0 // UberFramework 7777.0.0 // Exe: NetCoreApp 9999.0.0 // UberFramework 7777.1.0 // Expected: 9999.0.0 // 7777.1.0 // Expected: the framework's version of System.Collections.Immutable is used string uberAssembly = Path.Combine(_exeSharedUberFxBaseDir, "7777.1.0", "System.Collections.Immutable.dll"); dotnet.Exec(appDll) .WorkingDirectory(_currentWorkingDir) .EnvironmentVariable("COREHOST_TRACE", "1") .CaptureStdOut() .CaptureStdErr() .Execute() .Should() .Pass() .And .HaveStdErrContaining($"Replacing deps entry [{appAssembly}, AssemblyVersion:{SystemCollectionsImmutableAssemblyVersion}, FileVersion:{SystemCollectionsImmutableFileVersion}] with [{uberAssembly}, AssemblyVersion:{SystemCollectionsImmutableAssemblyVersion}, FileVersion:{SystemCollectionsImmutableFileVersion}]") .And // Verify final selection in TRUSTED_PLATFORM_ASSEMBLIES .HaveStdErrContaining($"{uberAssembly}{Path.PathSeparator}") .And .NotHaveStdErrContaining($"{netcoreAssembly}{Path.PathSeparator}") .And .NotHaveStdErrContaining($"{appAssembly}{Path.PathSeparator}"); }
public void Muxer_activation_of_LightupApp_WithLightupLib_and_Roll_Backwards_From_Prerelease_To_Release_Succeeds() { var fixtureLib = sharedTestState.LightupLibFixture_Published .Copy(); var fixtureApp = GlobalLightupClientFixture .Copy(); var dotnet = fixtureApp.BuiltDotnet; var appDll = fixtureApp.TestProject.AppDll; var libDepsJson = fixtureLib.TestProject.DepsJson; // Set desired version = 8888.0.0 string runtimeConfig = Path.Combine(fixtureApp.TestProject.OutputDirectory, "LightupClient.runtimeconfig.json"); SharedFramework.SetRuntimeConfigJson(runtimeConfig, "8888.0.5-preview1"); // Add versions in the exe folder SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _fxBaseDir, "8888.0.5-preview2"); CopyLightupLib(fixtureApp, fixtureLib); // Create the M.N.App specific folder where lightup.deps.json can be found. var baseDir = fixtureApp.TestProject.ProjectDirectory; var customLightupPath = Path.Combine(baseDir, "shared"); // Delete any existing artifacts if (Directory.Exists(customLightupPath)) { Directory.Delete(customLightupPath, true); } customLightupPath = Path.Combine(customLightupPath, "Microsoft.NETCore.App"); CreateLightupFolder(customLightupPath, $"8888.0.0", libDepsJson); CreateLightupFolder(customLightupPath, $"8888.0.4-preview", libDepsJson); // Closest backwards patch version (selected) CreateLightupFolder(customLightupPath, $"8888.0.4", libDepsJson); string selectedLightupPath = Path.Combine(customLightupPath, "8888.0.4"); CreateLightupFolder(customLightupPath, $"8888.0.5", libDepsJson); // Version targeted: NetCoreApp 8888.0.0-preview1 // Version existing: NetCoreApp 8888.0.5-preview2 // Lightup folders: 8888.0.0 // 8888.0.4-preview // 8888.0.4 // 8888.0.5 // Expected: 8888.0.4 dotnet.Exec("exec", "--additional-deps", baseDir, appDll) .EnableTracingAndCaptureOutputs() .Execute() .Should().Pass() .And.HaveStdOutContaining("Hello LightupClient") .And.HaveStdErrContaining($"Using specified additional deps.json: '{selectedLightupPath}"); }
public void Multiple_SharedFxLookup_Do_Not_Propagate() { var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture .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"); }
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"); }
public void Muxer_activation_of_LightupApp_WithLightupLib_and_Roll_Backwards_Fails() { var fixtureLib = PreviouslyPublishedAndRestoredLightupLibTestProjectFixture .Copy(); var fixtureApp = PreviouslyGlobalBuiltAndRestoredLightupAppTestProjectFixture .Copy(); var dotnet = fixtureApp.BuiltDotnet; var appDll = fixtureApp.TestProject.AppDll; var libDepsJson = fixtureLib.TestProject.DepsJson; // Set desired version = 8888.0.0 string runtimeConfig = Path.Combine(fixtureApp.TestProject.OutputDirectory, "LightupClient.runtimeconfig.json"); SharedFramework.SetRuntimeConfigJson(runtimeConfig, "8888.0.0"); // Add versions in the exe folder SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _fxBaseDir, "8888.0.1"); CopyLightupLib(fixtureApp, fixtureLib); // Create the M.N.App specific folder where lightup.deps.json can be found. var baseDir = fixtureApp.TestProject.ProjectDirectory; var customLightupPath = Path.Combine(baseDir, "shared"); // Delete any existing artifacts if (Directory.Exists(customLightupPath)) { Directory.Delete(customLightupPath, true); } customLightupPath = Path.Combine(customLightupPath, "Microsoft.NETCore.App"); CreateLightupFolder(customLightupPath, $"8887.0.0", libDepsJson); CreateLightupFolder(customLightupPath, $"8889.0.0", libDepsJson); // Version targeted: NetCoreApp 8888.0.0 // Version existing: NetCoreApp 8888.0.1 // Lightup folders: 8887.0.0 // 8889.0.0 // Expected: fail since we only roll backward on patch, not minor dotnet.Exec("exec", "--additional-deps", baseDir, appDll) .EnvironmentVariable("COREHOST_TRACE", "1") .CaptureStdErr() .CaptureStdOut() .Execute() .Should() .Fail() .And .HaveStdErrContaining($"No additional deps directory less than or equal to [8888.0.1] found with same major and minor version."); SharedFramework.DeleteAvailableSharedFxVersions(_fxBaseDir, "8888.0.1"); }
public void CoreClrLookup_WithNoDirectorySeparatorInDeps() { 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, "9999.0.0", null); // Add versions in the exe folders SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9999.0.0"); string sharedFxPath = Path.Combine(_exeSharedFxBaseDir, "9999.0.0"); string sharedFxDepsJsonPath = Path.Combine(sharedFxPath, "Microsoft.NETCore.App.deps.json"); // Modify the .deps.json for Microsoft.NETCore.App FX JObject root = JObject.Parse(File.ReadAllText(sharedFxDepsJsonPath)); IEnumerable <JProperty> netCoreAppNativeAssets = root["targets"] .Children <JProperty>().Where(p => p.Name.Contains("/")) .Children().Children().OfType <JProperty>().Where(p => p.Name.Contains("runtime") && p.Name.Contains("Microsoft.NETCore.App")) .Values()["native"].Children().OfType <JProperty>(); // Change the coreclr.dll asset to specify only "coreclr.dll" as the relative path (no directories). string coreClrLibraryName = RuntimeInformationExtensions.GetSharedLibraryFileNameForCurrentPlatform("coreclr"); JProperty coreClrProperty = netCoreAppNativeAssets.First(p => p.Name.Contains(coreClrLibraryName)); JProperty newCoreClrProperty = new JProperty(coreClrProperty.Name.Substring(coreClrProperty.Name.LastIndexOf('/') + 1), coreClrProperty.Value); coreClrProperty.Parent.Add(newCoreClrProperty); coreClrProperty.Remove(); // Change the clrjit.dll asset to specify only "clrjit.dll" as the relative path (no directories). string clrJitLibraryName = RuntimeInformationExtensions.GetSharedLibraryFileNameForCurrentPlatform("clrjit"); JProperty clrJitProperty = netCoreAppNativeAssets.First(p => p.Name.Contains(clrJitLibraryName)); JProperty newClrJitProperty = new JProperty(clrJitProperty.Name.Substring(clrJitProperty.Name.LastIndexOf('/') + 1), clrJitProperty.Value); clrJitProperty.Parent.Add(newClrJitProperty); clrJitProperty.Remove(); File.WriteAllText(sharedFxDepsJsonPath, root.ToString()); dotnet.Exec(appDll) .WorkingDirectory(_currentWorkingDir) .EnvironmentVariable("COREHOST_TRACE", "1") .CaptureStdOut() .CaptureStdErr() .Execute() .Should().Pass() .And.HaveStdErrContaining($"CoreCLR path = '{Path.Combine(sharedFxPath, coreClrLibraryName)}'") .And.HaveStdErrContaining($"The resolved JIT path is '{Path.Combine(sharedFxPath, clrJitLibraryName)}'"); }
public void Roll_Forward_On_No_Candidate_Fx_Fails_If_No_Higher_Version_Is_Available() { var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture .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"); }
public void Multiple_Fx_References_Can_Roll_Forward_With_Retry() { var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture .Copy(); var dotnet = fixture.BuiltDotnet; var appDll = fixture.TestProject.AppDll; string runtimeConfig = Path.Combine(fixture.TestProject.OutputDirectory, "SharedFxLookupPortableApp.runtimeconfig.json"); var additionalfxs = new JArray(); additionalfxs.Add(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'"); }
public void Multiple_Fx_References_Can_Roll_Forward_Without_Retry() { var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture .Copy(); var dotnet = fixture.BuiltDotnet; var appDll = fixture.TestProject.AppDll; string runtimeConfig = Path.Combine(fixture.TestProject.OutputDirectory, "SharedFxLookupPortableApp.runtimeconfig.json"); var additionalfxs = new JArray(); additionalfxs.Add(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"); }
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"); }
public void Additional_Deps_Lightup_Folder_With_Bad_JsonFile() { var fixture = PreviouslyGlobalBuiltAndRestoredLightupAppTestProjectFixture .Copy(); var fixtureLib = PreviouslyPublishedAndRestoredLightupLibTestProjectFixture .Copy(); CopyLightupLib(fixture, fixtureLib); var dotnet = fixture.BuiltDotnet; var appDll = fixture.TestProject.AppDll; // Add version in the exe folder SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _fxBaseDir, "9999.0.0"); // Set desired version = 9999.0.0 string runtimeConfig = Path.Combine(fixture.TestProject.OutputDirectory, "LightupClient.runtimeconfig.json"); SharedFramework.SetRuntimeConfigJson(runtimeConfig, "9999.0.0"); string additionalDepsRootPath = Path.Combine(_fxBaseDir, "additionalDeps"); // Create a deps.json file in the folder "additionalDeps\shared\Microsoft.NETCore.App\9999.0.0" string additionalDepsPath = Path.Combine(additionalDepsRootPath, "shared", "Microsoft.NETCore.App", "9999.0.0", "myAddtionalDeps.deps.json"); FileInfo additionalDepsFile = new FileInfo(additionalDepsPath); additionalDepsFile.Directory.Create(); File.WriteAllText(additionalDepsFile.FullName, "THIS IS A BAD JSON FILE"); // Expected: a parsing error since the json file is bad. dotnet.Exec("exec", "--additional-deps", additionalDepsRootPath, appDll) .EnvironmentVariable("COREHOST_TRACE", "1") .CaptureStdOut() .CaptureStdErr() .Execute() .Should() .Fail() .And .HaveStdErrContaining($"Error initializing the dependency resolver: An error occurred while parsing: {additionalDepsPath}"); SharedFramework.DeleteAvailableSharedFxVersions(_fxBaseDir, "9999.0.0", "additionalDeps"); }
public void Multiple_SharedFxLookup_NetCoreApp_MinorRollForward_Wins_Over_UberFx() { var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture .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}"); }
private TestProjectFixture ConfigureAppAndFrameworks(string appAssemblyVersion, string uberFxAssemblyVersion, string uberFxProductVersion, out string appAssembly, out string uberAssembly, out string netcoreAssembly) { const string fileVersion = "0.0.0.9"; var fixture = SharedFxLookupPortableAppFixture .Copy(); if (!string.IsNullOrEmpty(uberFxAssemblyVersion)) { // Modify Uber Fx's deps.json SharedFramework.CreateUberFrameworkArtifacts(_builtSharedFxDir, _builtSharedUberFxDir, uberFxAssemblyVersion, fileVersion); } // Set desired version = 7777.0.0 string runtimeConfig = Path.Combine(fixture.TestProject.OutputDirectory, "SharedFxLookupPortableApp.runtimeconfig.json"); SharedFramework.SetRuntimeConfigJson(runtimeConfig, "7777.0.0", null, useUberFramework: true); // Add versions in the exe folder SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9999.0.0"); SharedFramework.AddAvailableSharedUberFxVersions(_builtSharedUberFxDir, _exeSharedUberFxBaseDir, "9999.0.0", uberFxProductVersion); // Copy NetCoreApp's copy of the assembly to the app location netcoreAssembly = Path.Combine(_exeSharedFxBaseDir, "9999.0.0", "System.Collections.Immutable.dll"); appAssembly = Path.Combine(fixture.TestProject.OutputDirectory, "System.Collections.Immutable.dll"); File.Copy(netcoreAssembly, appAssembly); // Modify the app's deps.json to add System.Collections.Immmutable string appDepsJson = Path.Combine(fixture.TestProject.OutputDirectory, "SharedFxLookupPortableApp.deps.json"); JObject versionInfo = new JObject(); versionInfo.Add(new JProperty("assemblyVersion", appAssemblyVersion)); versionInfo.Add(new JProperty("fileVersion", fileVersion)); SharedFramework.AddReferenceToDepsJson(appDepsJson, "SharedFxLookupPortableApp/1.0.0", "System.Collections.Immutable", "1.0.0", versionInfo); uberAssembly = Path.Combine(_exeSharedUberFxBaseDir, uberFxProductVersion, "System.Collections.Immutable.dll"); return(fixture); }
public void Multiple_Fx_References_Cant_Roll_Forward_Because_Incompatible_Config() { var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture .Copy(); var dotnet = fixture.BuiltDotnet; var appDll = fixture.TestProject.AppDll; string runtimeConfig = Path.Combine(fixture.TestProject.OutputDirectory, "SharedFxLookupPortableApp.runtimeconfig.json"); var additionalfxs = new JArray(); additionalfxs.Add(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"); }
public void Multiple_SharedFxLookup_Propagated_Additional_Framework_RuntimeConfig_Values() { var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture .Copy(); var dotnet = fixture.BuiltDotnet; var appDll = fixture.TestProject.AppDll; string runtimeConfig = Path.Combine(fixture.TestProject.OutputDirectory, "SharedFxLookupPortableApp.runtimeconfig.json"); var additionalfxs = new JArray(); additionalfxs.Add(GetAdditionalFramework("Microsoft.NETCore.App", "9999.1.0", applyPatches: false, rollForwardOnNoCandidateFx: 0)); SharedFramework.SetRuntimeConfigJson(runtimeConfig, "7777.0.0", null, useUberFramework: true, additionalFrameworks: additionalfxs); // Add versions in the exe folders SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9999.1.0"); SharedFramework.AddAvailableSharedUberFxVersions(_builtSharedUberFxDir, _exeSharedUberFxBaseDir, "9999.5.5", "UberValue", "7777.0.0"); // Version: NetCoreApp 9999.5.5 (in framework section) // NetCoreApp 9999.1.0 (in app's additionalFrameworks section) // UberFramework 7777.0.0 // 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(Path.Combine(_exeSelectedMessage, "9999.1.0")) .And .HaveStdErrContaining(Path.Combine(_exeFoundUberFxMessage, "7777.0.0")); // Change the additionalFrameworks to allow roll forward, overriding Uber's global section and ignoring Uber's framework section additionalfxs.Clear(); additionalfxs.Add(GetAdditionalFramework("Microsoft.NETCore.App", "9999.0.0", applyPatches: false, rollForwardOnNoCandidateFx: 1)); additionalfxs.Add(GetAdditionalFramework("UberFx", "7777.0.0", applyPatches: false, rollForwardOnNoCandidateFx: 0)); SharedFramework.SetRuntimeConfigJson(runtimeConfig, "7777.0.0", rollFwdOnNoCandidateFx: 0, useUberFramework: true, additionalFrameworks: additionalfxs); // Version: NetCoreApp 9999.5.5 (in framework section) // NetCoreApp 9999.0.0 (in app's additionalFrameworks section) // UberFramework 7777.0.0 // UberFramework 7777.0.0 (in app's additionalFrameworks section) // 'Roll forward on no candidate fx' disabled through env var // 'Roll forward on no candidate fx' disabled through Uber's global runtimeconfig // 'Roll forward on no candidate fx' enabled for NETCore.App enabled through additionalFrameworks section // 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") .EnvironmentVariable("DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX", "0") .CaptureStdOut() .CaptureStdErr() .Execute() .Should() .Pass() .And .HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.1.0")) .And .HaveStdErrContaining(Path.Combine(_exeFoundUberFxMessage, "7777.0.0")); // Same as previous except use of '--roll-forward-on-no-candidate-fx' // Expected: Fail since '--roll-forward-on-no-candidate-fx' should apply to all layers dotnet.Exec( "exec", "--roll-forward-on-no-candidate-fx", "0", appDll) .WorkingDirectory(_currentWorkingDir) .EnvironmentVariable("COREHOST_TRACE", "1") .EnvironmentVariable("DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX", "1") .CaptureStdOut() .CaptureStdErr() .Execute(fExpectedToFail: true) .Should() .Fail() .And .HaveStdErrContaining("It was not possible to find any compatible framework version"); }
public void Multiple_SharedFxLookup_Independent_Roll_Forward() { var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture .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", null, "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 .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", null, "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"); }
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 SharedFx_With_Lower_Version_Loses_Against_Additional_Deps() { var fixture = PreviouslyGlobalBuiltAndRestoredLightupAppTestProjectFixture .Copy(); var fixtureLib = PreviouslyPublishedAndRestoredLightupLibTestProjectFixture .Copy(); CopyLightupLib(fixture, fixtureLib); var dotnet = fixture.BuiltDotnet; var appDll = fixture.TestProject.AppDll; // Set desired version = 7777.0.0 string runtimeConfig = Path.Combine(fixture.TestProject.OutputDirectory, "LightupClient.runtimeconfig.json"); SharedFramework.SetRuntimeConfigJson(runtimeConfig, "7777.0.0", null, useUberFramework: true); // Add versions in the exe folder SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _fxBaseDir, "9999.0.0"); SharedFramework.AddAvailableSharedUberFxVersions(_builtSharedUberFxDir, _uberFxBaseDir, "9999.0.0", null, "7777.0.0"); // Copy NetCoreApp's copy of the assembly to the app location string netcoreAssembly = Path.Combine(_fxBaseDir, "9999.0.0", "System.Collections.Immutable.dll"); string appAssembly = Path.Combine(fixture.TestProject.OutputDirectory, "System.Collections.Immutable.dll"); File.Copy(netcoreAssembly, appAssembly); // Create a deps.json file in the folder "additionalDeps\shared\Microsoft.NETCore.App\9999.0.0" string additionalDepsRootPath = Path.Combine(_fxBaseDir, "additionalDeps"); JObject versionInfo = new JObject(); // Use Higher version numbers to win versionInfo.Add(new JProperty("assemblyVersion", "99.9.9.9")); versionInfo.Add(new JProperty("fileVersion", "98.9.9.9")); string additionalDepsPath = CreateAdditionalDeps(additionalDepsRootPath, versionInfo); // Version: NetCoreApp 9999.0.0 // UberFramework 7777.0.0 // Existing:NetCoreApp 9999.0.0 // UberFramework 7777.0.0 // Expected: 9999.0.0 // 7777.0.0 // Expected: the additional dep's version of System.Collections.Immutable is used instead of the uber's assembly string uberAssembly = Path.Combine(_uberFxBaseDir, "7777.0.0", "System.Collections.Immutable.dll"); dotnet.Exec("exec", "--additional-deps", additionalDepsPath, appDll) .EnvironmentVariable("COREHOST_TRACE", "1") .CaptureStdOut() .CaptureStdErr() .Execute() .Should() .Pass() .And .HaveStdErrContaining($"Using specified additional deps.json: '{additionalDepsPath}'") .And .HaveStdErrContaining($"Adding tpa entry: {uberAssembly}") .And .HaveStdErrContaining($"Adding tpa entry: {appAssembly}") .And .HaveStdErrContaining($"Replacing deps entry [{uberAssembly}, AssemblyVersion:{SystemCollectionsImmutableAssemblyVersion}, FileVersion:{SystemCollectionsImmutableFileVersion}] with [{appAssembly}, AssemblyVersion:99.9.9.9, FileVersion:98.9.9.9]"); SharedFramework.DeleteAvailableSharedFxVersions(_fxBaseDir, "9999.0.0", "additionalDeps"); SharedFramework.DeleteAvailableSharedFxVersions(_uberFxBaseDir, "7777.0.0"); }
public void Roll_Forward_On_No_Candidate_Fx_Minor_And_Disabled() { 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 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"); // 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")); // 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"); }
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 Roll_Forward_On_No_Candidate_Fx_Production_To_Preview() { 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 preview version in the exe SharedFramework.AddAvailableSharedFxVersions(_builtSharedFxDir, _exeSharedFxBaseDir, "9999.1.1-dummy1"); // Version: 9999.0.0 // 'Roll forward on no candidate fx' default value of 1 (minor) // exe: 9999.1.1-dummy1 // Expected: 9999.1.1-dummy1 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-dummy1")); // 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-dummy1") .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"); }