From 7d1aa71e87551e1463b086a6652abb2e58ad10af Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Thu, 29 Aug 2024 11:24:43 -0700 Subject: [PATCH 1/2] Make missing framework error message list other architectures that were found --- src/native/corehost/fxr/fx_resolver.cpp | 2 +- src/native/corehost/fxr/fx_resolver.h | 1 - .../corehost/fxr/fx_resolver.messages.cpp | 41 ++++++++++++------- src/native/corehost/fxr/install_info.cpp | 19 ++++++--- src/native/corehost/fxr/install_info.h | 2 + src/native/corehost/hostmisc/utils.h | 7 ---- 6 files changed, 44 insertions(+), 28 deletions(-) diff --git a/src/native/corehost/fxr/fx_resolver.cpp b/src/native/corehost/fxr/fx_resolver.cpp index e78bd63eca1096..c109fa257121c7 100644 --- a/src/native/corehost/fxr/fx_resolver.cpp +++ b/src/native/corehost/fxr/fx_resolver.cpp @@ -540,7 +540,7 @@ StatusCode fx_resolver_t::resolve_frameworks_for_app( _X("Architecture: %s"), app_display_name, get_current_arch_name()); - display_missing_framework_error(resolution_failure.missing.get_fx_name(), resolution_failure.missing.get_fx_version(), pal::string_t(), dotnet_root, app_config.get_is_multilevel_lookup_disabled()); + display_missing_framework_error(resolution_failure.missing.get_fx_name(), resolution_failure.missing.get_fx_version(), dotnet_root, app_config.get_is_multilevel_lookup_disabled()); break; case StatusCode::FrameworkCompatFailure: display_incompatible_framework_error(resolution_failure.incompatible_higher.get_fx_version(), resolution_failure.incompatible_lower); diff --git a/src/native/corehost/fxr/fx_resolver.h b/src/native/corehost/fxr/fx_resolver.h index 466decd846fc90..9abfd706baadc1 100644 --- a/src/native/corehost/fxr/fx_resolver.h +++ b/src/native/corehost/fxr/fx_resolver.h @@ -64,7 +64,6 @@ class fx_resolver_t static void display_missing_framework_error( const pal::string_t& fx_name, const pal::string_t& fx_version, - const pal::string_t& fx_dir, const pal::string_t& dotnet_root, bool disable_multilevel_lookup); static void display_incompatible_framework_error( diff --git a/src/native/corehost/fxr/fx_resolver.messages.cpp b/src/native/corehost/fxr/fx_resolver.messages.cpp index e87cd6d0fbacb4..a922858ae5b390 100644 --- a/src/native/corehost/fxr/fx_resolver.messages.cpp +++ b/src/native/corehost/fxr/fx_resolver.messages.cpp @@ -3,6 +3,7 @@ #include "fx_resolver.h" #include "framework_info.h" +#include "install_info.h" /** * When the framework is referenced more than once in a non-compatible way, display detailed error message @@ -92,23 +93,9 @@ void fx_resolver_t::display_summary_of_frameworks( void fx_resolver_t::display_missing_framework_error( const pal::string_t& fx_name, const pal::string_t& fx_version, - const pal::string_t& fx_dir, const pal::string_t& dotnet_root, bool disable_multilevel_lookup) { - std::vector framework_infos; - pal::string_t fx_ver_dirs; - if (fx_dir.length()) - { - fx_ver_dirs = fx_dir; - framework_info::get_all_framework_infos(get_directory(fx_dir), fx_name.c_str(), disable_multilevel_lookup, &framework_infos); - } - else - { - fx_ver_dirs = dotnet_root; - } - - framework_info::get_all_framework_infos(dotnet_root, fx_name.c_str(), disable_multilevel_lookup, &framework_infos); // Display the error message about missing FX. if (fx_version.length()) @@ -122,6 +109,8 @@ void fx_resolver_t::display_missing_framework_error( trace::error(_X(".NET location: %s\n"), dotnet_root.c_str()); + std::vector framework_infos; + framework_info::get_all_framework_infos(dotnet_root, fx_name.c_str(), disable_multilevel_lookup, &framework_infos); if (framework_infos.size()) { trace::error(_X("The following frameworks were found:")); @@ -135,6 +124,30 @@ void fx_resolver_t::display_missing_framework_error( trace::error(_X("No frameworks were found.")); } + std::vector>> other_arch_framework_infos; + install_info::enumerate_other_architectures( + [&](pal::architecture arch, const pal::string_t& install_location, bool is_registered) + { + std::vector other_arch_infos; + framework_info::get_all_framework_infos(install_location, fx_name.c_str(), disable_multilevel_lookup, &other_arch_infos); + if (!other_arch_infos.empty()) + { + other_arch_framework_infos.push_back(std::make_pair(arch, std::move(other_arch_infos))); + } + }); + if (!other_arch_framework_infos.empty()) + { + trace::error(_X("\nThe following frameworks for other architectures were found:")); + for (const auto& arch_info_pair : other_arch_framework_infos) + { + trace::error(_X(" %s"), get_arch_name(arch_info_pair.first)); + for (const framework_info& info : arch_info_pair.second) + { + trace::error(_X(" %s at [%s]"), info.version.as_str().c_str(), info.path.c_str()); + } + } + } + pal::string_t url = get_download_url(fx_name.c_str(), fx_version.c_str()); trace::error( _X("\n") diff --git a/src/native/corehost/fxr/install_info.cpp b/src/native/corehost/fxr/install_info.cpp index ff231938db0d87..281457f115820f 100644 --- a/src/native/corehost/fxr/install_info.cpp +++ b/src/native/corehost/fxr/install_info.cpp @@ -31,7 +31,7 @@ bool install_info::print_environment(const pal::char_t* leading_whitespace) return found_any; } -bool install_info::print_other_architectures(const pal::char_t* leading_whitespace) +bool install_info::enumerate_other_architectures(std::function callback) { bool found_any = false; for (uint32_t i = 0; i < static_cast(pal::architecture::__last); ++i) @@ -47,13 +47,22 @@ bool install_info::print_other_architectures(const pal::char_t* leading_whitespa { found_any = true; remove_trailing_dir_separator(&install_location); + callback(arch, install_location, is_registered); + } + } + + return found_any; +} + +bool install_info::print_other_architectures(const pal::char_t* leading_whitespace) +{ + return enumerate_other_architectures( + [&](pal::architecture arch, const pal::string_t& install_location, bool is_registered) + { trace::println(_X("%s%-5s [%s]"), leading_whitespace, get_arch_name(arch), install_location.c_str()); if (is_registered) { trace::println(_X("%s registered at [%s]"), leading_whitespace, pal::get_dotnet_self_registered_config_location(arch).c_str()); } - } - } - - return found_any; + }); } diff --git a/src/native/corehost/fxr/install_info.h b/src/native/corehost/fxr/install_info.h index 3a100486b8f3e5..3f9d5910268487 100644 --- a/src/native/corehost/fxr/install_info.h +++ b/src/native/corehost/fxr/install_info.h @@ -5,9 +5,11 @@ #define __INSTALL_INFO_H__ #include "pal.h" +#include namespace install_info { + bool enumerate_other_architectures(std::function callback); bool print_environment(const pal::char_t* leading_whitespace); bool print_other_architectures(const pal::char_t* leading_whitespace); }; diff --git a/src/native/corehost/hostmisc/utils.h b/src/native/corehost/hostmisc/utils.h index 5d782a070f8b8e..52c6754d290a7f 100644 --- a/src/native/corehost/hostmisc/utils.h +++ b/src/native/corehost/hostmisc/utils.h @@ -10,13 +10,6 @@ #include #include -#if defined(_WIN32) -#define DOTNET_CORE_INSTALL_PREREQUISITES_URL _X("https://go.microsoft.com/fwlink/?linkid=798306") -#elif defined(TARGET_OSX) -#define DOTNET_CORE_INSTALL_PREREQUISITES_URL _X("https://go.microsoft.com/fwlink/?linkid=2063366") -#else -#define DOTNET_CORE_INSTALL_PREREQUISITES_URL _X("https://go.microsoft.com/fwlink/?linkid=2063370") -#endif #define DOTNET_CORE_DOWNLOAD_URL _X("https://aka.ms/dotnet/download") #define DOTNET_CORE_APPLAUNCH_URL _X("https://aka.ms/dotnet-core-applaunch") From c17d51a2488d2b29e11ddc9cc18ad6ca3d4470cb Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Thu, 29 Aug 2024 11:26:05 -0700 Subject: [PATCH 2/2] Add test --- .../ApplyPatchesSettings.cs | 2 + .../FrameworkResolution/ComplexHierarchies.cs | 2 + .../FrameworkResolutionBase.Settings.cs | 6 +-- .../FrameworkResolutionBase.cs | 5 --- .../FrameworkResolution/FxVersionCLI.cs | 2 + .../IncludedFrameworksSettings.cs | 2 + .../FrameworkResolution/MultipleHives.cs | 45 +++++++++++++++++++ ...rdAndRollForwardOnNoCandidateFxSettings.cs | 2 + .../RollForwardMultipleFrameworks.cs | 2 + .../RollForwardOnNoCandidateFx.cs | 4 +- ...orwardOnNoCandidateFxMultipleFrameworks.cs | 2 + .../RollForwardOnNoCandidateFxSettings.cs | 2 + .../RollForwardPreReleaseOnly.cs | 2 + .../RollForwardReleaseAndPreRelease.cs | 2 + .../RollForwardReleaseOnly.cs | 2 + .../RollForwardSettings.cs | 2 + src/installer/tests/TestUtils/Constants.cs | 6 ++- 17 files changed, 80 insertions(+), 10 deletions(-) diff --git a/src/installer/tests/HostActivation.Tests/FrameworkResolution/ApplyPatchesSettings.cs b/src/installer/tests/HostActivation.Tests/FrameworkResolution/ApplyPatchesSettings.cs index d747ee016f47df..3d00d7a02db589 100644 --- a/src/installer/tests/HostActivation.Tests/FrameworkResolution/ApplyPatchesSettings.cs +++ b/src/installer/tests/HostActivation.Tests/FrameworkResolution/ApplyPatchesSettings.cs @@ -5,6 +5,8 @@ using Microsoft.DotNet.Cli.Build.Framework; using Xunit; +using static Microsoft.DotNet.CoreSetup.Test.Constants; + namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution { public class ApplyPatchesSettings : diff --git a/src/installer/tests/HostActivation.Tests/FrameworkResolution/ComplexHierarchies.cs b/src/installer/tests/HostActivation.Tests/FrameworkResolution/ComplexHierarchies.cs index 9a474ba7de7c06..b8c3f82e77485a 100644 --- a/src/installer/tests/HostActivation.Tests/FrameworkResolution/ComplexHierarchies.cs +++ b/src/installer/tests/HostActivation.Tests/FrameworkResolution/ComplexHierarchies.cs @@ -6,6 +6,8 @@ using System; using Xunit; +using static Microsoft.DotNet.CoreSetup.Test.Constants; + namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution { public class ComplexHierarchies : diff --git a/src/installer/tests/HostActivation.Tests/FrameworkResolution/FrameworkResolutionBase.Settings.cs b/src/installer/tests/HostActivation.Tests/FrameworkResolution/FrameworkResolutionBase.Settings.cs index 81f2e14a35f527..9b8a63b9a65025 100644 --- a/src/installer/tests/HostActivation.Tests/FrameworkResolution/FrameworkResolutionBase.Settings.cs +++ b/src/installer/tests/HostActivation.Tests/FrameworkResolution/FrameworkResolutionBase.Settings.cs @@ -85,7 +85,7 @@ public enum SettingLocation public static Func RollForwardSetting( SettingLocation location, string value, - string frameworkReferenceName = MicrosoftNETCoreApp) + string frameworkReferenceName = Constants.MicrosoftNETCoreApp) { if (value == null || location == SettingLocation.None) { @@ -114,7 +114,7 @@ public static Func RollForwardSetting( public static Func RollForwardOnNoCandidateFxSetting( SettingLocation location, int? value, - string frameworkReferenceName = MicrosoftNETCoreApp) + string frameworkReferenceName = Constants.MicrosoftNETCoreApp) { if (!value.HasValue || location == SettingLocation.None) { @@ -143,7 +143,7 @@ public static Func RollForwardOnNoCandidateFxSetting public static Func ApplyPatchesSetting( SettingLocation location, bool? value, - string frameworkReferenceName = MicrosoftNETCoreApp) + string frameworkReferenceName = Constants.MicrosoftNETCoreApp) { if (!value.HasValue || location == SettingLocation.None) { diff --git a/src/installer/tests/HostActivation.Tests/FrameworkResolution/FrameworkResolutionBase.cs b/src/installer/tests/HostActivation.Tests/FrameworkResolution/FrameworkResolutionBase.cs index a0ce8d0cf3963d..b098994df8ae65 100644 --- a/src/installer/tests/HostActivation.Tests/FrameworkResolution/FrameworkResolutionBase.cs +++ b/src/installer/tests/HostActivation.Tests/FrameworkResolution/FrameworkResolutionBase.cs @@ -11,8 +11,6 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution { public abstract partial class FrameworkResolutionBase { - protected const string MicrosoftNETCoreApp = "Microsoft.NETCore.App"; - public static class ResolvedFramework { public const string NotFound = "[not found]"; @@ -23,7 +21,6 @@ protected CommandResult RunTest( DotNetCli dotnet, TestApp app, TestSettings settings, - Action resultAction = null, bool? multiLevelLookup = false) { using (DotNetCliExtensions.DotNetCliCustomizer dotnetCustomizer = settings.DotnetCustomizer == null ? null : dotnet.Customize()) @@ -53,8 +50,6 @@ protected CommandResult RunTest( .Environment(settings.Environment) .Execute(); - resultAction?.Invoke(result); - return result; } } diff --git a/src/installer/tests/HostActivation.Tests/FrameworkResolution/FxVersionCLI.cs b/src/installer/tests/HostActivation.Tests/FrameworkResolution/FxVersionCLI.cs index 10057216bc36de..5d09a35ff67b84 100644 --- a/src/installer/tests/HostActivation.Tests/FrameworkResolution/FxVersionCLI.cs +++ b/src/installer/tests/HostActivation.Tests/FrameworkResolution/FxVersionCLI.cs @@ -5,6 +5,8 @@ using Microsoft.DotNet.Cli.Build.Framework; using Xunit; +using static Microsoft.DotNet.CoreSetup.Test.Constants; + namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution { public class FXVersionCLI : diff --git a/src/installer/tests/HostActivation.Tests/FrameworkResolution/IncludedFrameworksSettings.cs b/src/installer/tests/HostActivation.Tests/FrameworkResolution/IncludedFrameworksSettings.cs index af8aa1dc3b5931..ec5ae8306693cf 100644 --- a/src/installer/tests/HostActivation.Tests/FrameworkResolution/IncludedFrameworksSettings.cs +++ b/src/installer/tests/HostActivation.Tests/FrameworkResolution/IncludedFrameworksSettings.cs @@ -5,6 +5,8 @@ using Microsoft.DotNet.Cli.Build.Framework; using Xunit; +using static Microsoft.DotNet.CoreSetup.Test.Constants; + namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution { public class IncludedFrameworksSettings : diff --git a/src/installer/tests/HostActivation.Tests/FrameworkResolution/MultipleHives.cs b/src/installer/tests/HostActivation.Tests/FrameworkResolution/MultipleHives.cs index 1fb612efb38264..e44a58272515f5 100644 --- a/src/installer/tests/HostActivation.Tests/FrameworkResolution/MultipleHives.cs +++ b/src/installer/tests/HostActivation.Tests/FrameworkResolution/MultipleHives.cs @@ -8,6 +8,7 @@ using Microsoft.DotNet.Cli.Build; using Microsoft.DotNet.Cli.Build.Framework; using Xunit; +using static Microsoft.DotNet.CoreSetup.Test.Constants; namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution { @@ -217,6 +218,50 @@ public void FrameworkResolutionError(string tfm, bool? multiLevelLookup, bool ef .And.HaveStdErrContaining("Ignoring FX version [9999.9.9] without .deps.json"); } + [Fact] + public void FrameworkResolutionError_ListOtherArchitectures() + { + using (var registeredInstallLocationOverride = new RegisteredInstallLocationOverride(SharedState.DotNetMainHive.GreatestVersionHostFxrFilePath)) + using (var otherArchArtifact = TestArtifact.Create("otherArch")) + { + string requestedVersion = "9999.9.9"; + string[] otherArchs = ["arm64", "x64", "x86"]; + var installLocations = new (string, string)[otherArchs.Length]; + for (int i = 0; i < otherArchs.Length; i++) + { + string arch = otherArchs[i]; + + // Create a .NET install with Microsoft.NETCoreApp at the registered location + var dotnet = new DotNetBuilder(otherArchArtifact.Location, TestContext.BuiltDotNet.BinPath, arch) + .AddMicrosoftNETCoreAppFrameworkMockHostPolicy(requestedVersion) + .Build(); + installLocations[i] = (arch, dotnet.BinPath); + } + + registeredInstallLocationOverride.SetInstallLocation(installLocations); + + CommandResult result = RunTest( + new TestSettings() + .WithRuntimeConfigCustomizer(c => c.WithFramework(MicrosoftNETCoreApp, requestedVersion)) + .WithEnvironment(TestOnlyEnvironmentVariables.RegisteredConfigLocation, registeredInstallLocationOverride.PathValueOverride), + multiLevelLookup: null); + + result.ShouldFailToFindCompatibleFrameworkVersion(MicrosoftNETCoreApp, requestedVersion) + .And.HaveStdErrContaining("The following frameworks for other architectures were found:"); + + // Error message should list framework found for other architectures + foreach ((string arch, string path) in installLocations) + { + if (arch == TestContext.BuildArchitecture) + continue; + + string expectedPath = System.Text.RegularExpressions.Regex.Escape(Path.Combine(path, "shared", MicrosoftNETCoreApp)); + result.Should() + .HaveStdErrMatching($@"{arch}\s*{requestedVersion} at \[{expectedPath}\]", System.Text.RegularExpressions.RegexOptions.Multiline); + } + } + } + private CommandResult RunTest(Func runtimeConfig, bool? multiLevelLookup = true) => RunTest(new TestSettings().WithRuntimeConfigCustomizer(runtimeConfig), multiLevelLookup); diff --git a/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardAndRollForwardOnNoCandidateFxSettings.cs b/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardAndRollForwardOnNoCandidateFxSettings.cs index 6555683bacd121..ab486868f661eb 100644 --- a/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardAndRollForwardOnNoCandidateFxSettings.cs +++ b/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardAndRollForwardOnNoCandidateFxSettings.cs @@ -5,6 +5,8 @@ using Microsoft.DotNet.Cli.Build.Framework; using Xunit; +using static Microsoft.DotNet.CoreSetup.Test.Constants; + namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution { public class RollForwardAndRollForwardOnNoCandidateFxSettings : diff --git a/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardMultipleFrameworks.cs b/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardMultipleFrameworks.cs index 26e2d11a2f13ae..8501e85e3698aa 100644 --- a/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardMultipleFrameworks.cs +++ b/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardMultipleFrameworks.cs @@ -6,6 +6,8 @@ using System; using Xunit; +using static Microsoft.DotNet.CoreSetup.Test.Constants; + namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution { public class RollForwardMultipleFrameworks : diff --git a/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardOnNoCandidateFx.cs b/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardOnNoCandidateFx.cs index 20a3f7796de864..835976248aed9d 100644 --- a/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardOnNoCandidateFx.cs +++ b/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardOnNoCandidateFx.cs @@ -1,11 +1,13 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using Microsoft.DotNet.Cli.Build; using Microsoft.DotNet.Cli.Build.Framework; -using System; using Xunit; +using static Microsoft.DotNet.CoreSetup.Test.Constants; + namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution { public class RollForwardOnNoCandidateFx : diff --git a/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardOnNoCandidateFxMultipleFrameworks.cs b/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardOnNoCandidateFxMultipleFrameworks.cs index 8db6771f6c0423..ff756cb7c774fb 100644 --- a/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardOnNoCandidateFxMultipleFrameworks.cs +++ b/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardOnNoCandidateFxMultipleFrameworks.cs @@ -6,6 +6,8 @@ using System; using Xunit; +using static Microsoft.DotNet.CoreSetup.Test.Constants; + namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution { public class RollForwardOnNoCandidateFxMultipleFrameworks : diff --git a/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardOnNoCandidateFxSettings.cs b/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardOnNoCandidateFxSettings.cs index b18b8c8131c6b1..1e32c44da644ba 100644 --- a/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardOnNoCandidateFxSettings.cs +++ b/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardOnNoCandidateFxSettings.cs @@ -5,6 +5,8 @@ using Microsoft.DotNet.Cli.Build.Framework; using Xunit; +using static Microsoft.DotNet.CoreSetup.Test.Constants; + namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution { public class RollForwardOnNoCandidateFxSettings : diff --git a/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardPreReleaseOnly.cs b/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardPreReleaseOnly.cs index 9e35ed8ff2a630..332a1b6e2a978f 100644 --- a/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardPreReleaseOnly.cs +++ b/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardPreReleaseOnly.cs @@ -5,6 +5,8 @@ using Microsoft.DotNet.Cli.Build.Framework; using Xunit; +using static Microsoft.DotNet.CoreSetup.Test.Constants; + namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution { /// diff --git a/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardReleaseAndPreRelease.cs b/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardReleaseAndPreRelease.cs index 5305d1abbc60bf..88d6f0c459d0ac 100644 --- a/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardReleaseAndPreRelease.cs +++ b/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardReleaseAndPreRelease.cs @@ -5,6 +5,8 @@ using Microsoft.DotNet.Cli.Build.Framework; using Xunit; +using static Microsoft.DotNet.CoreSetup.Test.Constants; + namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution { /// diff --git a/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardReleaseOnly.cs b/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardReleaseOnly.cs index cd92cabd1b7726..48e2f551a473d2 100644 --- a/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardReleaseOnly.cs +++ b/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardReleaseOnly.cs @@ -5,6 +5,8 @@ using Microsoft.DotNet.Cli.Build.Framework; using Xunit; +using static Microsoft.DotNet.CoreSetup.Test.Constants; + namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution { /// diff --git a/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardSettings.cs b/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardSettings.cs index b5e278c74ccabc..2f5d836c639718 100644 --- a/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardSettings.cs +++ b/src/installer/tests/HostActivation.Tests/FrameworkResolution/RollForwardSettings.cs @@ -5,6 +5,8 @@ using Microsoft.DotNet.Cli.Build.Framework; using Xunit; +using static Microsoft.DotNet.CoreSetup.Test.Constants; + namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.FrameworkResolution { public class RollForwardSettings : diff --git a/src/installer/tests/TestUtils/Constants.cs b/src/installer/tests/TestUtils/Constants.cs index 4ae6587dd6407e..9eb5b6e661e32f 100644 --- a/src/installer/tests/TestUtils/Constants.cs +++ b/src/installer/tests/TestUtils/Constants.cs @@ -1,6 +1,8 @@ // 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.DotNet.CoreSetup.Test { public static class Constants @@ -82,8 +84,10 @@ public static class DisableGuiErrors public static class TestOnlyEnvironmentVariables { public const string DefaultInstallPath = "_DOTNET_TEST_DEFAULT_INSTALL_PATH"; - public const string RegistryPath = "_DOTNET_TEST_REGISTRY_PATH"; public const string GloballyRegisteredPath = "_DOTNET_TEST_GLOBALLY_REGISTERED_PATH"; + + public static string RegisteredConfigLocation = OperatingSystem.IsWindows() ? RegistryPath : InstallLocationPath; + public const string RegistryPath = "_DOTNET_TEST_REGISTRY_PATH"; public const string InstallLocationPath = "_DOTNET_TEST_INSTALL_LOCATION_PATH"; }