我正在尝试将一组服务器上的 ASP.NET Core 从 2.0.3 升级到 2.1.5。我正在使用如下所示的 Powershell 脚本:
$software = Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
$software += Get-ChildItem 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\'
$software | Where-Object { $_.GetValue('DisplayName') -like '*.net core*2.0.3*' } | ForEach-Object {
write-verbose "Uninstalling $($_.GetValue('DisplayName'))"
$guid = ([regex]'{[A-Z0-9-]+}').Match($_.Name).Value
$process_params = @{
'FilePath' = Join-Path -Path $env:SystemRoot -ChildPath 'system32' | Join-Path -ChildPath 'msiexec.exe';
'ArgumentList' = @(
"/x$guid",
'/passive',
'/norestart'
);
'Wait' = $True
}
Write-Verbose "Invoking Start-Process with parameters $(ConvertTo-Json $process_params)"
Start-Process @process_params
}
运行脚本后,没有错误,但软件没有被删除。尝试使用以下命令删除单个项目时也出现同样的问题
Start-Process -FilePath 'msiexec' -ArgumentList @('/x{402BF053-9B1B-4962-8784-DA77541C45A3}', '/passive', '/norestart') -Verbose -Wait
我甚至尝试过使用win32_product
这样的可怕方法:
(gwmi -Class win32_product -Filter "IdentifyingNumber='{402BF053-9B1B-4962-8784-DA77541C45A3}'").Uninstall()
这些选项都不起作用。添加/log uninstall.log
到 msiexec 参数会产生以下日志文件:
=== Logging started: 10/11/2018 9:37:57 ===
Action start 9:37:57: INSTALL.
Action start 9:37:57: FindRelatedProducts.
Action ended 9:37:57: FindRelatedProducts. Return value 0.
Action start 9:37:57: LaunchConditions.
Action ended 9:37:57: LaunchConditions. Return value 1.
Action start 9:37:57: ValidateProductID.
Action ended 9:37:57: ValidateProductID. Return value 1.
Action start 9:37:57: CostInitialize.
Action ended 9:37:57: CostInitialize. Return value 1.
Action start 9:37:57: FileCost.
Action ended 9:37:57: FileCost. Return value 1.
Action start 9:37:57: CostFinalize.
Action ended 9:37:57: CostFinalize. Return value 1.
Action start 9:37:57: MigrateFeatureStates.
Action ended 9:37:57: MigrateFeatureStates. Return value 0.
Action start 9:37:57: InstallValidate.
Action ended 9:37:57: InstallValidate. Return value 1.
Action start 9:37:57: WixDependencyCheck.
If you continue with this uninstall, 1 or more products may stop working properly. Do you want to continue with this uninstall anyway?
CustomAction WixDependencyCheck returned actual error code 259 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended 9:37:57: WixDependencyCheck. Return value 5.
Action ended 9:37:57: INSTALL. Return value 1.
Property(S): UpgradeCode = {9E476537-57D3-4BCD-E354-3F9131F43B15}
Property(S): DOTNETHOME = C:\Program Files (x86)\dotnet\
Property(S): TARGETDIR = C:\
Property(S): WixUIRMOption = UseRM
Property(S): WIXUI_INSTALLDIR = DOTNETHOME
Property(S): ALLUSERS = 1
Property(S): ARPNOMODIFY = 1
Property(S): ProgramFilesFolder = C:\Program Files (x86)\
Property(S): ProductCPU = x86
Property(S): RTM_ProductVersion = 16.12.25816
Property(S): MSIFASTINSTALL = 7
Property(S): Manufacturer = Microsoft Corporation
Property(S): ProductCode = {402BF053-9B1B-4962-8784-DA77541C45A3}
Property(S): ProductLanguage = 1033
Property(S): ProductName = Microsoft .NET Core Host - 2.0.3 (x86)
Property(S): ProductVersion = 16.12.25816
Property(S): DefaultUIFont = WixUI_Font_Normal
Property(S): WixUI_Mode = InstallDir
Property(S): ErrorDialog = ErrorDlg
Property(S): SecureCustomProperties = IGNOREDEPENDENCIES;WIX_DOWNGRADE_DETECTED;WIX_UPGRADE_DETECTED
Property(S): MsiLogFileLocation = C:\Windows\system32\uninstall.log
Property(S): PackageCode = {D490295B-DB46-41F3-BF1B-ED9A8E55B81B}
Property(S): ProductState = 5
Property(S): ProductToBeRegistered = 1
Property(S): REBOOTPROMPT = S
Property(S): REBOOT = ReallySuppress
Property(S): REMOVE = ALL
Property(S): CURRENTDIRECTORY = C:\Windows\system32
Property(S): CLIENTUILEVEL = 2
Property(S): CLIENTPROCESSID = 13344
Property(S): MsiSystemRebootPending = 1
Property(S): PRODUCTLANGUAGE = 1033
Property(S): VersionDatabase = 200
Property(S): VersionMsi = 5.00
Property(S): VersionNT = 603
Property(S): VersionNT64 = 603
Property(S): WindowsBuild = 9600
Property(S): ServicePackLevel = 0
Property(S): ServicePackLevelMinor = 0
Property(S): MsiNTProductType = 3
Property(S): WindowsFolder = C:\Windows\
Property(S): WindowsVolume = C:\
Property(S): System64Folder = C:\Windows\system32\
Property(S): SystemFolder = C:\Windows\SysWOW64\
Property(S): RemoteAdminTS = 1
Property(S): TempFolder = C:\Users\username_redacted\AppData\Local\Temp\
Property(S): CommonFilesFolder = C:\Program Files (x86)\Common Files\
Property(S): ProgramFiles64Folder = C:\Program Files\
Property(S): CommonFiles64Folder = C:\Program Files\Common Files\
Property(S): AppDataFolder = C:\Users\username_redacted\AppData\Roaming\
Property(S): FavoritesFolder = C:\Users\username_redacted\Favorites\
Property(S): NetHoodFolder = C:\Users\username_redacted\AppData\Roaming\Microsoft\Windows\Network Shortcuts\
Property(S): PersonalFolder = C:\Users\username_redacted\Documents\
Property(S): PrintHoodFolder = C:\Users\username_redacted\AppData\Roaming\Microsoft\Windows\Printer Shortcuts\
Property(S): RecentFolder = C:\Users\username_redacted\AppData\Roaming\Microsoft\Windows\Recent\
Property(S): SendToFolder = C:\Users\username_redacted\AppData\Roaming\Microsoft\Windows\SendTo\
Property(S): TemplateFolder = C:\ProgramData\Microsoft\Windows\Templates\
Property(S): CommonAppDataFolder = C:\ProgramData\
Property(S): LocalAppDataFolder = C:\Users\username_redacted\AppData\Local\
Property(S): MyPicturesFolder = C:\Users\username_redacted\Pictures\
Property(S): AdminToolsFolder = C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools\
Property(S): StartupFolder = C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\
Property(S): ProgramMenuFolder = C:\ProgramData\Microsoft\Windows\Start Menu\Programs\
Property(S): StartMenuFolder = C:\ProgramData\Microsoft\Windows\Start Menu\
Property(S): DesktopFolder = C:\Users\Public\Desktop\
Property(S): FontsFolder = C:\Windows\Fonts\
Property(S): GPTSupport = 1
Property(S): OLEAdvtSupport = 1
Property(S): ShellAdvtSupport = 1
Property(S): MsiAMD64 = 21
Property(S): Msix64 = 21
Property(S): Intel = 21
Property(S): PhysicalMemory = 10477
Property(S): VirtualMemory = 10819
Property(S): AdminUser = 1
Property(S): MsiTrueAdminUser = 1
Property(S): LogonUser = username_redacted
Property(S): UserSID = S-1-5-21-3813976000-3187682355-4120183401-9416
Property(S): UserLanguageID = 1033
Property(S): ComputerName = VMTEST08
Property(S): SystemLanguageID = 1033
Property(S): ScreenX = 1024
Property(S): ScreenY = 768
Property(S): CaptionHeight = 23
Property(S): BorderTop = 1
Property(S): BorderSide = 1
Property(S): TextHeight = 16
Property(S): TextInternalLeading = 3
Property(S): ColorBits = 32
Property(S): TTCSupport = 1
Property(S): Time = 9:37:57
Property(S): Date = 10/11/2018
Property(S): MsiNetAssemblySupport = 4.7.3062.0
Property(S): MsiWin32AssemblySupport = 6.3.9600.17415
Property(S): RedirectedDllSupport = 2
Property(S): MsiRunningElevated = 1
Property(S): Privileged = 1
Property(S): Installed = 00:00:00
Property(S): DATABASE = C:\Windows\Installer\40b0b.msi
Property(S): UILevel = 3
Property(S): OriginalDatabase = C:\Windows\Installer\40b0b.msi
Property(S): MsiUIProgressOnly = 1
Property(S): MsiUIHideCancel = 1
Property(S): Preselected = 1
Property(S): ACTION = INSTALL
Property(S): ROOTDRIVE = C:\
Property(S): CostingComplete = 1
Property(S): OutOfDiskSpace = 0
Property(S): OutOfNoRbDiskSpace = 0
Property(S): PrimaryVolumeSpaceAvailable = 0
Property(S): PrimaryVolumeSpaceRequired = 0
Property(S): PrimaryVolumeSpaceRemaining = 0
Property(S): INSTALLLEVEL = 1
MSI (s) (7C:C0) [09:37:57:357]: Product: Microsoft .NET Core Host - 2.0.3 (x86) -- Removal completed successfully.
MSI (s) (7C:C0) [09:37:57:357]: Windows Installer removed the product. Product Name: Microsoft .NET Core Host - 2.0.3 (x86). Product Version: 16.12.25816. Product Language: 1033. Manufacturer: Microsoft Corporation. Removal success or error status: 0.
=== Logging stopped: 10/11/2018 9:37:57 ===
如您所见,即使日志文件也显示成功 - 但产品每次都还在那里!如果能帮助解决这个特定问题,那就太好了,但我也很感激任何常规的 Windows Installer 故障排除,因为我在网上找不到太多文档。感谢您的时间。
答案1
在日志中您可以看到 WixDependencyCheck 找到依赖于此 MSI 的其他 MSI,并出现错误。
将参数添加IGNOREDEPENDENCIES=ALL
到 msiexec 应该可以解决这个问题。
答案2
我遇到了同样的问题(使用 chocolatey 进行卸载),最后得到了这个解决方案。(不要忘记更改 $version 变量以匹配要删除的版本)
$version = '2.2.6'
$softwareName = '.Net Core'
$searchString = "*$softwareName*$version*"
$msiExecPath = Join-Path -Path $env:SystemRoot -ChildPath 'system32' | Join-Path -ChildPath 'msiexec.exe'
function Find-DotNetCoreInstall {
param (
$ver = $version,
$softName = $softwareName
)
$software = @(
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*',
'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
)
$searchString = "*$softwareName*$version*"
$allDotNetItems = Get-ItemProperty $software | Where-Object {$_.displayName -like $searchString} | Select-Object DisplayName,DisplayVersion,UninstallString
Write-Output $allDotNetItems
}
$allDotNetItems = Find-DotNetCoreInstall
if($allDotNetItems.count -gt 0) {
Write-Host "Uninstalling $($allDotNetItems.count) components for $softwareName $version"
foreach($item in $allDotNetItems) {
$uninstallString = $item.UninstallString
$name = $item.DisplayName
if ($uninstallString -like "MsiExec.exe *") {
Write-Host "Uninstalling $name version: $($item.displayVersion)"
$guid = ([regex]'{[A-Z0-9-]+}').Match($uninstallString).Value
start-process -FilePath $msiExecPath -ArgumentList @("/x$guid", "/passive", "/quiet", "/norestart", "IGNOREDEPENDENCIES=ALL", "/log `"$env:temp\$($name)_Uninstall_$($version).log`"") -Wait
}
else {
$filepath = ($uninstallString.Split('/')[0]).replace('"','')
Write-Host "Uninstalling $name version: $($item.displayVersion)"
Start-Process -FilePath $filepath -ArgumentList @("/uninstall", "/silent") -Wait
}
}
}
else {
Write-Host "There are no installed components of $software $version"
exit 0
}
$finalCheck = Find-DotNetCoreInstall
if ($finalCheck.count -eq 0){
Write-Host "All .NET components have been uninstalled"
exit 0
}
else {
Write-Host "Error: NOT ALL COMPONENTS uninstalled! `n $finalCheck "
exit 1
}