diff --git a/modules/android/tests/test_android_project.lua b/modules/android/tests/test_android_project.lua
index d7f2324260..43ef82b096 100644
--- a/modules/android/tests/test_android_project.lua
+++ b/modules/android/tests/test_android_project.lua
@@ -44,6 +44,7 @@
test.capture [[
{42B5DBC6-AE1F-903D-F75D-41E363076E92}
+ $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))
Android
MyProject
15.0
diff --git a/modules/vstudio/tests/vc2010/test_globals.lua b/modules/vstudio/tests/vc2010/test_globals.lua
index 874fc317eb..b72b7c5b3d 100644
--- a/modules/vstudio/tests/vc2010/test_globals.lua
+++ b/modules/vstudio/tests/vc2010/test_globals.lua
@@ -254,32 +254,27 @@
]]
end
---
--- Check that the "latest" systemversion works.
--- note: we override the os.getWindowsRegistry method for reliable tests.
---
+---
+-- Check handling of systemversion("latest")
+---
- function suite.windowsTargetPlatformVersionLatest_on2017()
- p.action.set("vs2017")
- systemversion "latest"
- local oldRegistry = os["getWindowsRegistry"]
- os["getWindowsRegistry"] = function (key) return "10.0.11111" end
- prepare()
- os["getWindowsRegistry"] = oldRegistry
- test.capture [[
+function suite.windowsTargetPlatformVersion_latest_on2015()
+ p.action.set("vs2015")
+ systemversion "latest"
+ prepare()
+ test.capture [[
{42B5DBC6-AE1F-903D-F75D-41E363076E92}
true
Win32Proj
MyProject
- 10.0.11111.0
- ]]
- end
+ ]]
+end
-
- function suite.windowsTargetPlatformVersionLatest_on2019()
- p.action.set("vs2019")
+
+ function suite.windowsTargetPlatformVersion_latest_on2017()
+ p.action.set("vs2017")
systemversion "latest"
prepare()
test.capture [[
@@ -288,18 +283,15 @@
true
Win32Proj
MyProject
- 10.0
+ $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))
+ $(LatestTargetPlatformVersion)
]]
end
---
--- Check that the "latest" systemversion will not add
--- when the action is less than 2017
---
- function suite.windowsTargetPlatformVersionLatest_on2015()
- p.action.set("vs2015")
+ function suite.windowsTargetPlatformVersion_latest_on2019()
+ p.action.set("vs2019")
systemversion "latest"
prepare()
test.capture [[
@@ -308,12 +300,19 @@
true
Win32Proj
MyProject
+ 10.0
]]
end
-
- function suite.windowsTargetPlatformVersionMultipleConditional_on2015Default()
+
+
+---
+-- Check handling of per-configuration systemversion
+---
+
+ function suite.windowsTargetPlatformVersion_perConfig_on2015()
p.action.set("vs2015")
+ systemversion "8.1"
filter "Debug"
systemversion "10.0.10240.0"
filter "Release"
@@ -325,6 +324,7 @@
true
Win32Proj
MyProject
+ 8.1
10.0.10240.0
@@ -334,12 +334,13 @@
]]
end
-
- function suite.windowsTargetPlatformVersionGlobalMultipleConditional_on2015Default()
- p.action.set("vs2015")
+
+
+ function suite.windowsTargetPlatformVersion_perConfig_on2017()
+ p.action.set("vs2017")
systemversion "8.1"
filter "Debug"
- systemversion "10.0.10240.0"
+ systemversion "latest"
filter "Release"
systemversion "10.0.10240.1"
prepare()
@@ -349,14 +350,15 @@
true
Win32Proj
MyProject
+ $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))
8.1
- 10.0.10240.0
+ $(LatestTargetPlatformVersion)
10.0.10240.1
]]
end
-
+
diff --git a/modules/vstudio/vs2010_vcxproj.lua b/modules/vstudio/vs2010_vcxproj.lua
index e6a8632652..acdfe4c0ca 100644
--- a/modules/vstudio/vs2010_vcxproj.lua
+++ b/modules/vstudio/vs2010_vcxproj.lua
@@ -131,13 +131,14 @@
m.keyword,
m.projectName,
m.preferredToolArchitecture,
- m.targetPlatformVersionGlobal,
+ m.latestTargetPlatformVersion,
+ m.windowsTargetPlatformVersion,
}
end
m.elements.globalsCondition = function(prj, cfg)
return {
- m.targetPlatformVersionCondition,
+ m.windowsTargetPlatformVersion,
}
end
@@ -2580,43 +2581,43 @@
end
- function m.targetPlatformVersion(cfgOrPrj)
-
- if _ACTION >= "vs2015" then
- local min = project.systemversion(cfgOrPrj)
- -- handle special "latest" version
- if min == "latest" then
- -- vs2015 and lower can't build against SDK 10
- -- vs2019 allows for automatic assignment to latest
- -- Windows 10 sdk if you set to "10.0"
- if _ACTION >= "vs2019" then
- min = "10.0"
- else
- min = iif(_ACTION == "vs2017", m.latestSDK10Version(), nil)
- end
- end
-
- return min
+ function m.latestTargetPlatformVersion(prj)
+ -- See https://developercommunity.visualstudio.com/content/problem/140294/windowstargetplatformversion-makes-it-impossible-t.html
+ if _ACTION == "vs2017" then
+ m.element("LatestTargetPlatformVersion", nil, "$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))")
end
-
end
- function m.targetPlatformVersionGlobal(prj)
- local min = m.targetPlatformVersion(prj)
- if min ~= nil then
- m.element("WindowsTargetPlatformVersion", nil, min)
+ function m.windowsTargetPlatformVersion(prj, cfg)
+ if _ACTION < "vs2015" then
+ return
end
- end
+ local target = cfg or prj
+ local version = project.systemversion(target)
- function m.targetPlatformVersionCondition(prj, cfg)
+ -- if this is a config, only emit if different from project
+ if cfg then
+ local prjVersion = project.systemversion(prj)
+ if not prjVersion or version == prjVersion then
+ return
+ end
+ end
- local cfgPlatformVersion = m.targetPlatformVersion(cfg)
- local prjPlatformVersion = m.targetPlatformVersion(prj)
+ -- See https://developercommunity.visualstudio.com/content/problem/140294/windowstargetplatformversion-makes-it-impossible-t.html
+ if version == "latest" then
+ if _ACTION == "vs2015" then
+ version = nil -- SDK v10 is not supported by VS2015
+ elseif _ACTION == "vs2017" then
+ version = "$(LatestTargetPlatformVersion)"
+ else
+ version = "10.0"
+ end
+ end
- if cfgPlatformVersion ~= nil and cfgPlatformVersion ~= prjPlatformVersion then
- m.element("WindowsTargetPlatformVersion", nil, cfgPlatformVersion)
+ if version then
+ m.element("WindowsTargetPlatformVersion", nil, version)
end
end