From 4256733a593a6eec1504ad9f7e7cc15010d09a91 Mon Sep 17 00:00:00 2001 From: tmat Date: Tue, 30 Aug 2022 12:02:22 -0700 Subject: [PATCH 1/5] Use architecture specific DOTNET_ROOT variable name --- .../DotNetWatchTasks/FileSetSerializer.cs | 6 ++ .../dotnet-watch/DotNetWatch.targets | 2 + .../dotnet-watch/HotReloadDotNetWatcher.cs | 9 ++- .../Internal/MSBuildFileSetResult.cs | 4 + .../Internal/MsBuildFileSetFactory.cs | 9 +-- src/BuiltInTools/dotnet-watch/ProjectInfo.cs | 2 + .../dotnet-watch/dotnet-watch.csproj | 4 + .../dotnet/commands/dotnet-run/RunCommand.cs | 44 ++--------- src/Common/EnvironmentVariableNames.cs | 56 +++++++++++++ .../EnvironmentVariableNamesTests.cs | 78 +++++++++++++++++++ 10 files changed, 171 insertions(+), 43 deletions(-) create mode 100644 src/Tests/dotnet.Tests/EnvironmentVariableNamesTests.cs diff --git a/src/BuiltInTools/DotNetWatchTasks/FileSetSerializer.cs b/src/BuiltInTools/DotNetWatchTasks/FileSetSerializer.cs index 2b2c9b805806..d2d934c102b1 100644 --- a/src/BuiltInTools/DotNetWatchTasks/FileSetSerializer.cs +++ b/src/BuiltInTools/DotNetWatchTasks/FileSetSerializer.cs @@ -20,6 +20,10 @@ public class FileSetSerializer : Task public string TargetFrameworkVersion { get; set; } + public string RuntimeIdentifier { get; set; } + + public string DefaultAppHostRuntimeIdentifier { get; set; } + public string RunCommand { get; set; } public string RunArguments { get; set; } @@ -37,6 +41,8 @@ public override bool Execute() { IsNetCoreApp = IsNetCoreApp, TargetFrameworkVersion = TargetFrameworkVersion, + RuntimeIdentifier = RuntimeIdentifier, + DefaultAppHostRuntimeIdentifier = DefaultAppHostRuntimeIdentifier, RunCommand = RunCommand, RunArguments = RunArguments, RunWorkingDirectory = RunWorkingDirectory, diff --git a/src/BuiltInTools/dotnet-watch/DotNetWatch.targets b/src/BuiltInTools/dotnet-watch/DotNetWatch.targets index ebbcdfc2921d..2300125c7a74 100644 --- a/src/BuiltInTools/dotnet-watch/DotNetWatch.targets +++ b/src/BuiltInTools/dotnet-watch/DotNetWatch.targets @@ -20,6 +20,8 @@ them to a file. Projects { get; set; } } diff --git a/src/BuiltInTools/dotnet-watch/Internal/MsBuildFileSetFactory.cs b/src/BuiltInTools/dotnet-watch/Internal/MsBuildFileSetFactory.cs index 454534779a5d..b69df3307096 100644 --- a/src/BuiltInTools/dotnet-watch/Internal/MsBuildFileSetFactory.cs +++ b/src/BuiltInTools/dotnet-watch/Internal/MsBuildFileSetFactory.cs @@ -9,6 +9,7 @@ using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using Microsoft.DotNet.Cli; using Microsoft.DotNet.Watcher.Tools; using Microsoft.Extensions.Tools.Internal; using IReporter = Microsoft.Extensions.Tools.Internal.IReporter; @@ -146,14 +147,12 @@ public async Task CreateAsync(CancellationToken cancellationToken) Debug.Assert(fileItems.All(f => Path.IsPathRooted(f.FilePath)), "All files should be rooted paths"); #endif - // TargetFrameworkVersion appears as v6.0 in msbuild. Ignore the leading v - var targetFrameworkVersion = !string.IsNullOrEmpty(result.TargetFrameworkVersion) ? - Version.Parse(result.TargetFrameworkVersion.AsSpan(1)) : // Ignore leading v - null; var projectInfo = new ProjectInfo( _projectFile, result.IsNetCoreApp, - targetFrameworkVersion, + EnvironmentVariableNames.TryParseTargetFrameworkVersion(result.TargetFrameworkVersion), + result.RuntimeIdentifier, + result.DefaultAppHostRuntimeIdentifier, result.RunCommand, result.RunArguments, result.RunWorkingDirectory); diff --git a/src/BuiltInTools/dotnet-watch/ProjectInfo.cs b/src/BuiltInTools/dotnet-watch/ProjectInfo.cs index 3e09d9631ed3..45e0e8628365 100644 --- a/src/BuiltInTools/dotnet-watch/ProjectInfo.cs +++ b/src/BuiltInTools/dotnet-watch/ProjectInfo.cs @@ -12,6 +12,8 @@ public record ProjectInfo string ProjectPath, bool IsNetCoreApp, Version? TargetFrameworkVersion, + string RuntimeIdentifier, + string DefaultAppHostRuntimeIdentifier, string RunCommand, string RunArguments, string RunWorkingDirectory diff --git a/src/BuiltInTools/dotnet-watch/dotnet-watch.csproj b/src/BuiltInTools/dotnet-watch/dotnet-watch.csproj index 065f750f7200..3bef016bdf0d 100644 --- a/src/BuiltInTools/dotnet-watch/dotnet-watch.csproj +++ b/src/BuiltInTools/dotnet-watch/dotnet-watch.csproj @@ -10,6 +10,10 @@ + + + + diff --git a/src/Cli/dotnet/commands/dotnet-run/RunCommand.cs b/src/Cli/dotnet/commands/dotnet-run/RunCommand.cs index b95ab5564625..c119e7f90c8a 100644 --- a/src/Cli/dotnet/commands/dotnet-run/RunCommand.cs +++ b/src/Cli/dotnet/commands/dotnet-run/RunCommand.cs @@ -8,6 +8,7 @@ using System.Runtime.InteropServices; using Microsoft.Build.Execution; using Microsoft.Build.Exceptions; +using Microsoft.DotNet.Cli; using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Tools.Run.LaunchSettings; using Microsoft.DotNet.CommandFactory; @@ -26,7 +27,6 @@ public partial class RunCommand public bool Interactive { get; private set; } public IEnumerable RestoreArgs { get; private set; } - private Version Version6_0 = new Version(6, 0); private bool ShouldBuild => !NoBuild; private bool HasQuietVerbosity => RestoreArgs.All(arg => !arg.StartsWith("-verbosity:", StringComparison.Ordinal) || @@ -261,21 +261,14 @@ private ICommand GetTargetCommand() var command = CommandFactoryUsingResolver.Create(commandSpec) .WorkingDirectory(runWorkingDirectory); - if (((TryGetTargetArchitecture(project.GetPropertyValue("RuntimeIdentifier"), out var targetArchitecture) || - TryGetTargetArchitecture(project.GetPropertyValue("DefaultAppHostRuntimeIdentifier"), out targetArchitecture)) && - targetArchitecture == RuntimeInformation.ProcessArchitecture) || targetArchitecture == null) - { - var rootVariableName = Environment.Is64BitProcess ? "DOTNET_ROOT" : "DOTNET_ROOT(x86)"; - string targetFrameworkVersion = project.GetPropertyValue("TargetFrameworkVersion"); - if (!string.IsNullOrEmpty(targetFrameworkVersion) && Version.Parse(targetFrameworkVersion.AsSpan(1)) >= Version6_0) - { - rootVariableName = $"DOTNET_ROOT_{RuntimeInformation.ProcessArchitecture.ToString().ToUpperInvariant()}"; - } + var rootVariableName = EnvironmentVariableNames.TryGetDotNetRootVariableName( + project.GetPropertyValue("RuntimeIdentifier"), + project.GetPropertyValue("DefaultAppHostRuntimeIdentifier"), + project.GetPropertyValue("TargetFrameworkVersion")); - if (Environment.GetEnvironmentVariable(rootVariableName) == null) - { - command.EnvironmentVariable(rootVariableName, Path.GetDirectoryName(new Muxer().MuxerPath)); - } + if (rootVariableName != null && Environment.GetEnvironmentVariable(rootVariableName) == null) + { + command.EnvironmentVariable(rootVariableName, Path.GetDirectoryName(new Muxer().MuxerPath)); } return command; @@ -329,26 +322,5 @@ private static string FindSingleProjectInDirectory(string directory) return projectFiles[0]; } - - private static bool TryGetTargetArchitecture(string runtimeIdentifier, out Architecture? targetArchitecture) - { - targetArchitecture = null; - int separator = runtimeIdentifier.LastIndexOf("-", StringComparison.InvariantCulture); - if (separator < 0) - { - return false; - } - - targetArchitecture = runtimeIdentifier.Substring(separator + 1).ToLowerInvariant() switch - { - "arm" => Architecture.Arm, - "arm64" => Architecture.Arm64, - "x64" => Architecture.X64, - "x86" => Architecture.X86, - _ => null - }; - - return targetArchitecture != null; - } } } diff --git a/src/Common/EnvironmentVariableNames.cs b/src/Common/EnvironmentVariableNames.cs index 71efdda67f0d..5fa77b979497 100644 --- a/src/Common/EnvironmentVariableNames.cs +++ b/src/Common/EnvironmentVariableNames.cs @@ -1,6 +1,12 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +#pragma warning disable IDE0240 // Nullable directive is redundant (when file is included to a project that already enables nullable +#nullable enable + +using System.Runtime.InteropServices; +using System; + namespace Microsoft.DotNet.Cli { static class EnvironmentVariableNames @@ -14,5 +20,55 @@ static class EnvironmentVariableNames public static readonly string TELEMETRY_OPTOUT = "DOTNET_CLI_TELEMETRY_OPTOUT"; public static readonly string ENABLE_PUBLISH_RELEASE_FOR_SOLUTIONS = "DOTNET_CLI_ENABLE_PUBLISH_RELEASE_FOR_SOLUTIONS"; public static readonly string ENABLE_PACK_RELEASE_FOR_SOLUTIONS = "DOTNET_CLI_ENABLE_PACK_RELEASE_FOR_SOLUTIONS"; + public static readonly string DOTNET_ROOT = "DOTNET_ROOT"; + +#if NET7_0_OR_GREATER + private static readonly Version s_version6_0 = new(6, 0); + + public static string? TryGetDotNetRootVariableName(string runtimeIdentifier, string defaultAppHostRuntimeIdentifier, string targetFrameworkVersion) + => TryGetDotNetRootVariableName(runtimeIdentifier, defaultAppHostRuntimeIdentifier, TryParseTargetFrameworkVersion(targetFrameworkVersion)); + + public static string? TryGetDotNetRootVariableName(string runtimeIdentifier, string defaultAppHostRuntimeIdentifier, Version? targetFrameworkVersion) + => TryGetDotNetRootVariableNameImpl(runtimeIdentifier, defaultAppHostRuntimeIdentifier, targetFrameworkVersion, RuntimeInformation.ProcessArchitecture, Environment.Is64BitProcess); + + internal static string? TryGetDotNetRootVariableNameImpl(string runtimeIdentifier, string defaultAppHostRuntimeIdentifier, Version? targetFrameworkVersion, Architecture currentArchitecture, bool is64bit) + { + if (!TryParseArchitecture(runtimeIdentifier, out var targetArchitecture) && !TryParseArchitecture(defaultAppHostRuntimeIdentifier, out targetArchitecture) || + targetArchitecture == currentArchitecture) + { + var suffix = targetFrameworkVersion != null && targetFrameworkVersion >= s_version6_0 ? + $"_{currentArchitecture.ToString().ToUpperInvariant()}" : + is64bit ? "" : "(x86)"; + + return DOTNET_ROOT + suffix; + } + + return null; + } + + internal static bool TryParseArchitecture(string runtimeIdentifier, out Architecture architecture) + { + // RID is [os].[version]-[architecture]-[additional qualifiers] + // See https://learn.microsoft.com/en-us/dotnet/core/rid-catalog + + int archStart = runtimeIdentifier.IndexOf('-') + 1; + if (archStart <= 0) + { + architecture = default; + return false; + } + + int archEnd = runtimeIdentifier.IndexOf('-', archStart); + var span = runtimeIdentifier.AsSpan(archStart, (archEnd > 0 ? archEnd : runtimeIdentifier.Length) - archStart); + + return Enum.TryParse(span, ignoreCase: true, out architecture); + } + + public static Version? TryParseTargetFrameworkVersion(string targetFrameworkVersion) + { + // TargetFrameworkVersion appears as "vX.Y" in msbuild. Ignore the leading 'v'. + return !string.IsNullOrEmpty(targetFrameworkVersion) && Version.TryParse(targetFrameworkVersion.Substring(1), out var version) ? version : null; + } +#endif } } diff --git a/src/Tests/dotnet.Tests/EnvironmentVariableNamesTests.cs b/src/Tests/dotnet.Tests/EnvironmentVariableNamesTests.cs new file mode 100644 index 000000000000..9b25b95dd66b --- /dev/null +++ b/src/Tests/dotnet.Tests/EnvironmentVariableNamesTests.cs @@ -0,0 +1,78 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; +using System.Runtime.InteropServices; +using Microsoft.DotNet.Cli; +using Xunit; + +namespace dotnet.Tests; + +public class EnvironmentVariableNamesTests +{ + [Theory] + [InlineData("os.1.2-x86", Architecture.X86)] + [InlineData("os.1.2-x64", Architecture.X64)] + [InlineData("os.1.2-arm", Architecture.Arm)] + [InlineData("os.1.2-arm64", Architecture.Arm64)] + [InlineData("os.1.2-wasm", Architecture.Wasm)] + [InlineData("os.1.2-s390x", Architecture.S390x)] + [InlineData("os.1.2-loongarch64", Architecture.LoongArch64)] + [InlineData("os.1.2-armv6", Architecture.Armv6)] + [InlineData("os.1.2-ppc64le", Architecture.Ppc64le)] + [InlineData("os.1.2-lOOngaRch64", Architecture.LoongArch64)] // case-insensitive + [InlineData("os-x86", Architecture.X86)] + [InlineData("-x86", Architecture.X86)] + [InlineData("-x86-", Architecture.X86)] + public static void TryParseArchitecture(string rid, Architecture expected) + { + Assert.True(EnvironmentVariableNames.TryParseArchitecture(rid, out var actual)); + Assert.Equal(expected, actual); + + Assert.True(EnvironmentVariableNames.TryParseArchitecture(rid + "-xyz", out actual)); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData("")] + [InlineData("-")] + [InlineData("--")] + [InlineData("---")] + [InlineData("x86")] + [InlineData("os")] + [InlineData("os.")] + [InlineData("os.1")] + [InlineData("os.1.2")] + [InlineData("os.1.2-")] + [InlineData("os.1.2--")] + [InlineData("os.1.2-unknown")] + [InlineData("os.1.2-unknown-")] + [InlineData("os.1.2-unknown-x")] + [InlineData("os.1.2-armel")] // currently not defined + public static void TryParseArchitecture_Invalid(string rid) + { + Assert.False(EnvironmentVariableNames.TryParseArchitecture(rid, out _)); + } + + [Theory] + [InlineData("os-unknown", null, Architecture.X86, true, "DOTNET_ROOT")] + [InlineData("os-unknown", null, Architecture.X86, false, "DOTNET_ROOT(x86)")] + [InlineData("os-unknown", "v5.0", Architecture.X86, true, "DOTNET_ROOT")] + [InlineData("os-unknown", "v5.0", Architecture.X86, false, "DOTNET_ROOT(x86)")] + [InlineData("os-unknown", "v6.0", Architecture.Wasm, true, "DOTNET_ROOT_WASM")] + [InlineData("os-unknown", "v6.0", Architecture.Wasm, false, "DOTNET_ROOT_WASM")] + [InlineData("os-x86", null, Architecture.X86, true, "DOTNET_ROOT")] + [InlineData("os-x86", null, Architecture.X86, false, "DOTNET_ROOT(x86)")] + [InlineData("os-x86", "v5.0", Architecture.X86, true, "DOTNET_ROOT")] + [InlineData("os-x86", "v5.0", Architecture.X86, false, "DOTNET_ROOT(x86)")] + [InlineData("os-x86", "v6.0", Architecture.X86, true, "DOTNET_ROOT_X86")] + [InlineData("os-x86", "v6.0", Architecture.X86, false, "DOTNET_ROOT_X86")] + [InlineData("os-x64", "v6.0", Architecture.X86, false, null)] + public static void TryGetDotNetRootVariableName(string rid, string frameworkVersion, Architecture currentArchitecture, bool is64bit, string expected) + { + var parsedVersion = EnvironmentVariableNames.TryParseTargetFrameworkVersion(frameworkVersion); + Assert.Equal(expected, EnvironmentVariableNames.TryGetDotNetRootVariableNameImpl(rid, "", parsedVersion, currentArchitecture, is64bit)); + Assert.Equal(expected, EnvironmentVariableNames.TryGetDotNetRootVariableNameImpl("", rid, parsedVersion, currentArchitecture, is64bit)); + } +} From a788848af6ca0b251701f35b45a740002d6f710b Mon Sep 17 00:00:00 2001 From: tmat Date: Mon, 19 Sep 2022 16:51:33 -0700 Subject: [PATCH 2/5] Feedback --- src/Common/EnvironmentVariableNames.cs | 3 +++ src/Tests/dotnet.Tests/EnvironmentVariableNamesTests.cs | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/Common/EnvironmentVariableNames.cs b/src/Common/EnvironmentVariableNames.cs index 5fa77b979497..c9a085634e2e 100644 --- a/src/Common/EnvironmentVariableNames.cs +++ b/src/Common/EnvironmentVariableNames.cs @@ -33,6 +33,9 @@ static class EnvironmentVariableNames internal static string? TryGetDotNetRootVariableNameImpl(string runtimeIdentifier, string defaultAppHostRuntimeIdentifier, Version? targetFrameworkVersion, Architecture currentArchitecture, bool is64bit) { + // If the app targets the same architecture as SDK is running on or an unknown architecture, set DOTNET_ROOT, DOTNET_ROOT(x86) for 32-bit, DOTNET_ROOT_arch for TFM 6+. + // If the app targets different architecture from the SDK, do not set DOTNET_ROOT. + if (!TryParseArchitecture(runtimeIdentifier, out var targetArchitecture) && !TryParseArchitecture(defaultAppHostRuntimeIdentifier, out targetArchitecture) || targetArchitecture == currentArchitecture) { diff --git a/src/Tests/dotnet.Tests/EnvironmentVariableNamesTests.cs b/src/Tests/dotnet.Tests/EnvironmentVariableNamesTests.cs index 9b25b95dd66b..556542f663c2 100644 --- a/src/Tests/dotnet.Tests/EnvironmentVariableNamesTests.cs +++ b/src/Tests/dotnet.Tests/EnvironmentVariableNamesTests.cs @@ -68,11 +68,15 @@ public static void TryParseArchitecture_Invalid(string rid) [InlineData("os-x86", "v5.0", Architecture.X86, false, "DOTNET_ROOT(x86)")] [InlineData("os-x86", "v6.0", Architecture.X86, true, "DOTNET_ROOT_X86")] [InlineData("os-x86", "v6.0", Architecture.X86, false, "DOTNET_ROOT_X86")] + [InlineData("os-x64", "v5.0", Architecture.X64, true, "DOTNET_ROOT")] + [InlineData("os-x64", "v6.0", Architecture.X64, true, "DOTNET_ROOT_X64")] + [InlineData("os-arm64", "v6.0", Architecture.Arm64, true, "DOTNET_ROOT_ARM64")] [InlineData("os-x64", "v6.0", Architecture.X86, false, null)] public static void TryGetDotNetRootVariableName(string rid, string frameworkVersion, Architecture currentArchitecture, bool is64bit, string expected) { var parsedVersion = EnvironmentVariableNames.TryParseTargetFrameworkVersion(frameworkVersion); Assert.Equal(expected, EnvironmentVariableNames.TryGetDotNetRootVariableNameImpl(rid, "", parsedVersion, currentArchitecture, is64bit)); Assert.Equal(expected, EnvironmentVariableNames.TryGetDotNetRootVariableNameImpl("", rid, parsedVersion, currentArchitecture, is64bit)); + Assert.Equal(expected, EnvironmentVariableNames.TryGetDotNetRootVariableNameImpl(rid, "os-armv6", parsedVersion, currentArchitecture, is64bit)); } } From 190ca019eb89da3ae59c6f6289f53cedc9447850 Mon Sep 17 00:00:00 2001 From: tmat Date: Thu, 10 Nov 2022 12:15:25 -0800 Subject: [PATCH 3/5] Fix test cases with unknown arch --- .../EnvironmentVariableNamesTests.cs | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/Tests/dotnet.Tests/EnvironmentVariableNamesTests.cs b/src/Tests/dotnet.Tests/EnvironmentVariableNamesTests.cs index 556542f663c2..04e73fa0793b 100644 --- a/src/Tests/dotnet.Tests/EnvironmentVariableNamesTests.cs +++ b/src/Tests/dotnet.Tests/EnvironmentVariableNamesTests.cs @@ -56,12 +56,6 @@ public static void TryParseArchitecture_Invalid(string rid) } [Theory] - [InlineData("os-unknown", null, Architecture.X86, true, "DOTNET_ROOT")] - [InlineData("os-unknown", null, Architecture.X86, false, "DOTNET_ROOT(x86)")] - [InlineData("os-unknown", "v5.0", Architecture.X86, true, "DOTNET_ROOT")] - [InlineData("os-unknown", "v5.0", Architecture.X86, false, "DOTNET_ROOT(x86)")] - [InlineData("os-unknown", "v6.0", Architecture.Wasm, true, "DOTNET_ROOT_WASM")] - [InlineData("os-unknown", "v6.0", Architecture.Wasm, false, "DOTNET_ROOT_WASM")] [InlineData("os-x86", null, Architecture.X86, true, "DOTNET_ROOT")] [InlineData("os-x86", null, Architecture.X86, false, "DOTNET_ROOT(x86)")] [InlineData("os-x86", "v5.0", Architecture.X86, true, "DOTNET_ROOT")] @@ -71,12 +65,33 @@ public static void TryParseArchitecture_Invalid(string rid) [InlineData("os-x64", "v5.0", Architecture.X64, true, "DOTNET_ROOT")] [InlineData("os-x64", "v6.0", Architecture.X64, true, "DOTNET_ROOT_X64")] [InlineData("os-arm64", "v6.0", Architecture.Arm64, true, "DOTNET_ROOT_ARM64")] + [InlineData("os-armv6", "v6.0", Architecture.Armv6, true, "DOTNET_ROOT_ARMV6")] + [InlineData("os-armv6", "v6.0", Architecture.Arm64, true, null)] [InlineData("os-x64", "v6.0", Architecture.X86, false, null)] - public static void TryGetDotNetRootVariableName(string rid, string frameworkVersion, Architecture currentArchitecture, bool is64bit, string expected) + public static void TryGetDotNetRootVariableName_KnownArchitecture(string rid, string frameworkVersion, Architecture currentArchitecture, bool is64bit, string expected) { var parsedVersion = EnvironmentVariableNames.TryParseTargetFrameworkVersion(frameworkVersion); - Assert.Equal(expected, EnvironmentVariableNames.TryGetDotNetRootVariableNameImpl(rid, "", parsedVersion, currentArchitecture, is64bit)); - Assert.Equal(expected, EnvironmentVariableNames.TryGetDotNetRootVariableNameImpl("", rid, parsedVersion, currentArchitecture, is64bit)); + Assert.Equal(expected, EnvironmentVariableNames.TryGetDotNetRootVariableNameImpl(rid, "os-unknown", parsedVersion, currentArchitecture, is64bit)); Assert.Equal(expected, EnvironmentVariableNames.TryGetDotNetRootVariableNameImpl(rid, "os-armv6", parsedVersion, currentArchitecture, is64bit)); + Assert.Equal(expected, EnvironmentVariableNames.TryGetDotNetRootVariableNameImpl("os-unknown", rid, parsedVersion, currentArchitecture, is64bit)); + } + + [Theory] + [InlineData(null, Architecture.X86, true, "DOTNET_ROOT")] + [InlineData(null, Architecture.X86, false, "DOTNET_ROOT(x86)")] + [InlineData("v5.0", Architecture.X86, true, "DOTNET_ROOT")] + [InlineData("v5.0", Architecture.X86, false, "DOTNET_ROOT(x86)")] + [InlineData("v6.0", Architecture.X86, true, "DOTNET_ROOT_X86")] + [InlineData("v6.0", Architecture.X86, false, "DOTNET_ROOT_X86")] + [InlineData("v5.0", Architecture.X64, true, "DOTNET_ROOT")] + [InlineData("v6.0", Architecture.X64, true, "DOTNET_ROOT_X64")] + [InlineData("v6.0", Architecture.Arm64, true, "DOTNET_ROOT_ARM64")] + [InlineData("v6.0", Architecture.Armv6, true, "DOTNET_ROOT_ARMV6")] + [InlineData("v6.0", Architecture.Wasm, true, "DOTNET_ROOT_WASM")] + [InlineData("v6.0", Architecture.Wasm, false, "DOTNET_ROOT_WASM")] + public static void TryGetDotNetRootVariableName_UnknownArchitecture(string frameworkVersion, Architecture currentArchitecture, bool is64bit, string expected) + { + var parsedVersion = EnvironmentVariableNames.TryParseTargetFrameworkVersion(frameworkVersion); + Assert.Equal(expected, EnvironmentVariableNames.TryGetDotNetRootVariableNameImpl("os-unknown", "os-unknown", parsedVersion, currentArchitecture, is64bit)); } } From 5a73e9379e0f332996c1bdf6b215f789b1903e29 Mon Sep 17 00:00:00 2001 From: tmat Date: Sat, 12 Nov 2022 10:00:18 -0800 Subject: [PATCH 4/5] Skip RestartProcessThatTerminatesAfterFileChange test --- src/Tests/dotnet-watch.Tests/NoDepsAppTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tests/dotnet-watch.Tests/NoDepsAppTests.cs b/src/Tests/dotnet-watch.Tests/NoDepsAppTests.cs index e84c68fa20b5..ddff0458f07f 100644 --- a/src/Tests/dotnet-watch.Tests/NoDepsAppTests.cs +++ b/src/Tests/dotnet-watch.Tests/NoDepsAppTests.cs @@ -46,7 +46,7 @@ public async Task RestartProcessOnFileChange() Assert.NotEqual(processIdentifier, processIdentifier2); } - [Fact] + [Fact(Skip = "https://github.com/dotnet/sdk/issues/29046")] public async Task RestartProcessThatTerminatesAfterFileChange() { var testAsset = _testAssetsManager.CopyTestAsset(AppName) From 1acb32540bd76f528d5855c0fdab156207b20460 Mon Sep 17 00:00:00 2001 From: tmat Date: Sat, 12 Nov 2022 14:51:43 -0800 Subject: [PATCH 5/5] Skip test Run_WithHotReloadEnabled_DoesNotReadConsoleIn_InNonInteractiveMode --- src/Tests/dotnet-watch.Tests/DotNetWatcherTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tests/dotnet-watch.Tests/DotNetWatcherTests.cs b/src/Tests/dotnet-watch.Tests/DotNetWatcherTests.cs index b1e492402114..0bdf67dfcdc7 100644 --- a/src/Tests/dotnet-watch.Tests/DotNetWatcherTests.cs +++ b/src/Tests/dotnet-watch.Tests/DotNetWatcherTests.cs @@ -169,7 +169,7 @@ public async Task Run_WithHotReloadEnabled_ReadsLaunchSettings_WhenUsingProjectO await app.Process.GetOutputLineAsyncWithConsoleHistoryAsync("Environment: Development"); } - [CoreMSBuildOnlyFact] + [CoreMSBuildOnlyFact(Skip = "https://github.com/dotnet/sdk/issues/29047")] public async Task Run_WithHotReloadEnabled_DoesNotReadConsoleIn_InNonInteractiveMode() { var testAsset = _testAssetsManager.CopyTestAsset("WatchAppWithLaunchSettings")