Export an project setting from visual studio 2010 - c++

I have created a project under an solution. I have set up all boost libs and some other project properties such as code generation.
Now I want to create another project and use the same settings. How can I reuse all the settings i have just used in this project in another project
I found another solution which involves property sheets:
Visual Studio: can I copy a project's properties to use in another project?
While in that case I need to create and setup the property sheet. Isn't there an simple solution like export and import?

As far as I know there is no import/export fuctionality (probably because property sheets exist).
Simple way: copy the project file, rename it, open it in a text editor and change the ProjectGuid (just modifying a single char/digit should be fine) and RootNamespace to match your new project name. New project, same settings.
Proper way: if you would have made your original changes to property sheets in the first place, you'd already have everything needed and could simply re-use those property sheets in any new project. So you could just start over now and create a new project, add a property sheets for boost stuff, another one for compiler/linker settings and so on (multiple property sheets is a good thing, as the can be combined in a modular way at will). Or you can create a new project, add property sheet and open it in a text editor side-by-side with your current project and just copy-paste the settings you altered.= to the property sheet.

Related

Apply a property change to all DLL projects in a solution

I have a solution containing approximately 150 projects, including static libraries, dynamic libraries and executables as well as a few Makefile based projects for good measure, so I have an extended version of this guy's problem.
I need to apply a change to the linker page of all EXE and DLL projects (add /FIXED:NO for the benefit of Rational Purify). Is there a way I can do this easily, e.g. with the help of a macro?
I would modify the project files directly - they are XML after all, and you can easily discover what change needs to be done in them to add the flag. Then you can write an e.g. Python script to modify all project files.
You can make a common project property, Then you can modify the related projects to inherit this common property, so when next time you just need to modify the common project property, then the projects inherit it will automatically sync the new settings. Property Sheets (C++)
To apply project settings that are defined in property sheets using the Inherited Project Property Sheets property:
To apply project settings that are defined in property sheets using the Inherited Project Property Sheets property
Open your project in the Visual Studio IDE.
In Solution Explorer, right-click the node for the project or the property sheet that will inherit the project configuration.
On the shortcut menu, click Properties. The property pages for your project will appear.
Use the Configuration control to specify which project configuration to apply the project settings.
In the Inherited Project Property Sheets field of the General property page, enter the path to the property sheet that contains the settings you want to inherit.
Click Apply.
This is exactly the sort of thing property sheets were designed for. Create a hierarchy of property sheets which contain settings that are common to certain types of project, then attach them to the relevant projects, using property manager (View menu -> Property manager).
For example:
All.props -> settings common to all projects
Debug.props -> settings common only to debug builds
Release.props -> settings common only to release builds
Static.props -> settings common only to static library projects
Dynamic.props -> settings common only to dynamic library projects
Executable.props -> settings common only to executable projects
This will require a small amount of work up-front, to add the property sheets to your existing projects. Then, whenever you create a new project, all you have to do is attach the relevant property sheets. Maintenance becomes easy - to change a setting and have that change apply to all executable projects, you simply update the property sheet Executable.props.
Note: property sheets are sorted according to their place in the hierarchy, so that a setting which is in a property sheet higher up will override the same setting in a sheet which is lower down the list. This is a big advantage - you can place your default settings in All.props (from my example above), and then override settings in more specific property sheets. If you have a one-off project with its own unique settings, then modifying the project settings directly will override all property sheets.

Can you copy linker/additional dependancies etc to other projects

I consistently have to add directx lib files etc to all of my projects, dependencies, linker stuff etc...
Is there a file I can copy across that has all that stuff.. and I just copy it to every project that needs it?
Yes. You have the option of creating a property sheet that can be added to new or existing projects. Here are the basic steps.
Open the Property Manager (View menu).
Right click on a project and select "Add New Property Sheet"
Once the property sheet has been created/added right click on it and add your common configuration settings (the same way you do in a project's properties).
Once you've created the property sheet you can add it to new or existing projects in much the same way.
Open the Property Manager.
right click on the project you want to add the property sheet to and click "Add Existing Property Sheet".
I don't recommend copying into each project or solution directory but rather keep in in a central place much like you would a third party library (i.e. Boost).

Visual Studios (2012 pro mainly) file location of defaults for <inherit from parent or PROJECT DEFAULTS>

I always add the _CRT_SECURE_NO_WARNINGS to all of my C/C++ projects in the Preprocessor Definition tab in the Project Properties. There is the drop-down for <edit> and <inherit from parent or project defaults>. How do I change the values of the project defaults. I would think it is an XML file hidden somewhere, or that file needs to be created. Anyone know the location?
View -> Property Manager, then expand a project and build configuration to see the property sheets being used for that build configuration. Right-click on a property sheet and select Properties to modify the property sheet. I don't recommend modifying the built-in property sheets, however there is a .user property sheet for this purpose. You can also create your own property sheet that defines the preprocessor macro, then add your new property sheet to the list for each build configuration.
My answer and description here will neatly solve this. It uses property sheets, as Hans Passant suggested.
The general setup is to a create a property sheet containing all of the necessary shared settings, optionally in multiple groups with conditions based on build type. You then include the property sheet from each project file.

Is there a tool that allows you to custom build a vcproj?

We have several Visual Studio projects, and we would like to:
enable/disable some defines on some of the projects
add/remove include paths
change output directories ( lib dependencies ) for libs
In a nutshell, we would like to be able to support all of the things above, without having to have a lot of configurations in the solution file. Is there some tool which allows us to do that, perhaps from command-line, if VS doesn't support such a thing? We are using VS2005 Professional.
You can use property sheets to share build settings accross several projects. Projects can use multiple property sheets and property sheets can inherit from each other allowing you to mix and match however you need to.
In the build settings dialog for you project, you will need change the settings you are concerned about to <inherit from project defaults>. In this context, default means to take the value from the property sheet. Any default settings will appear non-bold, while settings that customized for the project are bold.
After that, you can change the values in the property sheets and have those changes applied to all the projects that use them at once.
You can use CMake to generate a VS .sln and .vcproj files.

How to set configuration properties in VS once and for all?

In VS 2010RC I have to specify configuration properties and specifically included path every time I'm creating new project. Is there a way to do it just once for all future projects?
I'm asking this for a reason that I'm starting to use Boost libraries and I have to specify all those paths every time I'm creating project which is bit tedious.
The VC++ Directories (which is what I think you're looking to configure) have been moved to a property sheet to make them more MSBuild-friendly.
A snippet from http://blogs.msdn.com/vsproject/archive/2009/07/07/vc-directories.aspx:
If you open up the Property Manager view to see the property sheets associated with your project, you’ll see that one of the property sheets is named Microsoft.Cpp.Win32.User. This property sheet is actually stored in LocalAppData, just as VCComponents.dat file was, in the directory %LocalAppData%\Microsoft\VisualStudio\10.0. Using the property editor on the property sheet (just right-click on this property sheet node and select Properties…), you can see that you are able to make edits directly to this file. Since all projects, by default, import this property sheet, you are effectively editing the VC++ directories in the same way you were able to do before.
See the following for more details on property sheets in VC++ 2010:
http://blogs.msdn.com/vsproject/archive/2009/06/23/inherited-properties-and-property-sheets.aspx
I usually copy the *.vcproj and *.sln files and then edit them, changing files and project names. If you create projects frequently, you may want to copy the files, edit them to the bare minimum and save as read-only stencils.