Beispiel #1
0
        public LightupAppActivation(LightupAppActivation.SharedTestState fixture)
        {
            sharedTestState = fixture;

            // From the artifacts dir, it's possible to find where the sharedFrameworkPublish folder is. We need
            // to locate it because we'll copy its contents into other folders
            string artifactsDir = new RepoDirectoriesProvider().GetTestContextVariable("TEST_ARTIFACTS");
            string builtDotnet  = Path.Combine(artifactsDir, "sharedFrameworkPublish");

            // The dotnetLightupSharedFxLookup dir will contain some folders and files that will be necessary to perform the tests
            string sharedLookupDir = Path.Combine(artifactsDir, "dotnetLightupSharedFxLookup");

            _baseDirArtifact = new TestArtifact(SharedFramework.CalculateUniqueTestDirectory(sharedLookupDir));
            _fxBaseDir       = Path.Combine(_baseDirArtifact.Location, "shared", "Microsoft.NETCore.App");
            _uberFxBaseDir   = Path.Combine(_baseDirArtifact.Location, "shared", "Microsoft.UberFramework");

            SharedFramework.CopyDirectory(builtDotnet, _baseDirArtifact.Location);

            var repoDirectories = new RepoDirectoriesProvider(builtDotnet: _baseDirArtifact.Location);

            GlobalLightupClientFixture = new TestProjectFixture("LightupClient", repoDirectories)
                                         .EnsureRestored()
                                         .BuildProject();

            string greatestVersionSharedFxPath = sharedTestState.LightupLibFixture_Built.BuiltDotnet.GreatestVersionSharedFxPath;
            string sharedFxVersion             = (new DirectoryInfo(greatestVersionSharedFxPath)).Name;

            _builtSharedFxDir     = Path.Combine(builtDotnet, "shared", "Microsoft.NETCore.App", sharedFxVersion);
            _builtSharedUberFxDir = Path.Combine(builtDotnet, "shared", "Microsoft.UberFramework", sharedFxVersion);
            SharedFramework.CreateUberFrameworkArtifacts(_builtSharedFxDir, _builtSharedUberFxDir, SystemCollectionsImmutableAssemblyVersion, SystemCollectionsImmutableFileVersion);
        }
        public GivenThatICareAboutLightupAppActivation()
        {
            // From the artifacts dir, it's possible to find where the sharedFrameworkPublish folder is. We need
            // to locate it because we'll copy its contents into other folders
            string artifactsDir = Environment.GetEnvironmentVariable("TEST_ARTIFACTS");

            _builtDotnet = Path.Combine(artifactsDir, "sharedFrameworkPublish");

            // The dotnetLightupSharedFxLookup dir will contain some folders and files that will be necessary to perform the tests
            string sharedLookupDir = Path.Combine(artifactsDir, "dotnetLightupSharedFxLookup");

            _currentWorkingDir = SharedFramework.CalculateUniqueTestDirectory(sharedLookupDir);
            _fxBaseDir         = Path.Combine(_currentWorkingDir, "shared", "Microsoft.NETCore.App");
            _uberFxBaseDir     = Path.Combine(_currentWorkingDir, "shared", "Microsoft.UberFramework");

            SharedFramework.CopyDirectory(_builtDotnet, _currentWorkingDir);

            var repoDirectories = new RepoDirectoriesProvider(builtDotnet: _currentWorkingDir);

            PreviouslyGlobalBuiltAndRestoredLightupAppTestProjectFixture = new TestProjectFixture("LightupClient", repoDirectories)
                                                                           .EnsureRestored(RepoDirectories.CorehostPackages)
                                                                           .BuildProject();

            string greatestVersionSharedFxPath = PreviouslyBuiltAndRestoredLightupLibTestProjectFixture.BuiltDotnet.GreatestVersionSharedFxPath;
            string sharedFxVersion             = (new DirectoryInfo(greatestVersionSharedFxPath)).Name;

            _builtSharedFxDir     = Path.Combine(_builtDotnet, "shared", "Microsoft.NETCore.App", sharedFxVersion);
            _builtSharedUberFxDir = Path.Combine(_builtDotnet, "shared", "Microsoft.UberFramework", sharedFxVersion);
            SharedFramework.CreateUberFrameworkArtifacts(_builtSharedFxDir, _builtSharedUberFxDir, SystemCollectionsImmutableAssemblyVersion, SystemCollectionsImmutableFileVersion);
        }
