diff --git a/.ci/test_r_package_windows.ps1 b/.ci/test_r_package_windows.ps1 index 6af4dbb04173..1b0405257583 100644 --- a/.ci/test_r_package_windows.ps1 +++ b/.ci/test_r_package_windows.ps1 @@ -195,7 +195,6 @@ if ($env:COMPILER -ne "MSVC") { } } else { - $env:TMPDIR = $env:USERPROFILE # to avoid warnings about incremental builds inside a temp directory $INSTALL_LOG_FILE_NAME = "$env:BUILD_SOURCESDIRECTORY\00install_out.txt" Run-R-Code-Redirect-Stderr "source('build_r.R')" 1> $INSTALL_LOG_FILE_NAME ; $install_succeeded = $? Write-Output "----- build and install logs -----" diff --git a/.ci/test_windows.ps1 b/.ci/test_windows.ps1 index 3a130e1af6da..5dcd59c28439 100644 --- a/.ci/test_windows.ps1 +++ b/.ci/test_windows.ps1 @@ -8,6 +8,13 @@ function Check-Output { $env:CONDA_ENV = "test-env" $env:LGB_VER = (Get-Content $env:BUILD_SOURCESDIRECTORY\VERSION.txt).trim() +# Use custom temp directory to avoid +# > warning MSB8029: The Intermediate directory or Output directory cannot reside under the Temporary directory +# > as it could lead to issues with incremental build. +# And make sure this directory is always clean +$env:TMPDIR = "$env:USERPROFILE\tmp" +Remove-Item $env:TMPDIR -Force -Recurse -ErrorAction Ignore +[Void][System.IO.Directory]::CreateDirectory($env:TMPDIR) if ($env:TASK -eq "r-package") { & .\.ci\test_r_package_windows.ps1 ; Check-Output $?