Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,4 @@ _ReSharper.*/
buildlog.txt
nCrunchTemp*
TestResults/
.nuget/
27 changes: 27 additions & 0 deletions src/dotnet-core-uninstall/LocalizableStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions src/dotnet-core-uninstall/LocalizableStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@
<value>Set the verbosity level. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic].</value>
</data>
<data name="UninstallX64OptionDescription" xml:space="preserve">
<value>Can be used with --sdk, --runtime and --aspnet-runtime to remove x64.</value>
<value>Can be used with --sdk, --runtime, --aspnet-runtime and --windows-desktop-runtime to remove x64.</value>
</data>
<data name="UninstallX86OptionDescription" xml:space="preserve">
<value>Can be used with --sdk, --runtime and --aspnet-runtime to remove x86.</value>
<value>Can be used with --sdk, --runtime, --aspnet-runtime and --windows-desktop-runtime to remove x86.</value>
</data>
<data name="NotAdminExceptionMessage" xml:space="preserve">
<value>The current user does not have adequate privileges. See https://aka.ms/dotnet-core-uninstall-docs.</value>
Expand Down Expand Up @@ -249,6 +249,15 @@
<data name="HostingBundleFootnoteFormat" xml:space="preserve">
<value>"{0}" is treated as a version {1} in this tool.</value>
</data>
<data name="UninstallWindowsDesktopRuntimeOptionDescription" xml:space="preserve">
<value>Remove Windows Desktop Runtimes only.</value>
</data>
<data name="ListCommandWindowsDesktopRuntimeHeader" xml:space="preserve">
<value>Windows Desktop Runtimes:</value>
</data>
<data name="ListWindowsDesktopRuntimeOptionDescription" xml:space="preserve">
<value>List Windows Desktop Runtimes.</value>
</data>
<data name="ListAspNetRuntimeOptionDescription" xml:space="preserve">
<value>List ASP.NET Core Runtimes.</value>
</data>
Expand Down Expand Up @@ -391,7 +400,7 @@ Uninstalling this item will cause Visual Studio for to break.
<value>List arm64 .NET Core SDKs or Runtimes.</value>
</data>
<data name="UninstallArm64OptionDescription" xml:space="preserve">
<value>Can be used with --sdk, --runtime and --aspnet-runtime to remove arm64.</value>
<value>Can be used with --sdk, --runtime, --aspnet-runtime and --windows-desktop-runtime to remove arm64.</value>
</data>
<data name="MacOSPreserveVSSdksOptionDescription" xml:space="preserve">
<value>Prevent removal of SDKs and Runtimes that have a high probability of being used by Visual Studio for Mac (Note: Visual Studio for Mac is out of support).</value>
Expand Down
3 changes: 2 additions & 1 deletion src/dotnet-core-uninstall/Shared/BundleInfo/BundleType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ internal enum BundleType
Sdk = 0x1,
Runtime = 0x2,
AspNetRuntime = 0x4,
HostingBundle = 0x8
HostingBundle = 0x8,
WindowsDesktopRuntime = 0x10
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// 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;