Beispiel #3
0
        public SharedFxLookup()
        {
            // From the artifacts dir, it's possible to find where the sharedFrameworkPublish folder is. We need
            // to locate it because we'll copy its contents into other folders
            string artifactsDir = new RepoDirectoriesProvider().GetTestContextVariable("TEST_ARTIFACTS");

            _builtDotnet = Path.Combine(artifactsDir, "sharedFrameworkPublish");

            // The dotnetSharedFxLookup dir will contain some folders and files that will be
            // necessary to perform the tests
            string baseDir = Path.Combine(artifactsDir, "dotnetSharedFxLookup");

            _baseDir = SharedFramework.CalculateUniqueTestDirectory(baseDir);

            // 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");
            _executableDir     = Path.Combine(_baseDir, "exe");

            RepoDirectories = new RepoDirectoriesProvider(builtDotnet: _executableDir);

            // SharedFxBaseDirs contain all available version folders
            _exeSharedFxBaseDir = Path.Combine(_executableDir, "shared", "Microsoft.NETCore.App");

            _exeSharedUberFxBaseDir = Path.Combine(_executableDir, "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(_currentWorkingDir);
            SharedFramework.CopyDirectory(_builtDotnet, _executableDir);

            // Restore and build SharedFxLookupPortableApp from exe dir
            SharedFxLookupPortableAppFixture = new TestProjectFixture("SharedFxLookupPortableApp", RepoDirectories)
                                               .EnsureRestored(RepoDirectories.CorehostPackages)
                                               .BuildProject();
            var fixture = SharedFxLookupPortableAppFixture;

            // The actual framework version can be obtained from the built fixture. We'll use it to
            // locate the builtSharedFxDir from which we can get the files contained in the version folder
            string greatestVersionSharedFxPath = fixture.BuiltDotnet.GreatestVersionSharedFxPath;

            _sharedFxVersion      = (new DirectoryInfo(greatestVersionSharedFxPath)).Name;
            _builtSharedFxDir     = Path.Combine(_builtDotnet, "shared", "Microsoft.NETCore.App", _sharedFxVersion);
            _builtSharedUberFxDir = Path.Combine(_builtDotnet, "shared", "Microsoft.UberFramework", _sharedFxVersion);
            SharedFramework.CreateUberFrameworkArtifacts(_builtSharedFxDir, _builtSharedUberFxDir, SystemCollectionsImmutableAssemblyVersion, SystemCollectionsImmutableFileVersion);
        }
Beispiel #4
0
        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 GivenThatICareAboutMultilevelSharedFxLookup()
        {
            // From the artifacts dir, it's possible to find where the sharedFrameworkPublish folder is. We need
            // to locate it because we'll copy its contents into other folders
            string artifactsDir = Environment.GetEnvironmentVariable("TEST_ARTIFACTS");

            _builtDotnet = Path.Combine(artifactsDir, "sharedFrameworkPublish");

            // The dotnetMultilevelSharedFxLookup dir will contain some folders and files that will be
            // necessary to perform the tests
            string baseMultilevelDir = Path.Combine(artifactsDir, "dotnetMultilevelSharedFxLookup");

            _multilevelDir = SharedFramework.CalculateUniqueTestDirectory(baseMultilevelDir);

            // 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
            _currentWorkingDir = Path.Combine(_multilevelDir, "cwd");
            _userDir           = Path.Combine(_multilevelDir, "user");
            _exeDir            = Path.Combine(_multilevelDir, "exe");
            _regDir            = Path.Combine(_multilevelDir, "reg");

            RepoDirectories = new RepoDirectoriesProvider(builtDotnet: _exeDir);

            // 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(_exeDir, "shared", "Microsoft.NETCore.App");
            _regSharedFxBaseDir  = Path.Combine(_regDir, "shared", "Microsoft.NETCore.App");

            _cwdSharedUberFxBaseDir  = Path.Combine(_currentWorkingDir, "shared", "Microsoft.UberFramework");
            _userSharedUberFxBaseDir = Path.Combine(_userDir, ".dotnet", RepoDirectories.BuildArchitecture, "shared", "Microsoft.UberFramework");
            _exeSharedUberFxBaseDir  = Path.Combine(_exeDir, "shared", "Microsoft.UberFramework");
            _regSharedUberFxBaseDir  = Path.Combine(_regDir, "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(_regSharedFxBaseDir);
            Directory.CreateDirectory(_cwdSharedUberFxBaseDir);
            Directory.CreateDirectory(_userSharedUberFxBaseDir);
            Directory.CreateDirectory(_regSharedUberFxBaseDir);
            SharedFramework.CopyDirectory(_builtDotnet, _exeDir);

            //Copy dotnet to self-registered directory
            File.Copy(Path.Combine(_builtDotnet, $"dotnet{Constants.ExeSuffix}"), Path.Combine(_regDir, $"dotnet{Constants.ExeSuffix}"), true);

            // Restore and build SharedFxLookupPortableApp from exe dir
            PreviouslyBuiltAndRestoredPortableTestProjectFixture = new TestProjectFixture("SharedFxLookupPortableApp", RepoDirectories)
                                                                   .EnsureRestored(RepoDirectories.CorehostPackages)
                                                                   .BuildProject();
            var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture;

            // The actual framework version can be obtained from the built fixture. We'll use it to
            // locate the builtSharedFxDir from which we can get the files contained in the version folder
            string greatestVersionSharedFxPath = fixture.BuiltDotnet.GreatestVersionSharedFxPath;

            _sharedFxVersion      = (new DirectoryInfo(greatestVersionSharedFxPath)).Name;
            _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);
            _cwdSelectedMessage  = $"The expected {_hostPolicyDllName} directory is [{_cwdSharedFxBaseDir}";
            _userSelectedMessage = $"The expected {_hostPolicyDllName} directory is [{_userSharedFxBaseDir}";
            _exeSelectedMessage  = $"The expected {_hostPolicyDllName} directory is [{_exeSharedFxBaseDir}";
            _regSelectedMessage  = $"The expected {_hostPolicyDllName} directory is [{_regSharedFxBaseDir}";

            _cwdFoundUberFxMessage  = $"Chose FX version [{_cwdSharedUberFxBaseDir}";
            _userFoundUberFxMessage = $"Chose FX version [{_userSharedUberFxBaseDir}";
            _exeFoundUberFxMessage  = $"Chose FX version [{_exeSharedUberFxBaseDir}";
            _regFoundUberFxMessage  = $"Chose FX version [{_regSharedUberFxBaseDir}";
        }