I want to be able to reference an MSBuild (3) property using the contents of another property. For example:
<PropertyGroup>
<SelectVariable>Test</SelectVariable>
<TestVariable>1</TestVariable>
<FullVariable>2</FullVariable>
</PropertyGroup>
<Message Text="Value $($(SelectVariable)Variable)"/>
In this scenario, I want the contents of TestVariable outputted (1). Is this possible?
Sure this is possible. Just do:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SelectVariable>Test</SelectVariable>
<TestVariable>1</TestVariable>
<FullVariable>2</FullVariable>
</PropertyGroup>
<Target Name="Demo01">
<PropertyGroup>
<Value>$(SelectVariable)Variable</Value>
</PropertyGroup>
<Message Text="Value $(Value)"/>
</Target>
</Project>
The result is shown in the image below.

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With