namespace Microsoft.DotNet.Tools.Uninstall.Shared.BundleInfo.Versioning
{
internal class WindowsDesktopRuntimeVersion : BundleVersion, IComparable, IComparable<WindowsDesktopRuntimeVersion>, IEquatable<WindowsDesktopRuntimeVersion>
{
public override BundleType Type => BundleType.WindowsDesktopRuntime;
public override BeforePatch BeforePatch => new MajorMinorVersion(Major, Minor);

public WindowsDesktopRuntimeVersion() { }

public WindowsDesktopRuntimeVersion(string value) : base(value) { }

public int CompareTo(object obj)
{
return CompareTo(obj as WindowsDesktopRuntimeVersion);
}

public int CompareTo(WindowsDesktopRuntimeVersion other)
{
return other == null ? 1 : SemVer.CompareTo(other.SemVer);
}

public override bool Equals(object obj)
{
return Equals(obj as WindowsDesktopRuntimeVersion);
}

public bool Equals(WindowsDesktopRuntimeVersion other)
{
return other != null &&
base.Equals(other);
}

public override int GetHashCode()
{
return HashCode.Combine(base.GetHashCode());
}

public override Bundle ToBundle(BundleArch arch, string uninstallCommand, string displayName)
{
return new Bundle<WindowsDesktopRuntimeVersion>(this, arch, uninstallCommand, displayName);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ internal static class CommandLineConfigs
public static readonly string RuntimeOptionName = "runtime";
public static readonly string AspNetRuntimeOptionName = "aspnet-runtime";
public static readonly string HostingBundleOptionName = "hosting-bundle";
public static readonly string WindowsDesktopRuntimeOptionName = "windows-desktop-runtime";
public static readonly string X64OptionName = "x64";
public static readonly string X86OptionName = "x86";
public static readonly string Arm64OptionName = "arm64";
Expand Down Expand Up @@ -160,15 +161,17 @@ internal static class CommandLineConfigs
new Option($"--{SdkOptionName}", LocalizableStrings.ListSdkOptionDescription),
new Option($"--{RuntimeOptionName}", LocalizableStrings.ListRuntimeOptionDescription),
new Option($"--{AspNetRuntimeOptionName}", LocalizableStrings.ListAspNetRuntimeOptionDescription),
new Option($"--{HostingBundleOptionName}", LocalizableStrings.ListHostingBundleOptionDescription)
new Option($"--{HostingBundleOptionName}", LocalizableStrings.ListHostingBundleOptionDescription),
new Option($"--{WindowsDesktopRuntimeOptionName}", LocalizableStrings.ListWindowsDesktopRuntimeOptionDescription)
};

public static readonly Option[] UninstallBundleTypeOptions = new Option[]
{
new Option($"--{SdkOptionName}", LocalizableStrings.UninstallSdkOptionDescription),
new Option($"--{RuntimeOptionName}", LocalizableStrings.UninstallRuntimeOptionDescription),
new Option($"--{AspNetRuntimeOptionName}", LocalizableStrings.UninstallAspNetRuntimeOptionDescription),
new Option($"--{HostingBundleOptionName}", LocalizableStrings.UninstallHostingBundleOptionDescription)
new Option($"--{HostingBundleOptionName}", LocalizableStrings.UninstallHostingBundleOptionDescription),
new Option($"--{WindowsDesktopRuntimeOptionName}", LocalizableStrings.UninstallWindowsDesktopRuntimeOptionDescription)
};

public static readonly Option[] ArchUninstallOptions = new Option[]
Expand Down
16 changes: 14 additions & 2 deletions src/dotnet-core-uninstall/Shared/Filterers/Filterer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public IEnumerable<Bundle> Filter(TArg argValue, IEnumerable<Bundle> bundles, Bu
var runtimes = Bundle<RuntimeVersion>.FilterWithSameBundleType(filteredBundlesByArch);
var aspNetRuntimes = Bundle<AspNetRuntimeVersion>.FilterWithSameBundleType(filteredBundlesByArch);
var hostingBundles = Bundle<HostingBundleVersion>.FilterWithSameBundleType(filteredBundlesByArch);
var windowsDesktopRuntimes = Bundle<WindowsDesktopRuntimeVersion>.FilterWithSameBundleType(filteredBundlesByArch);

var filteredSdks = typeSelection.HasFlag(BundleType.Sdk) ?
Filter(argValue, sdks).OrderBy(sdk => sdk).Select(sdk => sdk as Bundle) :
Expand All @@ -80,10 +81,15 @@ public IEnumerable<Bundle> Filter(TArg argValue, IEnumerable<Bundle> bundles, Bu
Filter(argValue, hostingBundles).OrderBy(hostingBundle => hostingBundle).Select(hostingBundle => hostingBundle as Bundle) :
new List<Bundle>();

var filteredWindowsDesktopRuntimes = typeSelection.HasFlag(BundleType.WindowsDesktopRuntime) ?
Filter(argValue, windowsDesktopRuntimes).OrderBy(windowsDesktopRuntime => windowsDesktopRuntime).Select(windowsDesktopRuntime => windowsDesktopRuntime as Bundle) :
new List<Bundle>();

return filteredSdks
.Concat(filteredRuntimes)
.Concat(filteredAspNetRuntimes)
.Concat(filteredHostingBundles);
.Concat(filteredHostingBundles)
.Concat(filteredWindowsDesktopRuntimes);
}

public abstract IEnumerable<Bundle<TBundleVersion>> Filter<TBundleVersion>(TArg argValue, IEnumerable<Bundle<TBundleVersion>> bundles)
Expand All @@ -108,6 +114,7 @@ public IEnumerable<Bundle> Filter(IEnumerable<Bundle> bundles, BundleType typeSe
var runtimes = Bundle<RuntimeVersion>.FilterWithSameBundleType(filteredBundlesByArch);
var aspNetRuntimes = Bundle<AspNetRuntimeVersion>.FilterWithSameBundleType(filteredBundlesByArch);
var hostingBundles = Bundle<HostingBundleVersion>.FilterWithSameBundleType(filteredBundlesByArch);
var windowsDesktopRuntimes = Bundle<WindowsDesktopRuntimeVersion>.FilterWithSameBundleType(filteredBundlesByArch);

var filteredSdks = typeSelection.HasFlag(BundleType.Sdk) ?
Filter(sdks).OrderBy(sdk => sdk).Select(sdk => sdk as Bundle) :
Expand All @@ -125,10 +132,15 @@ public IEnumerable<Bundle> Filter(IEnumerable<Bundle> bundles, BundleType typeSe
Filter(hostingBundles).OrderBy(hostingBundle => hostingBundle).Select(hostingBundle => hostingBundle as Bundle) :
new List<Bundle>();

var filteredWindowsDesktopRuntimes = typeSelection.HasFlag(BundleType.WindowsDesktopRuntime) ?
Filter(windowsDesktopRuntimes).OrderBy(windowsDesktopRuntime => windowsDesktopRuntime).Select(windowsDesktopRuntime => windowsDesktopRuntime as Bundle) :
new List<Bundle>();

return filteredSdks
.Concat(filteredRuntimes)
.Concat(filteredAspNetRuntimes)
.Concat(filteredHostingBundles);
.Concat(filteredHostingBundles)
.Concat(filteredWindowsDesktopRuntimes);
}

public abstract IEnumerable<Bundle<TBundleVersion>> Filter<TBundleVersion>(IEnumerable<Bundle<TBundleVersion>> bundles)
Expand Down
19 changes: 14 additions & 5 deletions src/dotnet-core-uninstall/Windows/RegistryQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public IEnumerable<Bundle> GetInstalledBundles()

public virtual IEnumerable<Bundle> GetAllInstalledBundles()
{
var bundles = GetNetCoreBundleKeys(RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64));
bundles = bundles.Concat(GetNetCoreBundleKeys(RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)));
// The bundles are all 32bit so we only need to query one view of the registry
var bundles = GetNetCoreBundleKeys(RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32));

var wrappedBundles = bundles
.Select(bundle => WrapRegistryKey(bundle))
Expand Down Expand Up @@ -135,6 +135,12 @@ public static BundleVersion GetBundleVersion(string displayName, string uninstal
{
return new SdkVersion(versionString);
}
else if (displayName.IndexOf("Windows Desktop Runtime", StringComparison.OrdinalIgnoreCase) >= 0 ||
displayName.IndexOf("WindowsDesktop", StringComparison.OrdinalIgnoreCase) >= 0 ||
displayName.IndexOf("Dotnet Shared Framework for Windows Desktop", StringComparison.OrdinalIgnoreCase) >= 0)
{
return new WindowsDesktopRuntimeVersion(versionString);
}
else if (displayName.IndexOf(".NET Core Runtime", StringComparison.OrdinalIgnoreCase) >= 0 ||
Regex.IsMatch(displayName, @".*\.NET Core.*Runtime") ||
displayName.IndexOf(".NET Runtime", StringComparison.OrdinalIgnoreCase) >= 0)
Expand Down Expand Up @@ -165,9 +171,12 @@ private static BundleArch GetBundleArch(string displayName, string bundleCachePa
archString = cachePathMatch.Groups[Regexes.ArchGroupName].Value;
}

archString ??= displayName.Contains(x64String) ? x64String :
displayName.Contains(x86String) ? x86String :
displayName.Contains(arm64String) ? arm64String : null;
if (string.IsNullOrEmpty(archString))
{
archString = displayName.Contains(x64String) ? x64String :
displayName.Contains(x86String) ? x86String :
displayName.Contains(arm64String) ? arm64String : null;
}

return archString switch
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ internal static class SupportedBundleTypeConfigs
new BundleTypePrintInfo<HostingBundleVersion>(
LocalizableStrings.ListCommandHostingBundleHeader,
_gridViewGeneratorWithoutArch,
CommandLineConfigs.HostingBundleOptionName)
CommandLineConfigs.HostingBundleOptionName),

new BundleTypePrintInfo<WindowsDesktopRuntimeVersion>(
LocalizableStrings.ListCommandWindowsDesktopRuntimeHeader,
_gridViewGeneratorWithArch,
CommandLineConfigs.WindowsDesktopRuntimeOptionName)
};
}
}
27 changes: 21 additions & 6 deletions src/dotnet-core-uninstall/xlf/LocalizableStrings.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading