{"id":7131,"date":"2020-12-23T08:54:51","date_gmt":"2020-12-23T16:54:51","guid":{"rendered":"https:\/\/visualgdb.com\/w\/?p=7131"},"modified":"2020-12-23T08:55:41","modified_gmt":"2020-12-23T16:55:41","slug":"importing-msbuild-property-sheets","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/documentation\/projects\/msbuild\/propertysheets\/importing\/","title":{"rendered":"Importing MSBuild Property Sheets"},"content":{"rendered":"<p>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.<\/p>\n<p>First of all, create a property sheet file (e.g. test.props) that will define the necessary properties inside a <strong>PropertyGroup<\/strong> with the &#8220;<strong>UserMacros<\/strong>&#8221; label:<\/p>\n<pre>&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt; \r\n&lt;Project ToolsVersion=\"4.0\" xmlns=\"http:\/\/schemas.microsoft.com\/developer\/msbuild\/2003\"&gt;\r\n  &lt;PropertyGroup Label=\"UserMacros\"&gt;\r\n    &lt;TestProperty&gt;TestValue&lt;\/TestProperty&gt;\r\n  &lt;\/PropertyGroup&gt;\r\n&lt;\/Project&gt;<\/pre>\n<p>Then, add the following lines to the<strong> .vgdbsettings<\/strong> file (or the <strong>.vgdbcmake\/.vgdbproj<\/strong> file when using advanced project types) directly under the <strong>VisualGDBProjectSettings2<\/strong> element:<\/p>\n<pre>  &lt;ImportedPropertySheets&gt;\r\n    &lt;ImportedPropertySheet&gt;\r\n      &lt;Path&gt;PropertySheet.props&lt;\/Path&gt;\r\n    &lt;\/ImportedPropertySheet&gt;\r\n  &lt;\/ImportedPropertySheets&gt;<\/pre>\n<p>The <strong>Path<\/strong> element should contain the relative path to the property sheet file that is being imported.<\/p>\n<p>The <strong>$(TestProperty)<\/strong> 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 &#8220;<strong>cmd.exe \/c echo $(TestProperty)<\/strong>&#8220;. In this example, it will output &#8220;<strong>TestValue<\/strong>&#8220;.<\/p>\n<p>Although VisualGDB cannot fully evaluate MSBuild conditions, you can use the syntax below to limit the properties imported by VisualGDB:<\/p>\n<pre>&lt;ImportedPropertySheet&gt;\r\n    &lt;Path&gt;PropertySheet.props&lt;\/Path&gt;\r\n    &lt;MatchingCondition&gt;'$(Configuration)' == 'Debug'&lt;\/MatchingCondition&gt;\r\n&lt;\/ImportedPropertySheet&gt;<\/pre>\n<p>This will restrict the imported variables to variables with no condition and variables where the condition is set to exactly <strong>&#8216;$(Configuration)&#8217; == &#8216;Debug&#8217;<\/strong>.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>VisualGDB supports importing variables from MSBuild property sheets, so that they can be used anywhere throughout VisualGDB Project Properties. This<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[227],"tags":[],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/7131"}],"collection":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/comments?post=7131"}],"version-history":[{"count":1,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/7131\/revisions"}],"predecessor-version":[{"id":7132,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/7131\/revisions\/7132"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=7131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=7131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=7131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}