goneskiing
goneskiing

Reputation: 1819

Visual Studio and Imported MSBuild properties in vcxproj files

I was trying to factor out some properties in some C++ projects in a Visual Studio 2013 Update 4 solution into separate property files which I then Import into the vcxproj files. After doing so I noticed that the properties no longer seem to be reflected in the properties editor GUI. For instance if I Import this from some file

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
    <CharacterSet>Unicode</CharacterSet>
  </PropertyGroup>

rather than have it defined directly in the vcxproj file the "Character Set" item in the properties GUI appears as blank. However the C++ Command Line in the properties GUI does contain '/D "_UNICODE" /D "UNICODE"' so it would appear that the property is being noticed and taking effect.

So is this just a GUI thing or will doing something like this cause stuff to not to build correctly? My guess is that Visual Studio looks for elements like '' but only does so directly in the vcxproj file but not in anything it Imports.

Upvotes: 2

Views: 1320

Answers (2)

Karlson2k
Karlson2k

Reputation: 81

Visual Studio 2010, 2012, 2013, 2015, 2017, 2019 and 2022 creates list of visualised and editable options only from items in project file itself.

Items from included files are used only as default values for configuration options. Values from included files are processed and used, even if they are not visualised in GUI.

To see something in GUI, you have to add at least empty corresponding item in .vcxproj file.

For example, to see main configuration, you need to add empty "PropertyGroup" with label "Configuration" (for each project configuration) to .vcxproj file:

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
  </PropertyGroup>

To see name, location of output files and other general properties, add empty "PropertyGroup" without label:

  <PropertyGroup />

To see C/C++ compiler, linker and lib settings, add "ItemDefinitionGroup" with "ClCompile", "Link" and "Lib" items to .vcxproj file:

  <ItemDefinitionGroup>
    <ClCompile />
    <Link />
    <Lib />
  </ItemDefinitionGroup>

If you add everything, mentioned here, to your .vcxproj file, you will see all C/C++ settings in GUI and you will be able to change them.

Upvotes: 2

stijn
stijn

Reputation: 35901

If you are using 'propertysheets' properly you can see them in the Property Manager window in VS, nicely and hierarchically ordered, including the options contained in them. Which is really very convenient.

I guess you now manually modified the vcxproj and added an Import. While that works as well (as you can see is reflected in the commandline), it doesn't play together well with VS. So, don't do that but revert your change and head over to the property manager and add some property files there. VS will create the Import statements for you in the correct place, and should display all properties as usual.

Upvotes: 1

Related Questions