Skip to content

Commit

Permalink
Properly filter .NET build events for configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
mendsley committed May 28, 2024
1 parent d842e67 commit 35251f7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
26 changes: 21 additions & 5 deletions modules/vstudio/tests/cs2005/test_build_events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
prebuildcommands { "command1" }
prepare()
test.capture [[
<PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PreBuildEvent>command1</PreBuildEvent>
</PropertyGroup>
]]
Expand All @@ -55,7 +55,7 @@
postbuildcommands { "command1" }
prepare()
test.capture [[
<PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PostBuildEvent>command1</PostBuildEvent>
</PropertyGroup>
]]
Expand All @@ -66,13 +66,29 @@
postbuildcommands { "command2" }
prepare()
test.capture [[
<PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PreBuildEvent>command1</PreBuildEvent>
<PostBuildEvent>command2</PostBuildEvent>
</PropertyGroup>
]]
end

function suite.onMultipleConfigs()
configurations {"Debug", "Release"}
filter "configurations:Debug"
prebuildcommands { "command1" }
filter "configurations:Release"
prebuildcommands { "command2" }
prepare()
test.capture [[
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PreBuildEvent>command1</PreBuildEvent>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PreBuildEvent>command2</PreBuildEvent>
</PropertyGroup>
]]
end

--
-- Multiple commands should be separated with un-escaped EOLs.
Expand All @@ -81,7 +97,7 @@
function suite.splits_onMultipleCommands()
postbuildcommands { "command1", "command2" }
prepare()
test.capture ("\t<PropertyGroup>\n\t\t<PostBuildEvent>command1\r\ncommand2</PostBuildEvent>\n\t</PropertyGroup>\n")
test.capture ("\t<PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Debug|x86' \">\n\t\t<PostBuildEvent>command1\r\ncommand2</PostBuildEvent>\n\t</PropertyGroup>\n")
end


Expand All @@ -94,7 +110,7 @@
postbuildcommands { '\' " < > &' }
prepare()
test.capture [[
<PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PostBuildEvent>' " &lt; &gt; &amp;</PostBuildEvent>
</PropertyGroup>
]]
Expand Down
13 changes: 7 additions & 6 deletions modules/vstudio/vs2005_dotnetbase.lua
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,13 @@
end
end

local cfg = project.getfirstconfig(prj)
if #cfg.prebuildcommands > 0 or #cfg.postbuildcommands > 0 then
_p(1,'<PropertyGroup>')
output("Pre", cfg.prebuildcommands)
output("Post", cfg.postbuildcommands)
_p(1,'</PropertyGroup>')
for cfg in project.eachconfig(prj) do
if #cfg.prebuildcommands > 0 or #cfg.postbuildcommands > 0 then
_p(1,'<PropertyGroup %s>', dotnetbase.condition(cfg))
output("Pre", cfg.prebuildcommands)
output("Post", cfg.postbuildcommands)
_p(1,'</PropertyGroup>')
end
end
end

Expand Down

0 comments on commit 35251f7

Please sign in to comment.