Skip to content

Instantly share code, notes, and snippets.

@tomcurran
Last active June 13, 2024 17:18
Show Gist options
  • Save tomcurran/c261ffaf77304d0f7dd51800abff7e24 to your computer and use it in GitHub Desktop.
Save tomcurran/c261ffaf77304d0f7dd51800abff7e24 to your computer and use it in GitHub Desktop.
MSBuild Additional DefineConstants via property
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="DisplayMessages">
<Message Text="Configuration: $(Configuration)" />
<Message Text="DefineConstants: $(DefineConstants)" />
<Message Text="AdditionalDefineConstants: $(AdditionalDefineConstants)" />
</Target>
<PropertyGroup>
<DefineConstants>TEST</DefineConstants> <!-- this DefineConstants is optional -->
<DefineConstants Condition=" '$(AdditionalDefineConstants)' != '' ">$(DefineConstants);$(AdditionalDefineConstants)</DefineConstants>
</PropertyGroup>
</Project>
msbuild test.csproj /t:DisplayMessages /p:Configuration=Release /p:AdditionalDefineConstants="Additional_Define_Constants_Here"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment