diff --git a/src/finalizer/finalizer.cpp b/src/finalizer/finalizer.cpp index ecb6e1fa9..58bf9e1bd 100644 --- a/src/finalizer/finalizer.cpp +++ b/src/finalizer/finalizer.cpp @@ -396,7 +396,17 @@ extern "C" HRESULT DetectSdk(LPWSTR sczSdkFeatureBandVersion, LPWSTR sczArchitec LogStringLine(REPORT_STANDARD, "Scanning %ls", sczInstalledSdkVersionsKeyName); hr = RegOpen(HKEY_LOCAL_MACHINE, sczInstalledSdkVersionsKeyName, KEY_READ, &hkInstalledSdkVersionsKey); - ExitOnFailure(hr, "Failed to read installed versions key."); + + // When the last SDK is removed the registry key should no longer exist so we can just exit + if (E_FILENOTFOUND == hr) + { + LogStringLine(REPORT_STANDARD, "Registry key not found: %ls.", sczInstalledSdkVersionsKeyName); + hr = S_OK; + *pbInstalled = FALSE; + goto LExit; + } + + ExitOnFailure(hr, "Failed to open registry key: %ls.", sczInstalledSdkVersionsKeyName); for (DWORD dwSdkVersionsValueIndex = 0;; ++dwSdkVersionsValueIndex) { @@ -460,9 +470,10 @@ int wmain(int argc, wchar_t* argv[]) hr = ::DetectSdk(sczFeatureBandVersion, argv[3], &bSdkFeatureBandInstalled); ExitOnFailure(hr, "Failed to detect installed SDKs."); - if (!bSdkFeatureBandInstalled) + // If the feature band is still present, do not remove workloads. + if (bSdkFeatureBandInstalled) { - LogStringLine(REPORT_STANDARD, "SDK with feature band %ls could not be found.", sczFeatureBandVersion); + LogStringLine(REPORT_STANDARD, "Detected SDK with feature band %ls.", sczFeatureBandVersion); goto LExit; } diff --git a/src/redist/targets/packaging/windows/clisdk/bundle.wxs b/src/redist/targets/packaging/windows/clisdk/bundle.wxs index c58c6a194..148487bde 100644 --- a/src/redist/targets/packaging/windows/clisdk/bundle.wxs +++ b/src/redist/targets/packaging/windows/clisdk/bundle.wxs @@ -151,7 +151,31 @@ - + + + + + @@ -208,20 +232,7 @@ - - +