Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/installer/test')
-rw-r--r--src/installer/test/Assets/TestProjects/AppWithSubDirs/Program.cs6
-rw-r--r--src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundleExtractToSpecificPath.cs64
-rw-r--r--src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundleRename.cs4
-rw-r--r--src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs34
-rw-r--r--src/installer/test/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs97
-rw-r--r--src/installer/test/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Bundle.Tests/BundleAndRun.cs5
-rw-r--r--src/installer/test/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Bundle.Tests/BundleLegacy.cs1
-rw-r--r--src/installer/test/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Bundle.Tests/BundlerConsistencyTests.cs76
-rw-r--r--src/installer/test/TestUtils/TestApp.cs2
-rw-r--r--src/installer/test/TestUtils/TestProject.cs1
10 files changed, 125 insertions, 165 deletions
diff --git a/src/installer/test/Assets/TestProjects/AppWithSubDirs/Program.cs b/src/installer/test/Assets/TestProjects/AppWithSubDirs/Program.cs
index 5b51c37991b..20c24839186 100644
--- a/src/installer/test/Assets/TestProjects/AppWithSubDirs/Program.cs
+++ b/src/installer/test/Assets/TestProjects/AppWithSubDirs/Program.cs
@@ -4,6 +4,7 @@
using System;
using System.IO;
+using System.Reflection;
namespace AppWithSubDirs
{
@@ -11,7 +12,10 @@ namespace AppWithSubDirs
{
public static void Main(string[] args)
{
- string baseDir = Path.Combine(AppContext.BaseDirectory, "Sentence");
+ string baseDir =
+ Path.Combine(
+ Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
+ "Sentence");
string Part(string dir="", string subdir="", string subsubdir="")
{
diff --git a/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundleExtractToSpecificPath.cs b/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundleExtractToSpecificPath.cs
index 26dbc3a00ef..5f35a406c91 100644
--- a/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundleExtractToSpecificPath.cs
+++ b/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundleExtractToSpecificPath.cs
@@ -7,7 +7,9 @@ using Microsoft.DotNet.Cli.Build.Framework;
using Microsoft.DotNet.CoreSetup.Test;
using Microsoft.NET.HostModel.Bundle;
using System;
+using System.Collections.Generic;
using System.IO;
+using System.Linq;
using System.Threading;
using Xunit;
@@ -27,19 +29,24 @@ namespace AppHost.Bundle.Tests
{
var fixture = sharedTestState.TestFixture.Copy();
var hostName = BundleHelper.GetHostName(fixture);
+ var appName = Path.GetFileNameWithoutExtension(hostName);
+ string publishPath = BundleHelper.GetPublishPath(fixture);
// Publish the bundle
- string singleFile;
- Bundler bundler = BundleHelper.BundleApp(fixture, out singleFile);
+ var bundleDir = BundleHelper.GetBundleDir(fixture);
+ var bundler = new Bundler(hostName, bundleDir.FullName, BundleOptions.BundleAllContent);
+ string singleFile = BundleHelper.GenerateBundle(bundler, publishPath);
+
+ // Compute bundled files
+ var bundledFiles = bundler.BundleManifest.Files.Select(file => file.RelativePath).ToList();
// Verify expected files in the bundle directory
- var bundleDir = BundleHelper.GetBundleDir(fixture);
bundleDir.Should().HaveFile(hostName);
- bundleDir.Should().NotHaveFiles(BundleHelper.GetBundledFiles(fixture));
+ bundleDir.Should().NotHaveFiles(bundledFiles);
// Create a directory for extraction.
- var extractBaseDir = BundleHelper.GetExtractionRootDir(fixture);
- extractBaseDir.Should().NotHaveDirectory(BundleHelper.GetAppBaseName(fixture));
+ var extractBaseDir = BundleHelper.GetExtractDir(fixture);
+ extractBaseDir.Should().NotHaveDirectory(appName);
// Run the bundled app for the first time, and extract files to
// $DOTNET_BUNDLE_EXTRACT_BASE_DIR/<app>/bundle-id
@@ -53,22 +60,27 @@ namespace AppHost.Bundle.Tests
.And
.HaveStdOutContaining("Hello World");
- var extractDir = BundleHelper.GetExtractionDir(fixture, bundler);
- extractDir.Should().HaveFiles(BundleHelper.GetExtractedFiles(fixture));
- extractDir.Should().NotHaveFiles(BundleHelper.GetFilesNeverExtracted(fixture));
+ string extractPath = Path.Combine(extractBaseDir.FullName, appName, bundler.BundleManifest.BundleID);
+ var extractDir = new DirectoryInfo(extractPath);
+ extractDir.Should().OnlyHaveFiles(bundledFiles);
+ extractDir.Should().NotHaveFile(hostName);
}
[Fact]
private void Bundle_extraction_is_reused()
{
var fixture = sharedTestState.TestFixture.Copy();
+ var hostName = BundleHelper.GetHostName(fixture);
+ var appName = Path.GetFileNameWithoutExtension(hostName);
+ string publishPath = BundleHelper.GetPublishPath(fixture);
// Publish the bundle
- string singleFile;
- Bundler bundler = BundleHelper.BundleApp(fixture, out singleFile, BundleOptions.BundleNativeBinaries);
+ var bundleDir = BundleHelper.GetBundleDir(fixture);
+ var bundler = new Bundler(hostName, bundleDir.FullName, BundleOptions.BundleAllContent);
+ string singleFile = BundleHelper.GenerateBundle(bundler, publishPath);
// Create a directory for extraction.
- var extractBaseDir = BundleHelper.GetExtractionRootDir(fixture);
+ var extractBaseDir = BundleHelper.GetExtractDir(fixture);
// Run the bunded app for the first time, and extract files to
// $DOTNET_BUNDLE_EXTRACT_BASE_DIR/<app>/bundle-id
@@ -82,8 +94,8 @@ namespace AppHost.Bundle.Tests
.And
.HaveStdOutContaining("Hello World");
- var appBaseName = BundleHelper.GetAppBaseName(fixture);
- var extractDir = BundleHelper.GetExtractionDir(fixture, bundler);
+ string extractPath = Path.Combine(extractBaseDir.FullName, appName, bundler.BundleManifest.BundleID);
+ var extractDir = new DirectoryInfo(extractPath);
extractDir.Refresh();
DateTime firstWriteTime = extractDir.LastWriteTimeUtc;
@@ -113,14 +125,20 @@ namespace AppHost.Bundle.Tests
var fixture = sharedTestState.TestFixture.Copy();
var hostName = BundleHelper.GetHostName(fixture);
var appName = Path.GetFileNameWithoutExtension(hostName);
+ string publishPath = BundleHelper.GetPublishPath(fixture);
// Publish the bundle
- string singleFile;
- Bundler bundler = BundleHelper.BundleApp(fixture, out singleFile, BundleOptions.BundleNativeBinaries);
+ var bundleDir = BundleHelper.GetBundleDir(fixture);
+ var bundler = new Bundler(hostName, bundleDir.FullName, BundleOptions.BundleAllContent);
+ string singleFile = BundleHelper.GenerateBundle(bundler, publishPath);
+
+ // Compute bundled files
+ List<string> bundledFiles = bundler.BundleManifest.Files.Select(file => file.RelativePath).ToList();
// Create a directory for extraction.
- var extractBaseDir = BundleHelper.GetExtractionRootDir(fixture);
-
+ var extractBaseDir = BundleHelper.GetExtractDir(fixture);
+ string extractPath = Path.Combine(extractBaseDir.FullName, appName, bundler.BundleManifest.BundleID);
+ var extractDir = new DirectoryInfo(extractPath);
// Run the bunded app for the first time, and extract files to
// $DOTNET_BUNDLE_EXTRACT_BASE_DIR/<app>/bundle-id
@@ -134,14 +152,10 @@ namespace AppHost.Bundle.Tests
.And
.HaveStdOutContaining("Hello World");
- // Remove the extracted files, but keep the extraction directory
- var extractDir = BundleHelper.GetExtractionDir(fixture, bundler);
- var extractedFiles = BundleHelper.GetExtractedFiles(fixture);
-
- Array.ForEach(extractedFiles, file => File.Delete(Path.Combine(extractDir.FullName, file)));
+ bundledFiles.ForEach(file => File.Delete(Path.Combine(extractPath, file)));
extractDir.Should().Exist();
- extractDir.Should().NotHaveFiles(extractedFiles);
+ extractDir.Should().NotHaveFiles(bundledFiles);
// Run the bundled app again (recover deleted files)
Command.Create(singleFile)
@@ -154,7 +168,7 @@ namespace AppHost.Bundle.Tests
.And
.HaveStdOutContaining("Hello World");
- extractDir.Should().HaveFiles(extractedFiles);
+ extractDir.Should().HaveFiles(bundledFiles);
}
diff --git a/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundleRename.cs b/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundleRename.cs
index 581a1155c98..5466743fc5d 100644
--- a/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundleRename.cs
+++ b/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundleRename.cs
@@ -51,13 +51,11 @@ namespace AppHost.Bundle.Tests
.CaptureStdOut()
.Start();
- while (!File.Exists(waitFile) && !singleExe.Process.HasExited)
+ while (!File.Exists(waitFile))
{
Thread.Sleep(100);
}
- Assert.True(File.Exists(waitFile));
-
File.Move(singleFile, renameFile);
File.Create(resumeFile).Close();
diff --git a/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs b/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs
index 33e05b5c050..59360c09f99 100644
--- a/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs
+++ b/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs
@@ -2,12 +2,11 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using BundleTests.Helpers;
-using Microsoft.DotNet.Cli.Build.Framework;
-using Microsoft.NET.HostModel.Bundle;
-using Microsoft.DotNet.CoreSetup.Test;
using System;
using Xunit;
+using Microsoft.DotNet.Cli.Build.Framework;
+using BundleTests.Helpers;
+using Microsoft.DotNet.CoreSetup.Test;
namespace AppHost.Bundle.Tests
{
@@ -32,16 +31,11 @@ namespace AppHost.Bundle.Tests
.HaveStdOutContaining("Wow! We now say hello to the big world and you.");
}
- // BundleOptions.BundleNativeBinaries: Test when the payload data files are unbundled, and beside the single-file app.
- // BundleOptions.BundleAllContent: Test when the payload data files are bundled and extracted to temporary directory.
- // Once the runtime can load assemblies from the bundle, BundleOptions.None can be used in place of BundleOptions.BundleNativeBinaries.
- [InlineData(BundleOptions.BundleNativeBinaries)]
- [InlineData(BundleOptions.BundleAllContent)]
- [Theory]
- public void Bundled_Framework_dependent_App_Run_Succeeds(BundleOptions options)
+ [Fact]
+ public void Bundled_Framework_dependent_App_Run_Succeeds()
{
var fixture = sharedTestState.TestFrameworkDependentFixture.Copy();
- var singleFile = BundleHelper.BundleApp(fixture, options);
+ var singleFile = BundleHelper.BundleApp(fixture);
// Run the bundled app (extract files)
RunTheApp(singleFile);
@@ -50,13 +44,11 @@ namespace AppHost.Bundle.Tests
RunTheApp(singleFile);
}
- [InlineData(BundleOptions.BundleNativeBinaries)]
- [InlineData(BundleOptions.BundleAllContent)]
- [Theory]
- public void Bundled_Self_Contained_App_Run_Succeeds(BundleOptions options)
+ [Fact]
+ public void Bundled_Self_Contained_App_Run_Succeeds()
{
var fixture = sharedTestState.TestSelfContainedFixture.Copy();
- var singleFile = BundleHelper.BundleApp(fixture, options);
+ var singleFile = BundleHelper.BundleApp(fixture);
// Run the bundled app (extract files)
RunTheApp(singleFile);
@@ -65,13 +57,11 @@ namespace AppHost.Bundle.Tests
RunTheApp(singleFile);
}
- [InlineData(BundleOptions.BundleNativeBinaries)]
- [InlineData(BundleOptions.BundleAllContent)]
- [Theory]
- public void Bundled_With_Empty_File_Succeeds(BundleOptions options)
+ [Fact]
+ public void Bundled_With_Empty_File_Succeeds()
{
var fixture = sharedTestState.TestAppWithEmptyFileFixture.Copy();
- var singleFile = BundleHelper.BundleApp(fixture, options);
+ var singleFile = BundleHelper.BundleApp(fixture);
// Run the app
RunTheApp(singleFile);
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
diff --git a/src/installer/test/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Bundle.Tests/BundleAndRun.cs b/src/installer/test/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Bundle.Tests/BundleAndRun.cs
index e4949b47750..3199b1559ff 100644
--- a/src/installer/test/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Bundle.Tests/BundleAndRun.cs
+++ b/src/installer/test/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Bundle.Tests/BundleAndRun.cs
@@ -7,6 +7,7 @@ using System.IO;
using Xunit;
using Microsoft.DotNet.Cli.Build.Framework;
using Microsoft.DotNet.CoreSetup.Test;
+using Microsoft.NET.HostModel.Bundle;
using BundleTests.Helpers;
namespace Microsoft.NET.HostModel.Tests
@@ -40,7 +41,9 @@ namespace Microsoft.NET.HostModel.Tests
RunTheApp(Path.Combine(publishPath, hostName));
// Bundle to a single-file
- string singleFile = BundleHelper.BundleApp(fixture);
+ // Bundle all content, until the host can handle other scenarios.
+ Bundler bundler = new Bundler(hostName, singleFileDir, BundleOptions.BundleAllContent);
+ string singleFile = BundleHelper.GenerateBundle(bundler, publishPath);
// Run the extracted app
RunTheApp(singleFile);
diff --git a/src/installer/test/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Bundle.Tests/BundleLegacy.cs b/src/installer/test/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Bundle.Tests/BundleLegacy.cs
index 7b9d6863607..a9c9b700064 100644
--- a/src/installer/test/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Bundle.Tests/BundleLegacy.cs
+++ b/src/installer/test/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Bundle.Tests/BundleLegacy.cs
@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
+using System.IO;
using Xunit;
using Microsoft.DotNet.Cli.Build.Framework;
using Microsoft.DotNet.CoreSetup.Test;
diff --git a/src/installer/test/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Bundle.Tests/BundlerConsistencyTests.cs b/src/installer/test/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Bundle.Tests/BundlerConsistencyTests.cs
index 00f3b1cc843..efa13283bd1 100644
--- a/src/installer/test/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Bundle.Tests/BundlerConsistencyTests.cs
+++ b/src/installer/test/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Bundle.Tests/BundlerConsistencyTests.cs
@@ -92,10 +92,18 @@ namespace Microsoft.NET.HostModel.Tests
public void TestFilesAlwaysBundled(BundleOptions options)
{
var fixture = sharedTestState.TestFixture.Copy();
- var bundler = BundleHelper.Bundle(fixture, options);
- var bundledFiles = BundleHelper.GetBundledFiles(fixture);
- Array.ForEach(bundledFiles, file => bundler.BundleManifest.Contains(file).Should().BeTrue());
+ var hostName = BundleHelper.GetHostName(fixture);
+ var appName = Path.GetFileNameWithoutExtension(hostName);
+ string publishPath = BundleHelper.GetPublishPath(fixture);
+ var bundleDir = BundleHelper.GetBundleDir(fixture);
+
+ var bundler = new Bundler(hostName, bundleDir.FullName, options);
+ BundleHelper.GenerateBundle(bundler, publishPath);
+
+ bundler.BundleManifest.Contains($"{appName}.dll").Should().BeTrue();
+ bundler.BundleManifest.Contains($"{appName}.deps.json").Should().BeTrue();
+ bundler.BundleManifest.Contains($"{appName}.runtimeconfig.json").Should().BeTrue();
}
[InlineData(BundleOptions.None)]
@@ -107,16 +115,20 @@ namespace Microsoft.NET.HostModel.Tests
public void TestFilesNeverBundled(BundleOptions options)
{
var fixture = sharedTestState.TestFixture.Copy();
- var appBaseName = BundleHelper.GetAppBaseName(fixture);
+
+ var hostName = BundleHelper.GetHostName(fixture);
+ var appName = Path.GetFileNameWithoutExtension(hostName);
string publishPath = BundleHelper.GetPublishPath(fixture);
+ var bundleDir = BundleHelper.GetBundleDir(fixture);
// Make up a app.runtimeconfig.dev.json file in the publish directory.
- File.Copy(Path.Combine(publishPath, $"{appBaseName}.runtimeconfig.json"),
- Path.Combine(publishPath, $"{appBaseName}.runtimeconfig.dev.json"));
+ File.Copy(Path.Combine(publishPath, $"{appName}.runtimeconfig.json"),
+ Path.Combine(publishPath, $"{appName}.runtimeconfig.dev.json"));
- var bundler = BundleHelper.Bundle(fixture, options);
+ var bundler = new Bundler(hostName, bundleDir.FullName, options);
+ BundleHelper.GenerateBundle(bundler, publishPath);
- bundler.BundleManifest.Contains($"{appBaseName}.runtimeconfig.dev.json").Should().BeFalse();
+ bundler.BundleManifest.Contains($"{appName}.runtimeconfig.dev.json").Should().BeFalse();
}
[InlineData(BundleOptions.None)]
@@ -125,10 +137,16 @@ namespace Microsoft.NET.HostModel.Tests
public void TestBundlingSymbols(BundleOptions options)
{
var fixture = sharedTestState.TestFixture.Copy();
- var appBaseName = BundleHelper.GetAppBaseName(fixture);
- var bundler = BundleHelper.Bundle(fixture, options);
- bundler.BundleManifest.Contains($"{appBaseName}.pdb").Should().Be(options.HasFlag(BundleOptions.BundleSymbolFiles));
+ var hostName = BundleHelper.GetHostName(fixture);
+ var appName = Path.GetFileNameWithoutExtension(hostName);
+ string publishPath = BundleHelper.GetPublishPath(fixture);
+ var bundleDir = BundleHelper.GetBundleDir(fixture);
+
+ var bundler = new Bundler(hostName, bundleDir.FullName, options);
+ BundleHelper.GenerateBundle(bundler, publishPath);
+
+ bundler.BundleManifest.Contains($"{appName}.pdb").Should().Be(options.HasFlag(BundleOptions.BundleSymbolFiles));
}
[InlineData(BundleOptions.None)]
@@ -137,28 +155,30 @@ namespace Microsoft.NET.HostModel.Tests
public void TestBundlingNativeBinaries(BundleOptions options)
{
var fixture = sharedTestState.TestFixture.Copy();
- var coreclr = Path.GetFileName(fixture.TestProject.CoreClrDll);
- var bundler = BundleHelper.Bundle(fixture, options);
- bundler.BundleManifest.Contains($"{coreclr}").Should().Be(options.HasFlag(BundleOptions.BundleNativeBinaries));
- }
+ var hostName = BundleHelper.GetHostName(fixture);
+ var hostfxr = Path.GetFileName(fixture.TestProject.HostFxrDll);
+ string publishPath = BundleHelper.GetPublishPath(fixture);
+ var bundleDir = BundleHelper.GetBundleDir(fixture);
- [Fact]
- public void TestFileSizes()
- {
- var fixture = sharedTestState.TestFixture.Copy();
- var bundler = BundleHelper.Bundle(fixture);
- var publishPath = BundleHelper.GetPublishPath(fixture);
+ var bundler = new Bundler(hostName, bundleDir.FullName, options);
+ BundleHelper.GenerateBundle(bundler, publishPath);
- bundler.BundleManifest.Files.ForEach(file =>
- Assert.True(file.Size == new FileInfo(Path.Combine(publishPath, file.RelativePath)).Length));
+ bundler.BundleManifest.Contains($"{hostfxr}").Should().Be(options.HasFlag(BundleOptions.BundleNativeBinaries));
}
[Fact]
public void TestAssemblyAlignment()
{
var fixture = sharedTestState.TestFixture.Copy();
- var bundler = BundleHelper.Bundle(fixture);
+
+ var hostName = BundleHelper.GetHostName(fixture);
+ var appName = Path.GetFileNameWithoutExtension(hostName);
+ string publishPath = BundleHelper.GetPublishPath(fixture);
+ var bundleDir = BundleHelper.GetBundleDir(fixture);
+
+ var bundler = new Bundler(hostName, bundleDir.FullName, BundleOptions.BundleAllContent);
+ BundleHelper.GenerateBundle(bundler, publishPath);
bundler.BundleManifest.Files.ForEach(file =>
Assert.True((file.Type != FileType.Assembly) || (file.Offset % Bundler.AssemblyAlignment == 0)));
@@ -168,7 +188,13 @@ namespace Microsoft.NET.HostModel.Tests
public void TestWithAdditionalContentAfterBundleMetadata()
{
var fixture = sharedTestState.TestFixture.Copy();
- string singleFile = BundleHelper.BundleApp(fixture);
+
+ var hostName = BundleHelper.GetHostName(fixture);
+ var bundleDir = BundleHelper.GetBundleDir(fixture);
+ string publishPath = BundleHelper.GetPublishPath(fixture);
+
+ var bundler = new Bundler(hostName, bundleDir.FullName, BundleOptions.BundleAllContent);
+ string singleFile = BundleHelper.GenerateBundle(bundler, publishPath);
using (var file = File.OpenWrite(singleFile))
{
diff --git a/src/installer/test/TestUtils/TestApp.cs b/src/installer/test/TestUtils/TestApp.cs
index a1ff67d95c8..3e4e72f1fe7 100644
--- a/src/installer/test/TestUtils/TestApp.cs
+++ b/src/installer/test/TestUtils/TestApp.cs
@@ -16,7 +16,6 @@ namespace Microsoft.DotNet.CoreSetup.Test
public string RuntimeDevConfigJson { get; private set; }
public string HostPolicyDll { get; private set; }
public string HostFxrDll { get; private set; }
- public string CoreClrDll { get; private set; }
public string AssemblyName { get; }
@@ -56,7 +55,6 @@ namespace Microsoft.DotNet.CoreSetup.Test
RuntimeDevConfigJson = Path.Combine(Location, $"{AssemblyName}.runtimeconfig.dev.json");
HostPolicyDll = Path.Combine(Location, RuntimeInformationExtensions.GetSharedLibraryFileNameForCurrentPlatform("hostpolicy"));
HostFxrDll = Path.Combine(Location, RuntimeInformationExtensions.GetSharedLibraryFileNameForCurrentPlatform("hostfxr"));
- CoreClrDll = Path.Combine(Location, RuntimeInformationExtensions.GetSharedLibraryFileNameForCurrentPlatform("coreclr"));
}
}
}
diff --git a/src/installer/test/TestUtils/TestProject.cs b/src/installer/test/TestUtils/TestProject.cs
index b512f4c1e6b..5fd9135beec 100644
--- a/src/installer/test/TestUtils/TestProject.cs
+++ b/src/installer/test/TestUtils/TestProject.cs
@@ -22,7 +22,6 @@ namespace Microsoft.DotNet.CoreSetup.Test
public string AppExe { get => BuiltApp?.AppExe; }
public string HostPolicyDll { get => BuiltApp?.HostPolicyDll; }
public string HostFxrDll { get => BuiltApp?.HostFxrDll; }
- public string CoreClrDll { get => BuiltApp?.CoreClrDll; }
public TestApp BuiltApp { get; private set; }