diff --git a/eng/Subsets.props b/eng/Subsets.props
index ce90e8748f887..882c69fb160cb 100644
--- a/eng/Subsets.props
+++ b/eng/Subsets.props
@@ -489,8 +489,7 @@
-
-
+
diff --git a/src/installer/tests/Assets/Projects/Directory.Build.props b/src/installer/tests/Assets/Projects/Directory.Build.props
index becedfd843015..2d331dfb98451 100644
--- a/src/installer/tests/Assets/Projects/Directory.Build.props
+++ b/src/installer/tests/Assets/Projects/Directory.Build.props
@@ -4,7 +4,7 @@
true
true
- false
+ false
false
$(ArtifactsDir)tests\host\$(TargetOS).$(TargetArchitecture).$(Configuration)\$(MSBuildProjectName)
diff --git a/src/installer/tests/Assets/Projects/Directory.Build.targets b/src/installer/tests/Assets/Projects/Directory.Build.targets
index 6b927a86178bd..09d445f31a2fa 100644
--- a/src/installer/tests/Assets/Projects/Directory.Build.targets
+++ b/src/installer/tests/Assets/Projects/Directory.Build.targets
@@ -3,6 +3,10 @@
+
+ false
+
+
+
+ HelloWorld
+ net6.0
+ Exe
+ true
+ true
+ false
+
+
+ $(OutputRID)
+
+
diff --git a/src/installer/tests/Assets/TestProjects/StandaloneApp6x/Program.cs b/src/installer/tests/Assets/TestProjects/StandaloneApp6x/Program.cs
deleted file mode 100644
index 2bb065a6e980d..0000000000000
--- a/src/installer/tests/Assets/TestProjects/StandaloneApp6x/Program.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System;
-
-namespace StandaloneApp
-{
- public static class Program
- {
- public static void Main(string[] args)
- {
- Console.WriteLine("Hello World!");
- }
- }
-}
diff --git a/src/installer/tests/Assets/TestProjects/StandaloneApp6x/StandaloneApp6x.csproj b/src/installer/tests/Assets/TestProjects/StandaloneApp6x/StandaloneApp6x.csproj
deleted file mode 100644
index 4e8ab62907044..0000000000000
--- a/src/installer/tests/Assets/TestProjects/StandaloneApp6x/StandaloneApp6x.csproj
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
- StandaloneApp
- net6.0
- Exe
- $(TestTargetRid)
- true
-
-
diff --git a/src/installer/tests/HostActivation.Tests/HostVersionCompatibility.cs b/src/installer/tests/HostActivation.Tests/HostVersionCompatibility.cs
index e96c402266173..a12bab3825dc3 100644
--- a/src/installer/tests/HostActivation.Tests/HostVersionCompatibility.cs
+++ b/src/installer/tests/HostActivation.Tests/HostVersionCompatibility.cs
@@ -21,22 +21,23 @@ public HostVersionCompatibility(SharedTestState fixture)
[Fact]
public void LatestHost_OldRuntime_BackwardsCompatible_60()
{
- LatestHost_OldRuntime_BackwardsCompatible(sharedTestState.Fixture60);
+ LatestHost_OldRuntime_BackwardsCompatible(sharedTestState.App60);
}
- private void LatestHost_OldRuntime_BackwardsCompatible(TestProjectFixture previousVersionFixture)
+ private void LatestHost_OldRuntime_BackwardsCompatible(TestApp previousVersionApp)
{
- TestProjectFixture fixture = previousVersionFixture.Copy();
- string appExe = fixture.TestProject.AppExe;
+ TestApp app = previousVersionApp.Copy();
+ string appExe = app.AppExe;
- Assert.NotEqual(fixture.Framework, RepoDirectoriesProvider.Default.Tfm);
- Assert.NotEqual(fixture.RepoDirProvider.MicrosoftNETCoreAppVersion, RepoDirectoriesProvider.Default.MicrosoftNETCoreAppVersion);
+ RuntimeConfig appConfig = RuntimeConfig.FromFile(app.RuntimeConfigJson);
+ Assert.NotEqual(appConfig.Tfm, RepoDirectoriesProvider.Default.Tfm);
+ Assert.NotEqual(appConfig.GetIncludedFramework(Constants.MicrosoftNETCoreApp).Version, RepoDirectoriesProvider.Default.MicrosoftNETCoreAppVersion);
// Use the newer apphost
// This emulates the case when:
// 1) Newer runtime installed
// 2) Newer runtime uninstalled (installer preserves newer apphost)
- fixture.TestProject.BuiltApp.CreateAppHost();
+ app.CreateAppHost();
Command.Create(appExe)
.EnableTracingAndCaptureOutputs()
.Execute()
@@ -48,7 +49,7 @@ private void LatestHost_OldRuntime_BackwardsCompatible(TestProjectFixture previo
// This emulates the case when:
// 1) Newer runtime installed
// 2) A roll-forward to the newer runtime did not occur
- File.Copy(Binaries.HostFxr.FilePath, fixture.TestProject.HostFxrDll, true);
+ File.Copy(Binaries.HostFxr.FilePath, app.HostFxrDll, true);
Command.Create(appExe)
.EnableTracingAndCaptureOutputs()
.Execute()
@@ -60,28 +61,30 @@ private void LatestHost_OldRuntime_BackwardsCompatible(TestProjectFixture previo
[Fact]
public void OldHost_LatestRuntime_ForwardCompatible_60()
{
- OldHost_LatestRuntime_ForwardCompatible(sharedTestState.Fixture60);
+ OldHost_LatestRuntime_ForwardCompatible(sharedTestState.App60);
}
- private void OldHost_LatestRuntime_ForwardCompatible(TestProjectFixture previousVersionFixture)
+ private void OldHost_LatestRuntime_ForwardCompatible(TestApp previousVersionApp)
{
TestApp app = sharedTestState.AppLatest.Copy();
string appExe = app.AppExe;
- Assert.NotEqual(RepoDirectoriesProvider.Default.Tfm, previousVersionFixture.Framework);
- Assert.NotEqual(RepoDirectoriesProvider.Default.MicrosoftNETCoreAppVersion, previousVersionFixture.RepoDirProvider.MicrosoftNETCoreAppVersion);
+ RuntimeConfig previousAppConfig = RuntimeConfig.FromFile(previousVersionApp.RuntimeConfigJson);
+ string previousVersion = previousAppConfig.GetIncludedFramework(Constants.MicrosoftNETCoreApp).Version;
+ Assert.NotEqual(RepoDirectoriesProvider.Default.Tfm, previousAppConfig.Tfm);
+ Assert.NotEqual(RepoDirectoriesProvider.Default.MicrosoftNETCoreAppVersion, previousVersion);
// Use the older apphost
// This emulates the case when:
// 1) Newer runtime installed
// 2) App rolls forward to newer runtime
- File.Copy(previousVersionFixture.TestProject.AppExe, appExe, true);
+ File.Copy(previousVersionApp.AppExe, appExe, true);
Command.Create(appExe)
.EnableTracingAndCaptureOutputs()
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World")
- .And.HaveStdErrContaining($"--- Invoked apphost [version: {previousVersionFixture.RepoDirProvider.MicrosoftNETCoreAppVersion}");
+ .And.HaveStdErrContaining($"--- Invoked apphost [version: {previousVersion}");
// Use the older apphost and hostfxr
// This emulates the case when:
@@ -90,30 +93,26 @@ private void OldHost_LatestRuntime_ForwardCompatible(TestProjectFixture previous
// Note that we don't have multi-level on hostfxr so we will always find the older\one-off hostfxr
if (OperatingSystem.IsWindows())
{
- File.Copy(previousVersionFixture.TestProject.HostFxrDll, app.HostFxrDll, true);
+ File.Copy(previousVersionApp.HostFxrDll, app.HostFxrDll, true);
Command.Create(appExe)
.EnableTracingAndCaptureOutputs()
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World")
- .And.HaveStdErrContaining($"--- Invoked apphost [version: {previousVersionFixture.RepoDirProvider.MicrosoftNETCoreAppVersion}");
+ .And.HaveStdErrContaining($"--- Invoked apphost [version: {previousVersion}");
}
}
public class SharedTestState : IDisposable
{
- private static RepoDirectoriesProvider RepoDirectories { get; set; }
-
- public TestProjectFixture Fixture60 { get; }
+ public TestApp App60 { get; }
public TestApp AppLatest { get; }
private const string AppName = "HelloWorld";
public SharedTestState()
{
- RepoDirectories = new RepoDirectoriesProvider();
-
- Fixture60 = CreateTestFixture("StandaloneApp6x", "net6.0", "6.0");
+ App60 = TestApp.CreateFromBuiltAssets(AppName, Path.Combine("SelfContained", "net6.0"));
AppLatest = TestApp.CreateFromBuiltAssets(AppName);
AppLatest.PopulateSelfContained(TestApp.MockedComponent.None);
@@ -121,22 +120,9 @@ public SharedTestState()
public void Dispose()
{
- Fixture60.Dispose();
+ App60?.Dispose();
AppLatest?.Dispose();
}
-
- private static TestProjectFixture CreateTestFixture(string testName, string netCoreAppFramework, string mnaVersion)
- {
- var repoDirectories = new RepoDirectoriesProvider(microsoftNETCoreAppVersion: mnaVersion);
-
- // Use standalone instead of framework-dependent for ease of deployment.
- var publishFixture = new TestProjectFixture(testName, repoDirectories, framework: netCoreAppFramework, assemblyName: AppName);
- publishFixture
- .EnsureRestoredForRid(publishFixture.CurrentRid)
- .PublishProject(runtime: publishFixture.CurrentRid, selfContained: true, extraArgs: $"/p:AssemblyName={AppName}");
-
- return publishFixture;
- }
}
}
}
diff --git a/src/installer/tests/TestUtils/RuntimeConfig.cs b/src/installer/tests/TestUtils/RuntimeConfig.cs
index 8a456bd8b08c5..8b6ed542fcbb6 100644
--- a/src/installer/tests/TestUtils/RuntimeConfig.cs
+++ b/src/installer/tests/TestUtils/RuntimeConfig.cs
@@ -172,6 +172,8 @@ public static RuntimeConfig Path(string path)
return new RuntimeConfig(path);
}
+ public string Tfm => _tfm;
+
public Framework GetFramework(string name)
{
return _frameworks.FirstOrDefault(f => f.Name == name);
@@ -199,6 +201,11 @@ public RuntimeConfig RemoveFramework(string name)
return this;
}
+ public Framework GetIncludedFramework(string name)
+ {
+ return _includedFrameworks.FirstOrDefault(f => f.Name == name);
+ }
+
public RuntimeConfig WithIncludedFramework(Framework framework)
{
_includedFrameworks.Add(framework);
diff --git a/src/installer/tests/TestUtils/TestApp.cs b/src/installer/tests/TestUtils/TestApp.cs
index eab1ed629fbff..ccc46f9308242 100644
--- a/src/installer/tests/TestUtils/TestApp.cs
+++ b/src/installer/tests/TestUtils/TestApp.cs
@@ -50,11 +50,20 @@ public static TestApp CreateEmpty(string name)
};
}
- public static TestApp CreateFromBuiltAssets(string appName)
+ ///
+ /// Create a test app from pre-built output of .
+ ///
+ /// Name of pre-built app
+ /// Path to asset - relative to the directory containing all pre-built assets
+ ///
+ /// If is null, is used as the relative path.
+ ///
+ public static TestApp CreateFromBuiltAssets(string appName, string assetRelativePath = null)
{
+ assetRelativePath = assetRelativePath ?? appName;
TestApp app = CreateEmpty(appName);
TestArtifact.CopyRecursive(
- Path.Combine(RepoDirectoriesProvider.Default.TestAssetsOutput, appName),
+ Path.Combine(RepoDirectoriesProvider.Default.TestAssetsOutput, assetRelativePath),
app.Location);
return app;
}