summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-06-03 23:55:44 +0800
committerruki <[email protected]>2024-06-03 23:55:44 +0800
commitc1781dc638853e65f86261f3a7c2eede7044eb29 (patch)
tree3b3a9193ab037229919c58df4f80a8e52081abe9
parenta1d6ba0e17e3a50ed7fb076cdd3309e6b0705704 (diff)
improve msbuild
-rw-r--r--xmake/modules/private/action/trybuild/msbuild.lua13
1 files changed, 11 insertions, 2 deletions
diff --git a/xmake/modules/private/action/trybuild/msbuild.lua b/xmake/modules/private/action/trybuild/msbuild.lua
index c09a178af..d8e1f1baa 100644
--- a/xmake/modules/private/action/trybuild/msbuild.lua
+++ b/xmake/modules/private/action/trybuild/msbuild.lua
@@ -42,7 +42,11 @@ function clean()
local projectfile = _find_projectfile()
local runenvs = toolchain.load("msvc"):runenvs()
local msbuild = find_tool("msbuild", {envs = runenvs})
- os.vexecv(msbuild.program, {projectfile, "-nologo", "-t:Clean", "-p:Configuration=Release", "-p:Platform=" .. (is_arch("x64") and "x64" or "Win32")}, {envs = runenvs})
+ local projectdata = io.readfile(projectfile)
+ if projectdata and projectdata:find("Any CPU", 1, true) then
+ platform = "Any CPU"
+ end
+ os.vexecv(msbuild.program, {projectfile, "-nologo", "-t:Clean", "-p:Configuration=Release", "-p:Platform=" .. platform}, {envs = runenvs})
end
-- do build
@@ -55,6 +59,11 @@ function build()
local projectfile = _find_projectfile()
local runenvs = toolchain.load("msvc"):runenvs()
local msbuild = find_tool("msbuild", {envs = runenvs})
- os.vexecv(msbuild.program, {projectfile, "-nologo", "-t:Build", "-p:Configuration=Release", "-p:Platform=" .. (is_arch("x64") and "x64" or "Win32")}, {envs = runenvs})
+ local platform = is_arch("x64") and "x64" or "Win32"
+ local projectdata = io.readfile(projectfile)
+ if projectdata and projectdata:find("Any CPU", 1, true) then
+ platform = "Any CPU"
+ end
+ os.vexecv(msbuild.program, {projectfile, "-nologo", "-t:Build", "-p:Configuration=Release", "-p:Platform=" .. platform}, {envs = runenvs})
cprint("${color.success}build ok!")
end