Visual Studio: can I copy a project's properties to use in another project?

Viewed 69663

I've added several directories, libraries such as matlab, opencv, etc to compile my current C file in Visual Studio project.

All my upcoming projects will require the same setup/properties. Do I need to setup my each project's properties individually or I can do something to apply it to all ?

4 Answers

For Visual Studio 2010+ you can make a Project Template.

If you choose to automatically add the template to Visual Studio in the template creation wizard, when you create/add a new project, the template will appear (after restarting Visual Studio). Projects created with this template will have the same project properties!

To add source code files to the template, the easiest way is to rearrange the source code files in solution-explorer to be in the root (not under any folder). After doing that, THEN generate the template.

Why? Sometimes putting your files under the default Source Code solution-explorer folder (not in file explorer, the .project.filters label) will fail to copy the source file to the template, you'll see "the document cannot be opened. it has been renamed deleted or moved" when you try to use the template and the file you wanted in the template will NOT be in the file explorer.

If you do want solution-explorer folders, you will have to add them manually to the template by unzipping the template folder, making changes, then re-zipping it again.

For example, literally copy and paste the source files you want the template to have in the template folder and edit the .vstemplate file. M$ Doc on template editing.

<TemplateContent>
<!-- put new file references here and/or in your .vcxproj .vcxproj.filters --> 
 TargetFileName="HelloWorld.cl">HelloWorld.cl</ProjectItem>
      <ProjectItem ReplaceParameters="false" 
</TemplateContent>

Related questions:

How do I use VS template I created?

How can i load a template I have created in Visual Studio?

How copy visual studio project?

Simply copying and pasting entire projects and solutions is not recommended for complex or shared projects since various GUID s and filenames may overlap - causing bugs.

For MSVS 2017, the process @AaronMK mentioned doesn't work. Instead do the following:

  1. View -> Other Windows -> Property Manager
  2. Add New Property Sheet.
  3. Edit whatever options you want there.
  4. Give it an appropriate name so that you remember it.
  5. Right button on it and hit "Save {myPropertySheet}"
  6. It would be wise to place it alongside the default property sheets and that you can add it whenever you want (by Property Manager -> Add Existing Property Sheet -> Browse to its location). This directory is: C:\Users\{myUsername}\AppData\Local\Microsoft\MSBuild\v4.0

Alternatively you can edit the default property sheets and use these by default. I wouldn't advice it though as they provide a fallback option in case you mess up. So make backups first if editing default files.

Related