示例#1
0
        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);
                }
            }
        }
示例#2
0
        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 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");
            }
        }