diff --git a/build.psm1 b/build.psm1 index 2ad6c3d1ce..5ab48cbae2 100644 --- a/build.psm1 +++ b/build.psm1 @@ -120,6 +120,11 @@ function Start-PSBuild { Push-Location $PSScriptRoot try { git clean -fdX + # Extra cleaning is required to delete the CMake temporary files. + # These are not cleaned when using "X" and cause CMake to retain state, leading to + # mis-configured environment issues when switching between x86 and x64 compilation + # environments. + git clean -fdx .\src\powershell-native } finally { Pop-Location } diff --git a/src/powershell-native/nativemsh/pwrshexe/CMakeLists.txt b/src/powershell-native/nativemsh/pwrshexe/CMakeLists.txt index 149f1048ef..25ef183c75 100644 --- a/src/powershell-native/nativemsh/pwrshexe/CMakeLists.txt +++ b/src/powershell-native/nativemsh/pwrshexe/CMakeLists.txt @@ -20,16 +20,18 @@ if (BUILD_ONECORE) # # Configure lib directories so that CI picks up onecore.lib # - SET (WindowsSdkDir $ENV{WindowsSdkDir}) - SET (WindowsSDKVersion $ENV{WindowsSDKVersion}) - SET (WindowsSDKLibBase "${WindowsSdkDir}/Lib/${WindowsSDKVersion}") - SET (OneCoreLibBase "$ENV{VCInstallDir}lib/onecore/amd64") + if (BUILD_ARCH_AMD64) + SET (WindowsSdkDir $ENV{WindowsSdkDir}) + SET (WindowsSDKVersion $ENV{WindowsSDKVersion}) + SET (WindowsSDKLibBase "${WindowsSdkDir}/Lib/${WindowsSDKVersion}") + SET (OneCoreLibBase "$ENV{VCInstallDir}lib/onecore/amd64") - SET (LibraryPath) - list (APPEND LibraryPath "${OneCoreLibBase}") - list (APPEND LibraryPath "${WindowsSDKLibBase}ucrt/${WindowsSDKPlatform}") - list (APPEND LibraryPath "${WindowsSDKLibBase}um/${WindowsSDKPlatform}" ) - link_directories(${LibraryPath}) + SET (LibraryPath) + list (APPEND LibraryPath "${OneCoreLibBase}") + list (APPEND LibraryPath "${WindowsSDKLibBase}ucrt/${WindowsSDKPlatform}") + list (APPEND LibraryPath "${WindowsSDKLibBase}um/${WindowsSDKPlatform}" ) + link_directories(${LibraryPath}) + endif () else () # Settings to use when creating PowerShell.exe for Windows on full SKUs or downlevel platforms