What is really annoying is to do again and again the same task without having something new to do.
Set a Visual Studio project is one of this thing that you would like to automatize.
The property manager allows us to do this kind of mechanism.
We, indeed, are going to see how to share configurations from many C++ projects.
Let’s get started.
Visual Studio IDE: https://visualstudio.microsoft.com/
Let’s create a solution and 3 projects:
Now if we wanted to set the 3 projects with the same settings we would have to modify one by one each project with exactly the same settings.
With the Property manager we are going to set on project and copy these settings to all other projects.
So, open the project 1 (p1) and click from Visual Studio > Other Windows > View > Property Manager.
You can see your project with different configurations with a tree like below :
Note that only the Microsoft.Cpp.x64.user file is modifiable but it’s not a good practise to modify this one.
Even if it’s a shared file, it’s shared for every project even those in the future.
So it’s a good practise to not using it.
You can remove this file or at least don’t use it at all.
You can always add it again, indeed you can find it in the following directory:
Other files (Application, Unicode Support and Core Windows Libraries) are in read-only mode.
Right click the Debug | x64 element > Add New Project Property Sheet…
Then enter the following information:
We have now a file in the solution folder that we are going to share with other projects.
This file is a Property Sheet (.props).
Note that this config_tutorial.props file is a general file, it means that if you change something directly on your project from Project > Properties, then these modifications will override settings in your config_tutorial.props.
Of course the config_mpi.props will stay untouched by the MSBuild engine.
Besides when you click the config_tutorial or Microsoft.Cpp.x64.User file directly from the Property Manager, you can see an arrow on the Property Manager toolbar.
This arrow is to evaluate the priority of the files, when a file in on top it’s more generic that those below.
It’s now time to modify this config_tutorial file.
You now add this file on each project.
From the Project Property manager > click p2 > Add Existing Property Sheet... > Select the file created before > C:\p\cpp\solution_tutorial\config_tutorial.
Do the same for the p3 project.
Now all your project p1, p2 and p3 share the same config_tutorial file.
You can see something like this:
p1
p2
p3
We are going to modify this file to see if modifications are impacted on all projects.
From the Property Manager, just double click the config_tutorial file.
Modify what you want then click Apply > OK to quit the Property Page window.
You have a last step to accomplish, indeed you need to save this file, for that click the blue disk icon in the Property Manager toolbar.
And you are done.
There are some settings that you can’t share whit other projects, for example from each project > Properties > Configuration Properties > Debugging.
This panel can’t be shared.
So the solution to this problem is to create a file within you’ll write all your arguments, flags, option and so on for your output file.
And set every project one by one to call this file when you launch your output file.
A nice practise to adopt as soon as possible in order to gain in productivity.
Good job you did it.
Add new comment