From 8cb5db3c97aea0d53d95f8f7be8b0d8a24241283 Mon Sep 17 00:00:00 2001
From: Vitalii Koshura <lestat.de.lionkur@gmail.com>
Date: Thu, 6 Aug 2020 01:51:55 +0200
Subject: [PATCH] [VS2019] Fix VS2019 CI build cache

Fixes #3959

Signed-off-by: Vitalii Koshura <lestat.de.lionkur@gmail.com>
---
 appveyor.yml                                         | 3 +--
 win_build/vcpkg_3rdparty_dependencies_vs2019.vcxproj | 7 ++-----
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/appveyor.yml b/appveyor.yml
index 0938b75952..efed2efa9e 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -91,7 +91,7 @@ environment:
 cache:
   - C:\projects\boinc_depends_win_vs2010 -> appveyor.yml, win_build\load_dependencies.bat
   - C:\projects\boinc_depends_win_vs2013 -> appveyor.yml, win_build\load_dependencies.bat
-  - C:\projects\boinc_depends_win_vs2019 -> appveyor.yml
+  - '%LOCALAPPDATA%\vcpkg\archives -> appveyor.yml'
 
 before_build:
   - if %TOOLCHAIN_VERSION%==10.0 call win_build\load_dependencies.bat %depends_zip_path% %depends_path% %platform% %configuration%
@@ -109,7 +109,6 @@ build_script:
 after_build:
   - if %TOOLCHAIN_VERSION%==12.0 call deploy\prepare_deployment.bat
   - if %TOOLCHAIN_VERSION%==12.0 call deploy\deploy_to_bintray.bat
-  - if %TOOLCHAIN_VERSION%==16.0 call xcopy 3rdParty\Windows\vcpkg\installed ..\boinc_depends_win_vs2019 /e /i /y
 
 artifacts:
   - path: deploy\win-apps\*.7z
diff --git a/win_build/vcpkg_3rdparty_dependencies_vs2019.vcxproj b/win_build/vcpkg_3rdparty_dependencies_vs2019.vcxproj
index a625974579..d71d12ee5c 100644
--- a/win_build/vcpkg_3rdparty_dependencies_vs2019.vcxproj
+++ b/win_build/vcpkg_3rdparty_dependencies_vs2019.vcxproj
@@ -98,15 +98,12 @@
     <DownloadFile SourceUrl="http://developer.download.nvidia.com/compute/cuda/10.2/Prod/network_installers/windows/x86_64/wddm2/cublas_dev.exe" DestinationFolder="$(TMP)" />
     <Exec Command="$(TMP)\7z\7za x $(TMP)\cublas_dev.exe -onvcc -aoa" WorkingDirectory="$(CudaRootDir)" ConsoleToMSBuild="true" />
   </Target>
-  <Target Name="InstallVcpkg" BeforeTargets="RestoreCache" DependsOnTargets="CreateFolders" AfterTargets="DownloadCUDA">
+  <Target Name="InstallVcpkg" BeforeTargets="Build3rdPartyLibraries" DependsOnTargets="CreateFolders" AfterTargets="DownloadCUDA">
     <Exec Command="git clone https://github.com/microsoft/vcpkg ." WorkingDirectory="$(VcpkgRootDir)" ConsoleToMSBuild="true" Condition="!Exists($(VcpkgExe))" />
     <Exec Command="git pull" WorkingDirectory="$(VcpkgRootDir)" ConsoleToMSBuild="true" />
     <Exec Command="bootstrap-vcpkg.bat" WorkingDirectory="$(VcpkgRootDir)" ConsoleToMSBuild="true" />
   </Target>
-  <Target Name="RestoreCache" BeforeTargets="Build3rdPartyLibraries" DependsOnTargets="InstallVcpkg" AfterTargets="InstallVcpkg" Condition="Exists($(VcpkgCacheDir))">
-    <Exec Command="xcopy $(VcpkgCacheDir) $(VcpkgRootDir)\installed /e /i /y" />
-  </Target>
-  <Target Name="Build3rdPartyLibraries" BeforeTargets="ClCompile" DependsOnTargets="RestoreCache" AfterTargets="RestoreCache">
+  <Target Name="Build3rdPartyLibraries" BeforeTargets="ClCompile" DependsOnTargets="InstallVcpkg" AfterTargets="InstallVcpkg">
     <Exec Command="vcpkg.exe install openssl curl[core,openssl] freetype[core,bzip2,png] ftgl wxwidgets opencl rappture gtest --overlay-ports=../../vcpkg_ports/ports --overlay-triplets=../../vcpkg_ports/triplets/$(VcpkgTripletConfig) --triplet $(VcpkgTripletName)" WorkingDirectory="$(VcpkgRootDir)" ConsoleToMSBuild="true" />
     <Exec Command="vcpkg.exe upgrade --no-dry-run --overlay-ports=../../vcpkg_ports/ports --overlay-triplets=../../vcpkg_ports/triplets/$(VcpkgTripletConfig) --triplet $(VcpkgTripletName)" WorkingDirectory="$(VcpkgRootDir)" ConsoleToMSBuild="true" />
   </Target>