Importing MSBuild Property Sheets

VisualGDB supports importing variables from MSBuild property sheets, so that they can be used anywhere throughout VisualGDB Project Properties. This page provides brief instructions to do it.

First of all, create a property sheet file (e.g. test.props) that will define the necessary properties inside a PropertyGroup with the “UserMacros” label:

<?xml version="1.0" encoding="utf-8"?> 
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup Label="UserMacros">
    <TestProperty>TestValue</TestProperty>
  </PropertyGroup>
</Project>

Then, add the following lines to the .vgdbsettings file (or the .vgdbcmake/.vgdbproj file when using advanced project types) directly under the VisualGDBProjectSettings2 element:

  <ImportedPropertySheets>
    <ImportedPropertySheet>
      <Path>PropertySheet.props</Path>
    </ImportedPropertySheet>
  </ImportedPropertySheets>

The Path element should contain the relative path to the property sheet file that is being imported.

The $(TestProperty) expression can now be referenced anywhere in the VisualGDB Project Properties (e.g. directory uploading settings, build commands, custom build/debug actions). You can test it by adding a custom pre-build action running “cmd.exe /c echo $(TestProperty)“. In this example, it will output “TestValue“.

Although VisualGDB cannot fully evaluate MSBuild conditions, you can use the syntax below to limit the properties imported by VisualGDB:

<ImportedPropertySheet>
    <Path>PropertySheet.props</Path>
    <MatchingCondition>'$(Configuration)' == 'Debug'</MatchingCondition>
</ImportedPropertySheet>

This will restrict the imported variables to variables with no condition and variables where the condition is set to exactly ‘$(Configuration)’ == ‘Debug’.