Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set PlatformToolset from custom property sheet in Visual Studio 2010

I am moving now from VS 2005 to VS 2010 with products consisting of few solutions with numerous projects each. I wanted to make use of the property sheets system so our numerous configurations would be easier to maintain.

One of the issues is that we want to use Windows SDK 7.1 (as we need BaseClasses sample - and if we have to use that sample that why not the entire SDK)? But this requires me to change PlatformToolset on each and every single project in all the solutions. Also we will have to remember to change that value for newly added projects. Rather bad idea.

So I wanted to set this (among other things) from a custom property sheet. There is no such option directly from dialog shown when setting properties on property sheet. Adding entries manually to the XML file didn't help as well (but I haven't also seen any error or warning message).

Then how am I supposed to set default PlatformToolset value? At best in a configuration file which can be committed to repository. But if it could be done in some computer local settings then it would be acceptable too.

(Note that I know that I can use BaseClasses differently and avoid that problem at all but I think it is interesting issue in itself.)

I also asked this question at MSDN Formus.

like image 300
Adam Badura Avatar asked Jun 30 '10 10:06

Adam Badura


1 Answers

PlatformToolset must be set in project properties at the begin of the file before inclusion of other files so that it can be later used to set up some defaults. If non is set then those inclusions will set it up to some default value.

Resetting it later even if works is pointless as everything was already included/set up. So to change the default value to a different SDK it seems VS configuration files (those which are included) should be changed appropriately.

But this does not have to be a good thing because it is local for the machine.

There is also an option of manual inclusion of property file which sets the PlatformToolset before default inclusions. However MS warns that if project file does not keep proper order (and this would spoil the order) VS GUI tools for project set up might not work properly.

In the end I just manually changed all projects. New projects also have to be changed to the new PlatformToolset.

like image 122
Adam Badura Avatar answered Nov 09 '22 18:11

Adam Badura