diff options
Diffstat (limited to 'src/installer/test/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs')
-rw-r--r-- | src/installer/test/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs | 97 |
1 files changed, 12 insertions, 85 deletions
diff --git a/src/installer/test/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs b/src/installer/test/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs index c5f77179436..e941becc236 100644 --- a/src/installer/test/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs +++ b/src/installer/test/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs @@ -40,32 +40,6 @@ namespace BundleTests.Helpers return Path.GetFileName(fixture.TestProject.AppDll); } - public static string GetAppBaseName(TestProjectFixture fixture) - { - return Path.GetFileNameWithoutExtension(GetAppName(fixture)); - } - - public static string[] GetBundledFiles(TestProjectFixture fixture) - { - string appBaseName = GetAppBaseName(fixture); - return new string[] { $"{appBaseName}.dll", $"{appBaseName}.deps.json", $"{appBaseName}.runtimeconfig.json" }; - } - - public static string[] GetExtractedFiles(TestProjectFixture fixture) - { - string appBaseName = GetAppBaseName(fixture); - return new string[] { $"{appBaseName}.dll" }; - } - - public static string[] GetFilesNeverExtracted(TestProjectFixture fixture) - { - string appBaseName = GetAppBaseName(fixture); - return new string[] { $"{appBaseName}.deps.json", - $"{appBaseName}.runtimeconfig.json", - Path.GetFileName(fixture.TestProject.HostFxrDll), - Path.GetFileName(fixture.TestProject.HostPolicyDll) }; - } - public static string GetPublishPath(TestProjectFixture fixture) { return Path.Combine(fixture.TestProject.ProjectDirectory, "publish"); @@ -76,28 +50,13 @@ namespace BundleTests.Helpers return Directory.CreateDirectory(Path.Combine(fixture.TestProject.ProjectDirectory, "bundle")); } - public static string GetExtractionRootPath(TestProjectFixture fixture) - { - return Path.Combine(fixture.TestProject.ProjectDirectory, "extract"); - } - - public static DirectoryInfo GetExtractionRootDir(TestProjectFixture fixture) + public static DirectoryInfo GetExtractDir(TestProjectFixture fixture) { - return Directory.CreateDirectory(GetExtractionRootPath(fixture)); - } - - public static string GetExtractionPath(TestProjectFixture fixture, Bundler bundler) - { - return Path.Combine(GetExtractionRootPath(fixture), GetAppBaseName(fixture), bundler.BundleManifest.BundleID); - - } - public static DirectoryInfo GetExtractionDir(TestProjectFixture fixture, Bundler bundler) - { - return new DirectoryInfo(GetExtractionPath(fixture, bundler)); + return Directory.CreateDirectory(Path.Combine(fixture.TestProject.ProjectDirectory, "extract")); } /// Generate a bundle containind the (embeddable) files in sourceDir - public static string GenerateBundle(Bundler bundler, string sourceDir, string outputDir, bool copyExludedFiles=true) + public static string GenerateBundle(Bundler bundler, string sourceDir) { // Convert sourceDir to absolute path sourceDir = Path.GetFullPath(sourceDir); @@ -114,22 +73,7 @@ namespace BundleTests.Helpers fileSpecs.Add(new FileSpec(file, Path.GetRelativePath(sourceDir, file))); } - var singleFile = bundler.GenerateBundle(fileSpecs); - - if (copyExludedFiles) - { - foreach (var spec in fileSpecs) - { - if (spec.Excluded) - { - var outputFilePath = Path.Combine(outputDir, spec.BundleRelativePath); - Directory.CreateDirectory(Path.GetDirectoryName(outputFilePath)); - File.Copy(spec.SourcePath, outputFilePath, true); - } - } - } - - return singleFile; + return bundler.GenerateBundle(fileSpecs); } // Bundle to a single-file @@ -137,40 +81,23 @@ namespace BundleTests.Helpers // instead of the SDK via /p:PublishSingleFile=true. // This is necessary when the test needs the latest changes in the AppHost, // which may not (yet) be available in the SDK. - public static Bundler BundleApp(TestProjectFixture fixture, - out string singleFile, - BundleOptions options = BundleOptions.BundleNativeBinaries, - Version targetFrameworkVersion = null, - bool copyExcludedFiles = true) + // + // Currently, AppHost can only handle bundles if all content is extracted to disk on startup. + // Therefore, the BundleOption is BundleAllContent by default. + // The default should be BundleOptions.None once host/runtime no longer requires full-extraction. + public static string BundleApp(TestProjectFixture fixture, + BundleOptions options = BundleOptions.BundleAllContent, + Version targetFrameworkVersion = null) { var hostName = GetHostName(fixture); string publishPath = GetPublishPath(fixture); var bundleDir = GetBundleDir(fixture); var bundler = new Bundler(hostName, bundleDir.FullName, options, targetFrameworkVersion: targetFrameworkVersion); - singleFile = GenerateBundle(bundler, publishPath, bundleDir.FullName, copyExcludedFiles); - - return bundler; - } - - // The defaut option for Bundling apps is BundleOptions.BundleNativeBinaries - // Until CoreCLR runtime can learn how to process assemblies from the bundle. - // This is because CoreCLR expects System.Private.Corelib.dll to be beside CoreCLR.dll - public static string BundleApp(TestProjectFixture fixture, - BundleOptions options = BundleOptions.BundleNativeBinaries, - Version targetFrameworkVersion = null) - { - string singleFile; - BundleApp(fixture, out singleFile, options, targetFrameworkVersion); + string singleFile = GenerateBundle(bundler, publishPath); return singleFile; } - public static Bundler Bundle(TestProjectFixture fixture, BundleOptions options = BundleOptions.None) - { - string singleFile; - return BundleApp(fixture, out singleFile, options, copyExcludedFiles:false); - } - public static void AddLongNameContentToAppWithSubDirs(TestProjectFixture fixture) { // For tests using the AppWithSubDirs, One of the sub-directories with a really long name |