Skip to content

Properly filter .NET build events for configuration #2215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 36 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,44 @@
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" }
filter ""
prepare()
test.capture [[
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PreBuildEvent>command1</PreBuildEvent>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PreBuildEvent>command2</PreBuildEvent>
</PropertyGroup>
]]
end

function suite.onMultipleConfigsNoFilter()
configurations {"Debug", "Release"}
postbuildcommands { "command1" }
prepare()
test.capture [[
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PostBuildEvent>command1</PostBuildEvent>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PostBuildEvent>command1</PostBuildEvent>
</PropertyGroup>
]]
end

--
-- Multiple commands should be separated with un-escaped EOLs.
Expand All @@ -81,7 +112,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 +125,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
Loading