delete tfm constants (#79219)
authorkasperk81 <83082615+kasperk81@users.noreply.github.com>
Mon, 5 Dec 2022 14:44:24 +0000 (16:44 +0200)
committerGitHub <noreply@github.com>
Mon, 5 Dec 2022 14:44:24 +0000 (15:44 +0100)
src/installer/tests/HostActivation.Tests/FrameworkResolution/MultipleHives.cs
src/installer/tests/TestUtils/Constants.cs
src/installer/tests/TestUtils/RuntimeConfig.cs
src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/IntegrationTesting/src/Common/Tfm.cs [deleted file]
src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/IntegrationTesting/src/Deployers/ApplicationDeployer.cs
src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/IntegrationTesting/src/Deployers/SelfHostDeployer.cs
src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/ShutdownTests.cs

index cf2af06577adf5bb6bbcac0df8141b0afbec0abc..16ad7c34f793c475c016ad2ae93bd3475788610e 100644 (file)
@@ -61,7 +61,7 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution
         {
             RunTest(new TestSettings()
                     .WithRuntimeConfigCustomizer(runtimeConfig => runtimeConfig
-                        .WithTfm(Constants.Tfm.Net6)
+                        .WithTfm("net6.0")
                         .WithFramework(MicrosoftNETCoreApp, "5.0.0"))
                     .WithWorkingDirectory(SharedState.DotNetCurrentHive.BinPath),
                 multiLevelLookup: true)
index bba6b13a305167409f739ef5498ed278251e14eb..90fddc16bef39988c0329846437ab7eb29def2d2 100644 (file)
@@ -33,14 +33,6 @@ namespace Microsoft.DotNet.CoreSetup.Test
             public const string Disable = "Disable";
         }
 
-        public static class Tfm
-        {
-            public const string RuntimeConfigPropertyName = "tfm";
-            public const string Net6 = "net6.0";
-            public const string Net7 = "net7.0";
-            public const string Net8 = "net8.0";
-        }
-
         public static class FxVersion
         {
             public const string CommandLineArgument = "--fx-version";
index 057346a31922ecd96062fd77b7c1aa8ec67f5f1d..269918a963f0986fd3ce31bc2a2e13d82e4ec678 100644 (file)
@@ -279,9 +279,7 @@ namespace Microsoft.DotNet.CoreSetup.Test
 
             if (_tfm is not null)
             {
-                runtimeOptions.Add(
-                    Constants.Tfm.RuntimeConfigPropertyName,
-                    _tfm);
+                runtimeOptions.Add("tfm", _tfm);
             }
 
             if (_properties.Count > 0)
diff --git a/src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/IntegrationTesting/src/Common/Tfm.cs b/src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/IntegrationTesting/src/Common/Tfm.cs
deleted file mode 100644 (file)
index a4ae0c1..0000000
+++ /dev/null
@@ -1,23 +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 Microsoft.Extensions.Hosting.IntegrationTesting
-{
-    public static class Tfm
-    {
-        public const string Net462 = "net462";
-        public const string NetCoreApp20 = "netcoreapp2.0";
-        public const string NetCoreApp21 = "netcoreapp2.1";
-        public const string NetCoreApp22 = "netcoreapp2.2";
-        public const string NetCoreApp30 = "netcoreapp3.0";
-        public const string NetCoreApp31 = "netcoreapp3.1";
-        public const string NetCoreApp50 = "net5.0";
-
-        public static bool Matches(string tfm1, string tfm2)
-        {
-            return string.Equals(tfm1, tfm2, StringComparison.OrdinalIgnoreCase);
-        }
-    }
-}
index 37540702fcb75f7a0ba62772f75e68329112510d..34c5832beedabb95bf01fc9bea4ad4321a4b02d0 100644 (file)
@@ -61,7 +61,7 @@ namespace Microsoft.Extensions.Hosting.IntegrationTesting
 
         private RuntimeFlavor GetRuntimeFlavor(string tfm)
         {
-            if (Tfm.Matches(Tfm.Net462, tfm))
+            if (tfm.ToLowerInvariant() == "net462")
             {
                 return RuntimeFlavor.Clr;
             }
index 79e87c59ee9801529e925c173b2e9841dc10306e..0ef58a0d95924dfdc90e3b553a6f188671232080 100644 (file)
@@ -83,8 +83,9 @@ namespace Microsoft.Extensions.Hosting.IntegrationTesting
                 {
                     // Core+Standalone always publishes. This must be Clr+Standalone or Core+Portable.
                     // Run from the pre-built bin/{config}/{tfm} directory.
+                    Version version = Environment.Version;
                     var targetFramework = DeploymentParameters.TargetFramework
-                        ?? (DeploymentParameters.RuntimeFlavor == RuntimeFlavor.Clr ? Tfm.Net462 : Tfm.NetCoreApp22);
+                        ?? (DeploymentParameters.RuntimeFlavor == RuntimeFlavor.Clr ? "net462" : $"net{version.Major}.{version.Minor}");
                     workingDirectory = Path.Combine(DeploymentParameters.ApplicationPath, "bin", DeploymentParameters.Configuration, targetFramework);
                     // CurrentDirectory will point to bin/{config}/{tfm}, but the config and static files aren't copied, point to the app base instead.
                     DeploymentParameters.EnvironmentVariables["DOTNET_CONTENTROOT"] = DeploymentParameters.ApplicationPath;
index d04ed442a9444ffc252b54d947bee4f701d8c1c1..4625de304dd3ea0cdc196e5853d292646c58242f 100644 (file)
@@ -58,12 +58,13 @@ namespace Microsoft.AspNetCore.Hosting.FunctionalTests
             var applicationPath = string.Empty; // disabled for now
 #pragma warning restore 0618
 
+            Version version = Environment.Version;
             var deploymentParameters = new DeploymentParameters(
                 applicationPath,
                 RuntimeFlavor.CoreClr,
                 RuntimeArchitecture.x64)
             {
-                TargetFramework = Tfm.NetCoreApp50,
+                TargetFramework = $"Environment{version.Major}.{version.Minor}",
                 ApplicationType = ApplicationType.Portable,
                 PublishApplicationBeforeDeployment = true,
                 StatusMessagesEnabled = false