From 6d60e11a4a5e83f589895d6503d6e1089f9dd60c Mon Sep 17 00:00:00 2001 From: Marc Paine Date: Mon, 4 Mar 2024 11:12:29 -0800 Subject: [PATCH 1/3] Update to target net8.0 add windows checks to solve CA warnings update SDK version --- global.json | 2 +- .../Shared/Commands/UninstallCommandExec.cs | 4 ++-- src/dotnet-core-uninstall/Windows/RegistryQuery.cs | 2 ++ src/dotnet-core-uninstall/dotnet-core-uninstall.csproj | 8 ++++---- src/redist/redist.csproj | 2 +- .../dotnet-core-uninstall.Tests.csproj | 2 +- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/global.json b/global.json index ddc6167..25d4839 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "tools": { - "dotnet": "7.0.100-rc.1.22431.12" + "dotnet": "8.0.100" }, "msbuild-sdks": { "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.22480.2" diff --git a/src/dotnet-core-uninstall/Shared/Commands/UninstallCommandExec.cs b/src/dotnet-core-uninstall/Shared/Commands/UninstallCommandExec.cs index 0e7abf0..a76d7d1 100644 --- a/src/dotnet-core-uninstall/Shared/Commands/UninstallCommandExec.cs +++ b/src/dotnet-core-uninstall/Shared/Commands/UninstallCommandExec.cs @@ -133,13 +133,13 @@ namespace Microsoft.DotNet.Tools.Uninstall.Shared.Commands { try { - if (RuntimeInfo.RunningOnWindows) + if (OperatingSystem.IsWindows()) { var identity = WindowsIdentity.GetCurrent(); var principal = new WindowsPrincipal(identity); return principal.IsInRole(WindowsBuiltInRole.Administrator); } - else if (RuntimeInfo.RunningOnOSX) + else if (OperatingSystem.IsMacOS()) { return getuid() == 0; } diff --git a/src/dotnet-core-uninstall/Windows/RegistryQuery.cs b/src/dotnet-core-uninstall/Windows/RegistryQuery.cs index 9762bc8..93767e2 100644 --- a/src/dotnet-core-uninstall/Windows/RegistryQuery.cs +++ b/src/dotnet-core-uninstall/Windows/RegistryQuery.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Versioning; using System.Text.RegularExpressions; using Microsoft.DotNet.Tools.Uninstall.MacOs; using Microsoft.DotNet.Tools.Uninstall.Shared.BundleInfo; @@ -15,6 +16,7 @@ using Microsoft.Win32; namespace Microsoft.DotNet.Tools.Uninstall.Windows { + [SupportedOSPlatform("windows")] internal class RegistryQuery : IBundleCollector { public IEnumerable GetInstalledBundles() diff --git a/src/dotnet-core-uninstall/dotnet-core-uninstall.csproj b/src/dotnet-core-uninstall/dotnet-core-uninstall.csproj index b7c3682..eeec646 100644 --- a/src/dotnet-core-uninstall/dotnet-core-uninstall.csproj +++ b/src/dotnet-core-uninstall/dotnet-core-uninstall.csproj @@ -4,7 +4,7 @@ Exe win-x86;osx-x64 true - netcoreapp3.1 + net8.0 LatestMajor @@ -15,11 +15,11 @@ - - + + - + diff --git a/src/redist/redist.csproj b/src/redist/redist.csproj index a46ca76..8e846dc 100644 --- a/src/redist/redist.csproj +++ b/src/redist/redist.csproj @@ -1,6 +1,6 @@  - netcoreapp3.1 + net8.0 true false false diff --git a/test/dotnet-core-uninstall.Tests/dotnet-core-uninstall.Tests.csproj b/test/dotnet-core-uninstall.Tests/dotnet-core-uninstall.Tests.csproj index 6271bc5..abfcfdc 100644 --- a/test/dotnet-core-uninstall.Tests/dotnet-core-uninstall.Tests.csproj +++ b/test/dotnet-core-uninstall.Tests/dotnet-core-uninstall.Tests.csproj @@ -1,6 +1,6 @@  - net7.0 + net8.0 From 5300d380b57848563a5ed9a0e4b0f1c2660815fc Mon Sep 17 00:00:00 2001 From: Marc Paine Date: Mon, 4 Mar 2024 11:21:48 -0800 Subject: [PATCH 2/3] Fix build error on osx Address build warning in test assembly --- .../Shared/Configs/CommandLineConfigs.cs | 3 ++- .../Windows/RegistryQueryTests.cs | 15 +++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/dotnet-core-uninstall/Shared/Configs/CommandLineConfigs.cs b/src/dotnet-core-uninstall/Shared/Configs/CommandLineConfigs.cs index fb94194..e3ebbc8 100644 --- a/src/dotnet-core-uninstall/Shared/Configs/CommandLineConfigs.cs +++ b/src/dotnet-core-uninstall/Shared/Configs/CommandLineConfigs.cs @@ -8,6 +8,7 @@ using System.CommandLine.Builder; using System.CommandLine.Invocation; using System.CommandLine.Parsing; using System.Linq; +using System.Runtime.InteropServices; using Microsoft.DotNet.Tools.Uninstall.MacOs; using Microsoft.DotNet.Tools.Uninstall.Shared.BundleInfo; using Microsoft.DotNet.Tools.Uninstall.Shared.Commands; @@ -231,7 +232,7 @@ namespace Microsoft.DotNet.Tools.Uninstall.Shared.Configs } AssignOptionsToCommand(ListCommand, ListAuxOptions); - var bundleCollector = RuntimeInfo.RunningOnWindows ? new RegistryQuery() as IBundleCollector : new FileSystemExplorer() as IBundleCollector; + var bundleCollector = OperatingSystem.IsWindows() ? new RegistryQuery() as IBundleCollector : new FileSystemExplorer() as IBundleCollector; ListCommand.Handler = CommandHandler.Create(ExceptionHandler.HandleException(() => ListCommandExec.Execute(bundleCollector))); DryRunCommand.Handler = CommandHandler.Create(ExceptionHandler.HandleException(() => DryRunCommandExec.Execute(bundleCollector))); RemoveCommand.Handler = CommandHandler.Create(ExceptionHandler.HandleException(() => UninstallCommandExec.Execute(bundleCollector))); diff --git a/test/dotnet-core-uninstall.Tests/Windows/RegistryQueryTests.cs b/test/dotnet-core-uninstall.Tests/Windows/RegistryQueryTests.cs index 8baa1b9..3132a3b 100644 --- a/test/dotnet-core-uninstall.Tests/Windows/RegistryQueryTests.cs +++ b/test/dotnet-core-uninstall.Tests/Windows/RegistryQueryTests.cs @@ -1,6 +1,7 @@ // 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 FluentAssertions; using Microsoft.DotNet.Tools.Uninstall.Tests.Attributes; using Microsoft.DotNet.Tools.Uninstall.Windows; @@ -48,9 +49,12 @@ namespace Microsoft.DotNet.Tools.Uninstall.Tests.Windows [InlineData("Microsoft .NET SDK 5.0.100 (arm64)")] internal void TestIsNetCoreBundleAccept(string input) { - RegistryQuery.IsNetCoreBundle(input, "0.0", "mockuninstall.exe", "0.0") - .Should() - .BeTrue(); + if (OperatingSystem.IsWindows()) + { + RegistryQuery.IsNetCoreBundle(input, "0.0", "mockuninstall.exe", "0.0") + .Should() + .BeTrue(); + } } [WindowsOnlyTheory] @@ -58,9 +62,12 @@ namespace Microsoft.DotNet.Tools.Uninstall.Tests.Windows [InlineData("Microsoft .NET Core SDK - rc1 (x86)")] internal void TestGetBundleVersionReturnsNullOnInvalidDisplayNames(string displayName) { - RegistryQuery.GetBundleVersion(displayName, string.Empty, string.Empty) + if (OperatingSystem.IsWindows()) + { + RegistryQuery.GetBundleVersion(displayName, string.Empty, string.Empty) .Should() .BeNull(); + } } } } From b0d1ab8e8a272def3e60f34e2d2f78a412d0254a Mon Sep 17 00:00:00 2001 From: Marc Paine Date: Mon, 4 Mar 2024 11:34:46 -0800 Subject: [PATCH 3/3] retarget msbuildbinlogquery to 8.0 as well --- src/MSBuildBinLogQuery/MSBuildBinLogQuery.csproj | 4 ++-- test/MSBuildBinLogQuery.Tests/MSBuildBinLogQuery.Tests.csproj | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/MSBuildBinLogQuery/MSBuildBinLogQuery.csproj b/src/MSBuildBinLogQuery/MSBuildBinLogQuery.csproj index 4ffb13f..51e4d91 100644 --- a/src/MSBuildBinLogQuery/MSBuildBinLogQuery.csproj +++ b/src/MSBuildBinLogQuery/MSBuildBinLogQuery.csproj @@ -1,13 +1,13 @@  - netcoreapp3.1 + net8.0 Microsoft.Build.Logging.Query preview - + diff --git a/test/MSBuildBinLogQuery.Tests/MSBuildBinLogQuery.Tests.csproj b/test/MSBuildBinLogQuery.Tests/MSBuildBinLogQuery.Tests.csproj index 479fda1..26d9eb3 100644 --- a/test/MSBuildBinLogQuery.Tests/MSBuildBinLogQuery.Tests.csproj +++ b/test/MSBuildBinLogQuery.Tests/MSBuildBinLogQuery.Tests.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 false