public void SharedFx_With_Higher_Version_Wins_Against_App_On_NoRollForward()
        {
            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.0.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");
            // Use lower numbers for the app
            JObject versionInfo = new JObject();

            versionInfo.Add(new JProperty("assemblyVersion", "0.0.0.1"));
            versionInfo.Add(new JProperty("fileVersion", "0.0.0.2"));
            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.0.0
            // Expected: 9999.0.0
            //           7777.0.0
            // Expected: the framework's version of System.Collections.Immutable is used
            string uberAssembly = Path.Combine(_exeSharedUberFxBaseDir, "7777.0.0", "System.Collections.Immutable.dll");

            dotnet.Exec(appDll)
            .WorkingDirectory(_currentWorkingDir)
            .EnvironmentVariable("COREHOST_TRACE", "1")
            .CaptureStdOut()
            .CaptureStdErr()
            .Execute()
            .Should()
            .Pass()
            .And
            .HaveStdErrContaining($"Adding tpa entry: {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}");
        }
Example #2
0
        private static string CreateAdditionalDeps(string destDir, JObject immutableCollectionVersionInfo)
        {
            DirectoryInfo dir = new DirectoryInfo(destDir);

            if (dir.Exists)
            {
                dir.Delete(true);
            }

            dir.Create();

            JObject depsjson = SharedFramework.CreateDepsJson("Microsoft.NETCore.App", "LightupLib/1.0.0", "LightupLib");

            string depsFile = Path.Combine(destDir, "My.deps.json");

            File.WriteAllText(depsFile, depsjson.ToString());

            SharedFramework.AddReferenceToDepsJson(depsFile, "LightupLib/1.0.0", "System.Collections.Immutable", "1.0.0", immutableCollectionVersionInfo);
            SharedFramework.AddReferenceToDepsJson(depsFile, "LightupLib/1.0.0", "Newtonsoft.Json", "9.0.1");

            return(depsFile);
        }
        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);
        }
Example #4
0
        public void ComponentWithSameDependencyWithDifferentExtensionShouldFail()
        {
            var fixture          = sharedTestState.PreviouslyPublishedAndRestoredPortableApiTestProjectFixture.Copy();
            var componentFixture = sharedTestState.PreviouslyPublishedAndRestoredComponentWithDependenciesFixture.Copy();

            // Add a reference to another package which has asset with the same name as the existing ComponentDependency
            // but with a different extension. This causes a failure.
            SharedFramework.AddReferenceToDepsJson(
                componentFixture.TestProject.DepsJson,
                "ComponentWithDependencies/1.0.0",
                "ComponentDependency_Dupe",
                "1.0.0",
                testAssembly: "ComponentDependency.notdll");

            // Make sure the file exists so that we avoid failing due to missing file.
            File.Copy(
                Path.Combine(componentFixture.TestProject.OutputDirectory, "ComponentDependency.dll"),
                Path.Combine(componentFixture.TestProject.OutputDirectory, "ComponentDependency.notdll"));

            string[] args =
            {
                corehost_resolve_component_dependencies,
                componentFixture.TestProject.AppDll
            };
            fixture.BuiltDotnet.Exec(fixture.TestProject.AppDll, args)
            .CaptureStdOut().CaptureStdErr().EnvironmentVariable("COREHOST_TRACE", "1")
            .Execute()
            .StdErrAfter("corehost_resolve_component_dependencies = {")
            .Should().Pass()
            .And.HaveStdOutContaining("corehost_resolve_component_dependencies:Fail[0x8000808C]")
            .And.HaveStdOutContaining("corehost reported errors:")
            .And.HaveStdOutContaining("An assembly specified in the application dependencies manifest (ComponentWithDependencies.deps.json) has already been found but with a different file extension")
            .And.HaveStdOutContaining("package: 'ComponentDependency_Dupe', version: '1.0.0'")
            .And.HaveStdOutContaining("path: 'ComponentDependency.notdll'")
            .And.HaveStdOutContaining($"previously found assembly: '{Path.Combine(componentFixture.TestProject.OutputDirectory, "ComponentDependency.dll")}'");
        }
Example #5
0
        public void Muxer_activation_of_StartupHook_WithSimpleAssemblyName_Succeeds()
        {
            var fixture                 = sharedTestState.PortableAppFixture.Copy();
            var startupHookFixture      = sharedTestState.StartupHookFixture.Copy();
            var startupHookDll          = startupHookFixture.TestProject.AppDll;
            var startupHookAssemblyName = Path.GetFileNameWithoutExtension(startupHookDll);

            File.Copy(startupHookDll, Path.Combine(fixture.TestProject.BuiltApp.Location, Path.GetFileName(startupHookDll)));

            SharedFramework.AddReferenceToDepsJson(
                fixture.TestProject.DepsJson,
                $"{fixture.TestProject.AssemblyName}/1.0.0",
                startupHookAssemblyName,
                "1.0.0");

            fixture.BuiltDotnet.Exec(fixture.TestProject.AppDll)
            .EnvironmentVariable(startupHookVarName, startupHookAssemblyName)
            .CaptureStdOut()
            .CaptureStdErr()
            .Execute()
            .Should().Pass()
            .And.HaveStdOutContaining("Hello from startup hook!")
            .And.HaveStdOutContaining("Hello World");
        }