首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >卸载工具无法识别时如何卸载.NET SDK预览和旧版本

卸载工具无法识别时如何卸载.NET SDK预览和旧版本
EN

Stack Overflow用户
提问于 2022-01-10 08:51:08
回答 2查看 4.3K关注 0票数 5

我想卸载.NET 5和.NET 6预览-并保留最新的.NET 6。

但是,卸载实用程序只允许我卸载我想要保留的版本。

在设置/应用程序和功能(Windows 10)中也没有用于删除的旧版本。

所有SDK都是使用正确的安装实用程序(没有压缩文件)或Visual安装的。

我已经卸载了Visual我使用VSCode代替。

现有SDK的列表:

代码语言:javascript
复制
C:\>dotnet --list-sdks

5.0.400 [C:\Program Files\dotnet\sdk]
6.0.100-preview.7.21379.14 [C:\Program Files\dotnet\sdk]
6.0.101 [C:\Program Files\dotnet\sdk]

可卸载SDK的列表(使用卸载实用程序):

代码语言:javascript
复制
C:\Program Files (x86)\dotnet-core-uninstall>dotnet-core-uninstall list

.NET Core SDKs:
  6.0.101  x64    [Used by Visual Studio. Specify individually or use --force to remove]

.NET Core Runtimes:

ASP.NET Core Runtimes:

.NET Core Runtime & Hosting Bundles:
代码语言:javascript
复制
C:\Program Files (x86)\dotnet-core-uninstall>dotnet-core-uninstall --version
1.5.255402+e07a3c995ec2d3cf449d37eb50c87e180da12544

任何关于如何摆脱它们的提示都是非常感谢的。

EN

回答 2

Stack Overflow用户

发布于 2022-05-28 08:29:50

我知道这已经晚了几个月了,但这最终在谷歌上是相当高的,所以只是在这里加一个答案。

您可以使用dotnet核心卸载工具https://learn.microsoft.com/en-us/dotnet/core/additional-tools/uninstall-tool?tabs=windows

并运行:dotnet-core-uninstall remove --all-previews-but-latest如果您只想删除预览/保留.Net 5,您的问题只是保留.Net 6,所以可以使用--all-below 6.0.101 --sdk

您可以通过将其添加到命令中来执行一次试运行( dry和whatif是同义词,您可以使用这两种方法):dotnet-core-uninstall whatif --all-below 6.0.101 --sdk

票数 2
EN

Stack Overflow用户

发布于 2022-10-05 16:56:18

我找到了一个GitHub问题,我用它制作了一个要旨,其中列出了所有已安装的软件,包括任何不可见的软件。

示例

获取包含(区分大小写的) .NET的所有软件

Get-Installed -Name .NET

获取包含(区分大小写的) .NET和3.1.10的所有软件

Get-Installed -Name .NET | Where-Object {$_.DisplayName.Contains("3.1.10")}

获取所有包含(区分大小写的) .NET和3.1.10的软件,并删除该软件

Get-Installed -Name .NET | Where-Object {$_.DisplayName.Contains("3.1.10")} | Select -Expand PsChildName | Remove-Installed

代码语言:javascript
复制
function Get-Installed {
    [CmdletBinding()]
    param (
        # The name of the software
        [Parameter(Mandatory = $true)]
        [string] $Name
    )
    
    begin {
        $PATHS = @(
            "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall",
            "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
        )

    }
    
    process {
        $installed = $null
        ForEach ($path in $PATHS) {
            $installed += Get-ChildItem -Path $path |
            ForEach-Object { Get-ItemProperty $_.PSPath } |
            Where-Object { $null -ne $_.DisplayName -and $_.DisplayName.Contains($Name) } |
            Select-Object DisplayName, DisplayVersion, PSChildName |
            Sort-Object -Property DisplayName
        }
        $installed
    }
    
    end {
        
    }
}

function Remove-Installed {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true, ValueFromPipeline = $true)]
        $Guid
    )
    
    process {
        Write-Verbose "Removing $Guid"
        $a = "/x " + $Guid
        Start-Process msiexec -Wait -ArgumentList $a
    }
    
}

# Examples
#
# Get ALL software containing (case-SENSITIVE) .NET
# Get-Installed -Name .NET  
# 
# Get ALL software containing (case-SENSITIVE) .NET AND 3.1.10
# Get-Installed -Name .NET | Where-Object {$_.DisplayName.Contains("3.1.10")} 
#
# Get ALL software containing (case-SENSITIVE) .NET AND 3.1.10 AND Remove those software
# Get-Installed -Name .NET | Where-Object {$_.DisplayName.Contains("3.1.10")} | Select -Expand PsChildName | Remove-Installed
# 
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70649841

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档