diff --git a/src/installer/tests/AppHost.Bundle.Tests/BundleExtractToSpecificPath.cs b/src/installer/tests/AppHost.Bundle.Tests/BundleExtractToSpecificPath.cs index b04653ddfd21bf..0260f415709186 100644 --- a/src/installer/tests/AppHost.Bundle.Tests/BundleExtractToSpecificPath.cs +++ b/src/installer/tests/AppHost.Bundle.Tests/BundleExtractToSpecificPath.cs @@ -224,6 +224,9 @@ private void UndefinedHOME_getpwuidFallback() DirectoryInfo expectedExtractDir = sharedTestState.SelfContainedApp.GetExtractionDir(Path.Combine(home, ".net"), bundledApp.Manifest); var extractedFiles = GetExpectedExtractedFiles(bundledApp.Manifest, bundledApp.Options); expectedExtractDir.Should().HaveFiles(extractedFiles); + + // Extraction directory for this test is not associated with the SingleFileTestApp, so we need to explicitly delete it. + Directory.Delete(expectedExtractDir.FullName, recursive: true); } private static List GetExpectedExtractedFiles(Manifest manifest, BundleOptions bundleOptions) diff --git a/src/installer/tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs b/src/installer/tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs index 5e1b5ef42bcac5..05381dc87d440e 100644 --- a/src/installer/tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs +++ b/src/installer/tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs @@ -20,16 +20,20 @@ public BundledAppWithSubDirs(SharedTestState fixture) sharedTestState = fixture; } - private FluentAssertions.AndConstraint RunTheApp(string path, bool selfContained, bool deleteExtracted = true) + private FluentAssertions.AndConstraint RunTheApp(string path, bool selfContained, bool deleteApp = true) { CommandResult result = Command.Create(path) .EnableTracingAndCaptureOutputs() .DotNetRoot(selfContained ? null : TestContext.BuiltDotNet.BinPath) .MultilevelLookup(false) .Execute(); - if (deleteExtracted) + if (deleteApp) { DeleteExtractionDirectory(result); + + // Delete the bundled app itself. It would already be cleaned up after all tests in this class run, but + // we do this early for test environments that may not have enough space for all the bundled apps at once. + FileUtils.DeleteFileIfPossible(path); } return result.Should().Pass() @@ -65,7 +69,7 @@ public void FrameworkDependent(BundleOptions options) // Run the bundled app bool shouldExtract = options.HasFlag(BundleOptions.BundleAllContent); - RunTheApp(singleFile, selfContained: false, deleteExtracted: !shouldExtract) + RunTheApp(singleFile, selfContained: false, deleteApp: !shouldExtract) .And.CreateExtraction(shouldExtract); if (shouldExtract) @@ -87,7 +91,7 @@ public void SelfContained(BundleOptions options) // Run the bundled app bool shouldExtract = options.HasFlag(BundleOptions.BundleAllContent); - RunTheApp(singleFile, selfContained: true, deleteExtracted: !shouldExtract) + RunTheApp(singleFile, selfContained: true, deleteApp: !shouldExtract) .And.CreateExtraction(shouldExtract); if (shouldExtract) @@ -107,7 +111,7 @@ public void SelfContained_Targeting50(BundleOptions options) // Run the bundled app bool shouldExtract = options.HasFlag(BundleOptions.BundleAllContent); - RunTheApp(singleFile, selfContained: true, deleteExtracted: !shouldExtract) + RunTheApp(singleFile, selfContained: true, deleteApp: !shouldExtract) .And.CreateExtraction(shouldExtract); if (shouldExtract) @@ -127,7 +131,7 @@ public void FrameworkDependent_Targeting50(BundleOptions options) // Run the bundled app bool shouldExtract = options.HasFlag(BundleOptions.BundleAllContent); - RunTheApp(singleFile, selfContained: false, deleteExtracted: !shouldExtract) + RunTheApp(singleFile, selfContained: false, deleteApp: !shouldExtract) .And.CreateExtraction(shouldExtract); if (shouldExtract)