From fd4a08806fd88299814aac886e57708ade1d7398 Mon Sep 17 00:00:00 2001 From: ras0219 <533828+ras0219@users.noreply.github.com> Date: Wed, 8 Jul 2020 15:08:17 -0700 Subject: [PATCH] [vcpkg] Fix MSBuild regressions #12062 and #12086. (#12257) This PR also renames the VcpkgUserTriplet MSBuild variable to VcpkgTriplet to minimize user confusion compared to previous practice and documentation. Co-authored-by: Robert Schumacher --- scripts/azure-pipelines/end-to-end-tests.ps1 | 51 +++++- .../buildsystems/msbuild/vcpkg-general.xml | 2 +- scripts/buildsystems/msbuild/vcpkg.targets | 13 +- .../testing/integrate-install/NoProps.vcxproj | 145 +++++++++++++++++ .../integrate-install/Project1.vcxproj | 146 +++++++++++++++++ scripts/testing/integrate-install/Source.cpp | 6 + .../integrate-install/VcpkgTriplet.vcxproj | 151 ++++++++++++++++++ .../integrate-install/VcpkgTriplet2.vcxproj | 149 +++++++++++++++++ .../integrate-install/VcpkgUseStatic.vcxproj | 151 ++++++++++++++++++ .../integrate-install/VcpkgUseStatic2.vcxproj | 149 +++++++++++++++++ 10 files changed, 955 insertions(+), 8 deletions(-) create mode 100644 scripts/testing/integrate-install/NoProps.vcxproj create mode 100644 scripts/testing/integrate-install/Project1.vcxproj create mode 100644 scripts/testing/integrate-install/Source.cpp create mode 100644 scripts/testing/integrate-install/VcpkgTriplet.vcxproj create mode 100644 scripts/testing/integrate-install/VcpkgTriplet2.vcxproj create mode 100644 scripts/testing/integrate-install/VcpkgUseStatic.vcxproj create mode 100644 scripts/testing/integrate-install/VcpkgUseStatic2.vcxproj diff --git a/scripts/azure-pipelines/end-to-end-tests.ps1 b/scripts/azure-pipelines/end-to-end-tests.ps1 index b0642df82..eccefd544 100644 --- a/scripts/azure-pipelines/end-to-end-tests.ps1 +++ b/scripts/azure-pipelines/end-to-end-tests.ps1 @@ -44,9 +44,11 @@ $commonArgs = @( "--x-packages-root=$packagesRoot" ) -Remove-Item -Recurse -Force $TestingRoot -ErrorAction SilentlyContinue -mkdir $TestingRoot -mkdir $NuGetRoot +function Refresh-TestRoot { + Remove-Item -Recurse -Force $TestingRoot -ErrorAction SilentlyContinue + mkdir $TestingRoot + mkdir $NuGetRoot +} function Require-FileExists { [CmdletBinding()] @@ -66,12 +68,49 @@ function Require-FileNotExists { throw "'$CurrentTest' should not have created file '$File'" } } +function Throw-IfFailed { + if ($LASTEXITCODE -ne 0) { + throw "'$CurrentTest' had a step with a nonzero exit code" + } +} + +if (-not $IsLinux -and -not $IsMacOS) +{ + Refresh-TestRoot + # Test msbuild props and targets + $CurrentTest = "zlib:x86-windows-static msbuild scripts\testing\integrate-install\..." + Write-Host $CurrentTest + ./vcpkg $commonArgs install zlib:x86-windows-static --x-binarysource=clear + Throw-IfFailed + foreach ($project in @("VcpkgTriplet", "VcpkgTriplet2", "VcpkgUseStatic", "VcpkgUseStatic2")) { + $CurrentTest = "msbuild scripts\testing\integrate-install\$project.vcxproj" + ./vcpkg $commonArgs env "msbuild scripts\testing\integrate-install\$project.vcxproj /p:VcpkgRoot=$TestingRoot /p:IntDir=$TestingRoot\int\ /p:OutDir=$TestingRoot\out\ " + Throw-IfFailed + Remove-Item -Recurse -Force $TestingRoot\int + Remove-Item -Recurse -Force $TestingRoot\out + } + $CurrentTest = "zlib:x86-windows msbuild scripts\testing\integrate-install\..." + Write-Host $CurrentTest + ./vcpkg $commonArgs install zlib:x86-windows --x-binarysource=clear + Throw-IfFailed + foreach ($project in @("Project1", "NoProps")) { + $CurrentTest = "msbuild scripts\testing\integrate-install\$project.vcxproj" + Write-Host $CurrentTest + ./vcpkg $commonArgs env "msbuild scripts\testing\integrate-install\$project.vcxproj /p:VcpkgRoot=$TestingRoot /p:IntDir=$TestingRoot\int\ /p:OutDir=$TestingRoot\out\ " + Throw-IfFailed + Remove-Item -Recurse -Force $TestingRoot\int + Remove-Item -Recurse -Force $TestingRoot\out + } +} + +Refresh-TestRoot # Test simple installation $args = $commonArgs + @("install","rapidjson","--binarycaching","--x-binarysource=clear;files,$ArchiveRoot,write;nuget,$NuGetRoot,upload") $CurrentTest = "./vcpkg $($args -join ' ')" Write-Host $CurrentTest ./vcpkg @args +Throw-IfFailed Require-FileExists "$installRoot/$Triplet/include/rapidjson/rapidjson.h" @@ -80,6 +119,7 @@ $args = $commonArgs + @("remove", "rapidjson") $CurrentTest = "./vcpkg $($args -join ' ')" Write-Host $CurrentTest ./vcpkg @args +Throw-IfFailed Require-FileNotExists "$installRoot/$Triplet/include/rapidjson/rapidjson.h" @@ -90,6 +130,7 @@ Remove-Item -Recurse -Force $installRoot Remove-Item -Recurse -Force $buildtreesRoot Write-Host $CurrentTest ./vcpkg @args +Throw-IfFailed Require-FileExists "$installRoot/$Triplet/include/rapidjson/rapidjson.h" Require-FileNotExists "$buildtreesRoot/rapidjson/src" @@ -101,6 +142,7 @@ Remove-Item -Recurse -Force $installRoot Remove-Item -Recurse -Force $buildtreesRoot Write-Host $CurrentTest ./vcpkg @args +Throw-IfFailed Require-FileExists "$installRoot/$Triplet/include/rapidjson/rapidjson.h" Require-FileNotExists "$buildtreesRoot/rapidjson/src" @@ -111,11 +153,13 @@ $CurrentTest = "./vcpkg $($args -join ' ')" Remove-Item -Recurse -Force $installRoot -ErrorAction SilentlyContinue Write-Host $CurrentTest ./vcpkg @args +Throw-IfFailed Require-FileNotExists "$installRoot/$Triplet/include/rapidjson/rapidjson.h" Require-FileNotExists "$buildtreesRoot/rapidjson/src" Require-FileExists "$TestingRoot/packages.config" & $(./vcpkg fetch nuget) restore $TestingRoot/packages.config -OutputDirectory "$NuGetRoot2" -Source "$NuGetRoot" +Throw-IfFailed Remove-Item -Recurse -Force $NuGetRoot -ErrorAction SilentlyContinue mkdir $NuGetRoot @@ -124,6 +168,7 @@ $args = $commonArgs + @("install","rapidjson","tinyxml","--binarycaching","--x-b $CurrentTest = "./vcpkg $($args -join ' ')" Write-Host $CurrentTest ./vcpkg @args +Throw-IfFailed Require-FileExists "$installRoot/$Triplet/include/rapidjson/rapidjson.h" Require-FileExists "$installRoot/$Triplet/include/tinyxml.h" Require-FileNotExists "$buildtreesRoot/rapidjson/src" diff --git a/scripts/buildsystems/msbuild/vcpkg-general.xml b/scripts/buildsystems/msbuild/vcpkg-general.xml index d45f1103f..2638597a6 100644 --- a/scripts/buildsystems/msbuild/vcpkg-general.xml +++ b/scripts/buildsystems/msbuild/vcpkg-general.xml @@ -41,7 +41,7 @@ Category="General" Default="true"> - windows + + + x86 + + + $(Platform) + + - $(PlatformTarget)-$(VcpkgOSTarget) + $(VcpkgPlatformTarget)-$(VcpkgOSTarget) $(VcpkgUserTriplet) $(VcpkgRoot)\installed\$(VcpkgTriplet)\ @@ -46,9 +54,6 @@ $(VcpkgUserTriplet)-static - - $(VcpkgUserTriplet) - $(VcpkgInstalledDir)$(VcpkgTriplet) diff --git a/scripts/testing/integrate-install/NoProps.vcxproj b/scripts/testing/integrate-install/NoProps.vcxproj new file mode 100644 index 000000000..5b75d0961 --- /dev/null +++ b/scripts/testing/integrate-install/NoProps.vcxproj @@ -0,0 +1,145 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + {5AFB7AF5-D8FC-4A86-B0D2-3BBD039ED03A} + Project1 + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + \ No newline at end of file diff --git a/scripts/testing/integrate-install/Project1.vcxproj b/scripts/testing/integrate-install/Project1.vcxproj new file mode 100644 index 000000000..a8896fe29 --- /dev/null +++ b/scripts/testing/integrate-install/Project1.vcxproj @@ -0,0 +1,146 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + {5AFB7AF5-D8FC-4A86-B0D2-3BBD039ED03A} + Project1 + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + \ No newline at end of file diff --git a/scripts/testing/integrate-install/Source.cpp b/scripts/testing/integrate-install/Source.cpp new file mode 100644 index 000000000..24a84e4d7 --- /dev/null +++ b/scripts/testing/integrate-install/Source.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + zlibVersion(); + return 0; +} \ No newline at end of file diff --git a/scripts/testing/integrate-install/VcpkgTriplet.vcxproj b/scripts/testing/integrate-install/VcpkgTriplet.vcxproj new file mode 100644 index 000000000..883fc8ec1 --- /dev/null +++ b/scripts/testing/integrate-install/VcpkgTriplet.vcxproj @@ -0,0 +1,151 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + {5AFB7AF5-D8FC-4A86-B0D2-3BBD039ED03A} + VcpkgUseStatic + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + x86-windows-static + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreadedDebug + + + Console + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreaded + + + Console + true + true + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + \ No newline at end of file diff --git a/scripts/testing/integrate-install/VcpkgTriplet2.vcxproj b/scripts/testing/integrate-install/VcpkgTriplet2.vcxproj new file mode 100644 index 000000000..d3352e195 --- /dev/null +++ b/scripts/testing/integrate-install/VcpkgTriplet2.vcxproj @@ -0,0 +1,149 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + {5AFB7AF5-D8FC-4A86-B0D2-3BBD039ED03A} + VcpkgUseStatic + 10.0 + x86-windows-static + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreadedDebug + + + Console + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreaded + + + Console + true + true + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + \ No newline at end of file diff --git a/scripts/testing/integrate-install/VcpkgUseStatic.vcxproj b/scripts/testing/integrate-install/VcpkgUseStatic.vcxproj new file mode 100644 index 000000000..28c4fc715 --- /dev/null +++ b/scripts/testing/integrate-install/VcpkgUseStatic.vcxproj @@ -0,0 +1,151 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + {5AFB7AF5-D8FC-4A86-B0D2-3BBD039ED03A} + VcpkgUseStatic + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + true + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreadedDebug + + + Console + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreaded + + + Console + true + true + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + \ No newline at end of file diff --git a/scripts/testing/integrate-install/VcpkgUseStatic2.vcxproj b/scripts/testing/integrate-install/VcpkgUseStatic2.vcxproj new file mode 100644 index 000000000..98beaee4b --- /dev/null +++ b/scripts/testing/integrate-install/VcpkgUseStatic2.vcxproj @@ -0,0 +1,149 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + {5AFB7AF5-D8FC-4A86-B0D2-3BBD039ED03A} + VcpkgUseStatic + 10.0 + true + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreadedDebug + + + Console + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreaded + + + Console + true + true + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + \ No newline at end of file