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); }
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 SharedTestState() { // The dotnetSDKLookup dir will contain some folders and files that will be // necessary to perform the tests string baseDir = Path.Combine(TestArtifact.TestArtifactsPath, "dotnetSDKLookup"); BaseDir = SharedFramework.CalculateUniqueTestDirectory(baseDir); _baseDirArtifact = new TestArtifact(BaseDir); // The three tested locations will be the cwd and the exe dir. cwd is no longer supported. // All dirs will be placed inside the base folder BuiltDotNet = new DotNetCli(Path.Combine(TestArtifact.TestArtifactsPath, "sharedFrameworkPublish")); RepoDirectories = new RepoDirectoriesProvider(); // Executable location is created per test as each test adds a different set of SDK versions var currentWorkingSdk = new DotNetBuilder(BaseDir, BuiltDotNet.BinPath, "current") .AddMockSDK("10000.0.0", "9999.0.0") .Build(); CurrentWorkingDir = currentWorkingSdk.BinPath; TestAssetsPath = Path.Combine(RepoDirectories.TestAssetsFolder, "TestUtils", "SDKLookup"); }
[PlatformSpecific(TestPlatforms.Windows)] // GUI app host is only supported on Windows. public void AppHost_GUI_FrameworkDependent_DisabledGUIErrors_DialogNotShown() { var fixture = sharedTestState.PortableAppFixture_Built .Copy(); string appExe = fixture.TestProject.AppExe; File.Copy(sharedTestState.BuiltAppHost, appExe, overwrite: true); AppHostExtensions.BindAppHost(appExe); AppHostExtensions.SetWindowsGraphicalUserInterfaceBit(appExe); string invalidDotNet = SharedFramework.CalculateUniqueTestDirectory(Path.Combine(TestArtifact.TestArtifactsPath, "guiErrors")); using (new TestArtifact(invalidDotNet)) { Directory.CreateDirectory(invalidDotNet); Command.Create(appExe) .EnableTracingAndCaptureOutputs() .DotNetRoot(invalidDotNet) .MultilevelLookup(false) .EnvironmentVariable(Constants.DisableGuiErrors.EnvironmentVariable, "1") .Execute() .Should().Fail() .And.NotHaveStdErrContaining("Showing error dialog for application"); } }
public SharedTestStateBase() { BaseDirectory = SharedFramework.CalculateUniqueTestDirectory(Path.Combine(TestArtifact.TestArtifactsPath, "nativeHosting")); _baseDirArtifact = new TestArtifact(BaseDirectory); Directory.CreateDirectory(BaseDirectory); string nativeHostName = RuntimeInformationExtensions.GetExeFileNameForCurrentPlatform("nativehost"); NativeHostPath = Path.Combine(BaseDirectory, nativeHostName); // Copy over native host RepoDirectories = new RepoDirectoriesProvider(); File.Copy(Path.Combine(RepoDirectories.Artifacts, "corehost_test", nativeHostName), NativeHostPath); // Copy nethost next to native host // This is done even for tests not directly using nethost because nativehost consumes nethost in the more // user-friendly way of linking against nethost (instead of dlopen/LoadLibrary and dlsym/GetProcAddress). // On Windows, we can delay load through a linker option, but on other platforms load is required on start. string nethostName = RuntimeInformationExtensions.GetSharedLibraryFileNameForCurrentPlatform("nethost"); NethostPath = Path.Combine(Path.GetDirectoryName(NativeHostPath), nethostName); File.Copy( Path.Combine(RepoDirectories.HostArtifacts, nethostName), NethostPath); }
public SDKLookup() { // The dotnetSDKLookup dir will contain some folders and files that will be // necessary to perform the tests string baseDir = Path.Combine(TestArtifact.TestArtifactsPath, "dotnetSDKLookup"); _baseDir = SharedFramework.CalculateUniqueTestDirectory(baseDir); // The three tested locations will be the cwd, the user folder and the exe dir. cwd and user are no longer supported. // All dirs will be placed inside the base folder _currentWorkingDir = Path.Combine(_baseDir, "cwd"); _userDir = Path.Combine(_baseDir, "user"); _executableDir = Path.Combine(_baseDir, "exe"); DotNet = new DotNetBuilder(_baseDir, Path.Combine(TestArtifact.TestArtifactsPath, "sharedFrameworkPublish"), "exe") .AddMicrosoftNETCoreAppFramework("9999.0.0") .Build(); RepoDirectories = new RepoDirectoriesProvider(builtDotnet: DotNet.BinPath); // SdkBaseDirs contain all available version folders _cwdSdkBaseDir = Path.Combine(_currentWorkingDir, "sdk"); _userSdkBaseDir = Path.Combine(_userDir, ".dotnet", RepoDirectories.BuildArchitecture, "sdk"); _exeSdkBaseDir = Path.Combine(_executableDir, "sdk"); // Create directories Directory.CreateDirectory(_cwdSdkBaseDir); Directory.CreateDirectory(_userSdkBaseDir); Directory.CreateDirectory(_exeSdkBaseDir); // Trace messages used to identify from which folder the SDK was picked _exeSelectedMessage = $"Using dotnet SDK dll=[{_exeSdkBaseDir}"; }
public SharedTestState() { BaseDirectory = SharedFramework.CalculateUniqueTestDirectory(Path.Combine(TestArtifact.TestArtifactsPath, "nativeHosting")); Directory.CreateDirectory(BaseDirectory); string nativeHostName = RuntimeInformationExtensions.GetExeFileNameForCurrentPlatform("nativehost"); NativeHostPath = Path.Combine(BaseDirectory, nativeHostName); // Copy over native host and nethost RepoDirectories = new RepoDirectoriesProvider(); string nethostName = RuntimeInformationExtensions.GetSharedLibraryFileNameForCurrentPlatform("nethost"); File.Copy(Path.Combine(RepoDirectories.CorehostPackages, nethostName), Path.Combine(BaseDirectory, nethostName)); File.Copy(Path.Combine(RepoDirectories.Artifacts, "corehost_test", nativeHostName), NativeHostPath); InvalidInstallRoot = Path.Combine(BaseDirectory, "invalid"); Directory.CreateDirectory(InvalidInstallRoot); ValidInstallRoot = Path.Combine(BaseDirectory, "valid"); HostFxrPath = CreateHostFxr(Path.Combine(ValidInstallRoot, "dotnet")); string appDir = Path.Combine(BaseDirectory, "app"); Directory.CreateDirectory(appDir); string assemblyPath = Path.Combine(appDir, "App.dll"); File.WriteAllText(assemblyPath, string.Empty); TestAssemblyPath = assemblyPath; }
public void Bundle_Framework_dependent_NoBundleEntryPoint() { var fixture = sharedTestState.TestFrameworkDependentFixture.Copy(); UseFrameworkDependentHost(fixture); var singleFile = BundleHelper.BundleApp(fixture, BundleOptions.None); string dotnetWithMockHostFxr = SharedFramework.CalculateUniqueTestDirectory(Path.Combine(TestArtifact.TestArtifactsPath, "guiErrors")); using (new TestArtifact(dotnetWithMockHostFxr)) { Directory.CreateDirectory(dotnetWithMockHostFxr); var dotnetBuilder = new DotNetBuilder(dotnetWithMockHostFxr, sharedTestState.RepoDirectories.BuiltDotnet, "mockhostfxrFrameworkMissingFailure") .RemoveHostFxr() .AddMockHostFxr(new Version(2, 2, 0)); var dotnet = dotnetBuilder.Build(); // Run the bundled app (extract files) RunTheApp(singleFile, dotnet) .Should() .Fail() .And.HaveStdErrContaining("You must install or update .NET to run this application.") .And.HaveStdErrContaining("App host version:") .And.HaveStdErrContaining("apphost_version="); } }
public SharedTestStateBase() { _builtDotnet = Path.Combine(TestArtifact.TestArtifactsPath, "sharedFrameworkPublish"); string baseDir = Path.Combine(TestArtifact.TestArtifactsPath, "frameworkResolution"); _baseDir = SharedFramework.CalculateUniqueTestDirectory(baseDir); }
public void AppHost_GUI_FrameworkDependent_MissingRuntimeFramework_ErrorReportedInDialog(bool missingHostfxr) { var fixture = sharedTestState.PortableAppFixture_Built .Copy(); string appExe = fixture.TestProject.AppExe; File.Copy(sharedTestState.BuiltAppHost, appExe, overwrite: true); AppHostExtensions.BindAppHost(appExe); AppHostExtensions.SetWindowsGraphicalUserInterfaceBit(appExe); string invalidDotNet = SharedFramework.CalculateUniqueTestDirectory(Path.Combine(TestArtifact.TestArtifactsPath, "guiErrors")); using (new TestArtifact(invalidDotNet)) { Directory.CreateDirectory(invalidDotNet); string expectedErrorCode; string expectedUrlQuery; string expectedUrlParameter = null; if (missingHostfxr) { expectedErrorCode = Constants.ErrorCode.CoreHostLibMissingFailure.ToString("x"); expectedUrlQuery = "missing_runtime=true&"; expectedUrlParameter = $"&apphost_version={sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}"; } else { invalidDotNet = new DotNetBuilder(invalidDotNet, sharedTestState.RepoDirectories.BuiltDotnet, "missingFramework") .Build() .BinPath; expectedErrorCode = Constants.ErrorCode.FrameworkMissingFailure.ToString("x"); expectedUrlQuery = $"framework={Constants.MicrosoftNETCoreApp}&framework_version={sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}"; } Command command = Command.Create(appExe) .EnableTracingAndCaptureOutputs() .DotNetRoot(invalidDotNet) .MultilevelLookup(false) .Start(); WaitForPopupFromProcess(command.Process); command.Process.Kill(); var result = command.WaitForExit(true) .Should().Fail(); result.And.HaveStdErrContaining($"Showing error dialog for application: '{Path.GetFileName(appExe)}' - error code: 0x{expectedErrorCode}") .And.HaveStdErrContaining($"url: 'https://aka.ms/dotnet-core-applaunch?{expectedUrlQuery}") .And.HaveStdErrContaining("&gui=true"); if (expectedUrlParameter != null) { result.And.HaveStdErrContaining(expectedUrlParameter); } } }
public SharedTestState() { RepoDirectories = new RepoDirectoriesProvider(); BuiltDotNet = new DotNetCli(RepoDirectories.BuiltDotnet); BaseDirectory = SharedFramework.CalculateUniqueTestDirectory(Path.Combine(TestArtifact.TestArtifactsPath, "argValidation")); // Create an empty global.json file Directory.CreateDirectory(BaseDirectory); File.WriteAllText(Path.Combine(BaseDirectory, "global.json"), "{}"); }
public SharedTestStateBase() { BaseDirectory = SharedFramework.CalculateUniqueTestDirectory(Path.Combine(TestArtifact.TestArtifactsPath, "nativeHosting")); Directory.CreateDirectory(BaseDirectory); string nativeHostName = RuntimeInformationExtensions.GetExeFileNameForCurrentPlatform("nativehost"); NativeHostPath = Path.Combine(BaseDirectory, nativeHostName); // Copy over native host RepoDirectories = new RepoDirectoriesProvider(); File.Copy(Path.Combine(RepoDirectories.Artifacts, "corehost_test", nativeHostName), NativeHostPath); }
public SDKLookup(SharedTestState sharedState) { SharedState = sharedState; string exeDotNetPath = SharedFramework.CalculateUniqueTestDirectory(sharedState.BaseDir); ExecutableDotNetBuilder = new DotNetBuilder(exeDotNetPath, sharedState.BuiltDotNet.BinPath, "exe"); ExecutableDotNet = ExecutableDotNetBuilder .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("9999.0.0") .Build(); // Trace messages used to identify from which folder the SDK was picked ExecutableSelectedMessage = $"Using .NET SDK dll=[{Path.Combine(ExecutableDotNet.BinPath, "sdk")}"; // Note: no need to delete the directory, it will be removed once the entire class is done // since everything is under the BaseDir from the shared state }
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); }
public void AppHost_GUI_NoCustomErrorWriter_FrameworkMissing_ErrorReportedInDialog() { if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { return; } var fixture = sharedTestState.PortableAppFixture_Built .Copy(); string appExe = fixture.TestProject.AppExe; File.Copy(sharedTestState.BuiltAppHost, appExe, overwrite: true); AppHostExtensions.BindAppHost(appExe); AppHostExtensions.SetWindowsGraphicalUserInterfaceBit(appExe); string dotnetWithMockHostFxr = SharedFramework.CalculateUniqueTestDirectory(Path.Combine(TestArtifact.TestArtifactsPath, "guiErrors")); using (new TestArtifact(dotnetWithMockHostFxr)) { Directory.CreateDirectory(dotnetWithMockHostFxr); string expectedErrorCode = Constants.ErrorCode.FrameworkMissingFailure.ToString("x"); var dotnetBuilder = new DotNetBuilder(dotnetWithMockHostFxr, sharedTestState.RepoDirectories.BuiltDotnet, "hostfxrFrameworkMissingFailure") .RemoveHostFxr() .AddMockHostFxr(new Version(2, 2, 0)); var dotnet = dotnetBuilder.Build(); Command command = Command.Create(appExe) .EnableTracingAndCaptureOutputs() .DotNetRoot(dotnet.BinPath) .MultilevelLookup(false) .Start(); WaitForPopupFromProcess(command.Process); command.Process.Kill(); command.WaitForExit(true) .Should().Fail() .And.HaveStdErrContaining($"Showing error dialog for application: '{Path.GetFileName(appExe)}' - error code: 0x{expectedErrorCode}") .And.HaveStdErrContaining("To run this application, you need to install a newer version of .NET"); } }
public SharedTestState() { RepoDirectories = new RepoDirectoriesProvider(); BuiltAppHost = Path.Combine(RepoDirectories.HostArtifacts, RuntimeInformationExtensions.GetExeFileNameForCurrentPlatform("apphost")); BuiltDotNet = new DotNetCli(RepoDirectories.BuiltDotnet); PortableAppFixture_Built = new TestProjectFixture("PortableApp", RepoDirectories) .EnsureRestored() .BuildProject(); PortableAppFixture_Published = new TestProjectFixture("PortableApp", RepoDirectories) .EnsureRestored() .PublishProject(); MockApp = new TestApp(SharedFramework.CalculateUniqueTestDirectory(Path.Combine(TestArtifact.TestArtifactsPath, "portableAppActivation")), "App"); Directory.CreateDirectory(MockApp.Location); File.WriteAllText(MockApp.AppDll, string.Empty); File.Copy(BuiltAppHost, MockApp.AppExe); AppHostExtensions.BindAppHost(MockApp.AppExe); }
public MultilevelSDKLookup() { // The dotnetMultilevelSDKLookup dir will contain some folders and files that will be // necessary to perform the tests string baseMultilevelDir = Path.Combine(TestArtifact.TestArtifactsPath, "dotnetMultilevelSDKLookup"); _multilevelDir = SharedFramework.CalculateUniqueTestDirectory(baseMultilevelDir); // The tested locations will be the cwd, user folder, exe dir, and registered directory. cwd and user are no longer supported. // All dirs will be placed inside the multilevel folder _currentWorkingDir = Path.Combine(_multilevelDir, "cwd"); _userDir = Path.Combine(_multilevelDir, "user"); _exeDir = Path.Combine(_multilevelDir, "exe"); _regDir = Path.Combine(_multilevelDir, "reg"); DotNet = new DotNetBuilder(_multilevelDir, Path.Combine(TestArtifact.TestArtifactsPath, "sharedFrameworkPublish"), "exe") .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("9999.0.0") .Build(); RepoDirectories = new RepoDirectoriesProvider(builtDotnet: DotNet.BinPath); // SdkBaseDirs contain all available version folders _cwdSdkBaseDir = Path.Combine(_currentWorkingDir, "sdk"); _userSdkBaseDir = Path.Combine(_userDir, ".dotnet", RepoDirectories.BuildArchitecture, "sdk"); _exeSdkBaseDir = Path.Combine(_exeDir, "sdk"); _regSdkBaseDir = Path.Combine(_regDir, "sdk"); // Create directories Directory.CreateDirectory(_cwdSdkBaseDir); Directory.CreateDirectory(_userSdkBaseDir); Directory.CreateDirectory(_exeSdkBaseDir); Directory.CreateDirectory(_regSdkBaseDir); // Trace messages used to identify from which folder the SDK was picked _exeSelectedMessage = $"Using .NET SDK dll=[{_exeSdkBaseDir}"; _regSelectedMessage = $"Using .NET SDK dll=[{_regSdkBaseDir}"; _testOnlyProductBehaviorMarker = TestOnlyProductBehavior.Enable(DotNet.GreatestVersionHostFxrFilePath); }
[PlatformSpecific(TestPlatforms.Windows)] // GUI app host is only supported on Windows. public void Bundled_Framework_dependent_App_GUI_DownlevelHostFxr_ErrorDialog(BundleOptions options) { var fixture = sharedTestState.TestFrameworkDependentFixture.Copy(); UseFrameworkDependentHost(fixture); var singleFile = BundleHelper.BundleApp(fixture, options); AppHostExtensions.SetWindowsGraphicalUserInterfaceBit(singleFile); string dotnetWithMockHostFxr = SharedFramework.CalculateUniqueTestDirectory(Path.Combine(TestArtifact.TestArtifactsPath, "bundleErrors")); using (new TestArtifact(dotnetWithMockHostFxr)) { Directory.CreateDirectory(dotnetWithMockHostFxr); string expectedErrorCode = Constants.ErrorCode.BundleExtractionFailure.ToString("x"); var dotnetBuilder = new DotNetBuilder(dotnetWithMockHostFxr, sharedTestState.RepoDirectories.BuiltDotnet, "mockhostfxrBundleVersionFailure") .RemoveHostFxr() .AddMockHostFxr(new Version(5, 0, 0)); var dotnet = dotnetBuilder.Build(); Command command = Command.Create(singleFile) .EnableTracingAndCaptureOutputs() .DotNetRoot(dotnet.BinPath, sharedTestState.RepoDirectories.BuildArchitecture) .MultilevelLookup(false) .Start(); WindowsUtils.WaitForPopupFromProcess(command.Process); command.Process.Kill(); command .WaitForExit(true) .Should().Fail() .And.HaveStdErrContaining("Bundle header version compatibility check failed.") .And.HaveStdErrContaining($"Showing error dialog for application: '{Path.GetFileName(singleFile)}' - error code: 0x{expectedErrorCode}") .And.HaveStdErrContaining("apphost_version="); } }
public GivenThatICareAboutMultilevelSDKLookup() { // 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"); string builtDotnet = Path.Combine(artifactsDir, "sharedFrameworkPublish"); // The dotnetMultilevelSDKLookup dir will contain some folders and files that will be // necessary to perform the tests string baseMultilevelDir = Path.Combine(artifactsDir, "dotnetMultilevelSDKLookup"); _multilevelDir = SharedFramework.CalculateUniqueTestDirectory(baseMultilevelDir); // The three tested locations will be the cwd, the user folder and the exe dir. cwd and user are no longer supported. // All dirs will be placed inside the multilevel folder _currentWorkingDir = Path.Combine(_multilevelDir, "cwd"); _userDir = Path.Combine(_multilevelDir, "user"); _executableDir = Path.Combine(_multilevelDir, "exe"); // 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 SharedFramework.CopyDirectory(builtDotnet, _executableDir); RepoDirectories = new RepoDirectoriesProvider(builtDotnet: _executableDir); // SdkBaseDirs contain all available version folders _cwdSdkBaseDir = Path.Combine(_currentWorkingDir, "sdk"); _userSdkBaseDir = Path.Combine(_userDir, ".dotnet", RepoDirectories.BuildArchitecture, "sdk"); _exeSdkBaseDir = Path.Combine(_executableDir, "sdk"); // Create directories Directory.CreateDirectory(_cwdSdkBaseDir); Directory.CreateDirectory(_userSdkBaseDir); Directory.CreateDirectory(_exeSdkBaseDir); // Restore and build PortableApp from exe dir PreviouslyBuiltAndRestoredPortableTestProjectFixture = new TestProjectFixture("PortableApp", RepoDirectories) .EnsureRestored(RepoDirectories.CorehostPackages) .BuildProject(); var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture; // Set a dummy framework version (9999.0.0) in the exe sharedFx location. We will // always pick the framework from this to avoid interference with the sharedFxLookup string exeDirDummyFxVersion = Path.Combine(_executableDir, "shared", "Microsoft.NETCore.App", "9999.0.0"); string builtSharedFxDir = fixture.BuiltDotnet.GreatestVersionSharedFxPath; SharedFramework.CopyDirectory(builtSharedFxDir, exeDirDummyFxVersion); // The actual SDK version can be obtained from the built fixture. We'll use it to // locate the sdkDir from which we can get the files contained in the version folder string sdkBaseDir = Path.Combine(fixture.SdkDotnet.BinPath, "sdk"); var sdkVersionDirs = Directory.EnumerateDirectories(sdkBaseDir) .Select(p => Path.GetFileName(p)); string greatestVersionSdk = sdkVersionDirs .Where(p => !string.Equals(p, "NuGetFallbackFolder", StringComparison.OrdinalIgnoreCase)) .OrderByDescending(p => p.ToLower()) .First(); _sdkDir = Path.Combine(sdkBaseDir, greatestVersionSdk); // Trace messages used to identify from which folder the SDK was picked _cwdSelectedMessage = $"Using dotnet SDK dll=[{_cwdSdkBaseDir}"; _userSelectedMessage = $"Using dotnet SDK dll=[{_userSdkBaseDir}"; _exeSelectedMessage = $"Using dotnet SDK dll=[{_exeSdkBaseDir}"; }
private static string GetBaseDir(string name) { string baseDir = Path.Combine(TestArtifactsPath, name); return(SharedFramework.CalculateUniqueTestDirectory(baseDir)); }
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}"; }