diff --git a/src/installer/tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs b/src/installer/tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs index 6f20384803e142..7acfba3aaaee2f 100644 --- a/src/installer/tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs +++ b/src/installer/tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs @@ -25,6 +25,7 @@ private FluentAssertions.AndConstraint RunTheApp(string CommandResult result = Command.Create(path) .EnableTracingAndCaptureOutputs() .DotNetRoot(selfContained ? null : HostTestContext.BuiltDotNet.BinPath) + .EnvironmentVariable(Constants.BundleExtractBase.EnvironmentVariable, GetExtractionRootPath(path)) .Execute(); if (deleteApp) { @@ -39,6 +40,20 @@ private FluentAssertions.AndConstraint RunTheApp(string .And.HaveStdOutContaining("Wow! We now say hello to the big world and you."); } + private static string GetExtractionRootPath(string path) + { + string extractionRoot = Path.Combine(Path.GetDirectoryName(path), "extract"); + // Native extraction must support the long-name content even when the test artifact path exceeds MAX_PATH. + if (OperatingSystem.IsWindows() && !extractionRoot.StartsWith(@"\\?\", StringComparison.Ordinal)) + { + extractionRoot = extractionRoot.StartsWith(@"\\", StringComparison.Ordinal) + ? @"\\?\UNC\" + extractionRoot[2..] + : @"\\?\" + extractionRoot; + } + + return extractionRoot; + } + private static void DeleteExtractionDirectory(CommandResult result) { Assert.False(string.IsNullOrEmpty(result.StdErr), "Attempted to get extraction directory from empty stderr. Ensure tracing was enabled and stderr captured."); @@ -64,7 +79,7 @@ private static void DeleteExtractionDirectory(CommandResult result) [InlineData(BundleOptions.BundleAllContent)] public void FrameworkDependent(BundleOptions options) { - var singleFile = sharedTestState.FrameworkDependentApp.Bundle(options); + var singleFile = sharedTestState.FrameworkDependentApp.Bundle(options, out Manifest manifest); // Run the bundled app bool shouldExtract = options.HasFlag(BundleOptions.BundleAllContent); @@ -73,6 +88,10 @@ public void FrameworkDependent(BundleOptions options) if (shouldExtract) { + sharedTestState.FrameworkDependentApp + .GetExtractionDir(GetExtractionRootPath(singleFile), manifest) + .Should().Exist(); + // Run the bundled app again (reuse extracted files) RunTheApp(singleFile, selfContained: false) .And.ReuseExtraction(); @@ -86,7 +105,7 @@ public void FrameworkDependent(BundleOptions options) [InlineData(BundleOptions.BundleAllContent | BundleOptions.EnableCompression)] public void SelfContained(BundleOptions options) { - var singleFile = sharedTestState.SelfContainedApp.Bundle(options); + var singleFile = sharedTestState.SelfContainedApp.Bundle(options, out Manifest manifest); // Run the bundled app bool shouldExtract = options.HasFlag(BundleOptions.BundleAllContent); @@ -95,6 +114,10 @@ public void SelfContained(BundleOptions options) if (shouldExtract) { + sharedTestState.SelfContainedApp + .GetExtractionDir(GetExtractionRootPath(singleFile), manifest) + .Should().Exist(); + // Run the bundled app again (reuse extracted files) RunTheApp(singleFile, selfContained: true) .And.ReuseExtraction();