Skip to content
| Marketplace
Sign in
Visual Studio>Tools>Per Project Configuration
Per Project Configuration

Per Project Configuration

Teh Markos

|
748 installs
| (1) | Free
This extension configures Visual Studio based on active document.
Download

Per Project Configuration

Introduction

Per Project Configuration is an extension that allows to export Visual Studio settings to a file and load the settings based on active solution, project or document. It is possible to assign different settings for each directory or file. Directory hierarchy is traversed so you can store common settings in root directory and only changed values in project directory. Configuration files are watched and loaded automatically whenever they are changed (on the fly).

This extension works great in team projects, when each project you are working on requires different code formatting.

Settings are stored in file named ".vsconfig" or "document.vsconfig" and is in human-editable ini format. Since settings are read from directory tree, it is possible to store only differences between configurations and keep the file short and clean.

Instructions

Export Settings

  1. Click 'Tools -> Per Project Configuration -> Export Configuration'
  2. Select configuration categories you would like to export, e.g. 'TextEditor/CSharp' and 'TextEditor/CSharp-Specific'
  3. Click on 'Export' button, new panel will appear
  4. Type in target file location or click the 'Browse' button to navigate to the directory that you want to save it in
  5. Click on 'OK' button; the extension will work for a while and the window will close when it's done

Export Settings to make incremental difference

Let's assume that you store projects in directory 'C:\Projects' and that the project you want to make incremental setting file is in directory 'C:\Projects\MyProject'

  1. Configure Visual Studio as you normally use it (e.g. set your preferred code formatting settings)
  2. Export settings as described in section 'Export Settings', but in step 4 enter 'C:\Projects\.vsconfig' as the target file
  3. Change Visual Studio settings (e.g. set code formatting as required by 'MyProject' project)
  4. Click 'Tools -> Per Project Configuration -> Export Configuration'
  5. Select configuration categories you would like to export, e.g. 'TextEditor/CSharp' and 'TextEditor/CSharp-Specific'
  6. Click on 'Export & Diff' button, new panel will appear
  7. In 'Existing File' input box enter 'C:\Projects\.vsconfig' (the file you used in step 2)
  8. In 'Target File' input box enter 'C:\Projects\MyProject\.vsconfig'
  9. Click on 'OK' button; the extension will work for a while and the window will close when it's done

Now you have 2 exported files. First 'C:\Projects\.vsconfig', which is used for ALL documents under 'C:\Projects' directory (and its childs), second 'C:\Projects\MyProject\.vsconfig' which is used for all documents under 'C:\Projects\MyProject'. Project MyProject now used BOTH configuration files - it loads the full settings from 'C:\Projects\.vsconfig' and incremental changes from 'C:\Projects\MyProject\.vsconfig'.

How the settings hierarchy works

Let's assume that you store projects in directory 'C:\Projects' and you have 3 projects in that directory: 'NormalProject1', 'NormalProject2' and 'DifferentProject1'.

If you store settings in 'C:\Projects\.vsconfig' file, it will be used by all 3 projects. Now, if you add settings to 'C:\Projects\DifferentProject1\.vsconfig', 'DifferentProject1' will now use both setting files. It first loads file 'C:\Projects\.vsconfig' and then 'C:\Projects\DifferentProject1\.vsconfig'.

Now, let's assume that for some reason you want to change settings only for one file 'C:\Projects\DifferentProject1\MySpecialFile.cs'. Export & Diff another settings file and name it 'C:\Projects\DifferentProject1\MySpecialFile.cs.vsconfig'. Now, when you switch to 'MySpecialFile.cs' in Visual Studio, it loads all 3 settings files in the hierarchy (in Projects dir, in DifferentProject1 dir and in MySpecialFile.cs.vsconfig), and when you switch back to file 'Program.cs', VS will load only the configs in Projects and DifferentProject1.

You may use any number of .vsconfig files you want (it is only limited by the directory structure that you have). One for each directory and one for each file.

But I want to turn this 'settings hierarchy' thing off for my project

Yes, that is possible. If you don't want project 'DifferentProject1' to load the shared .vsconfig in 'C:\Projects', you could use special value 'root = true' set in the settings file.

    Just open 'C:\Projects\DifferentProject1\.vsconfig' in your favorite text editor (Notepad will do) and add line 'root = true' (without the quotes) just in the beginning of the file (line 1; or simply section named [] will be enough).

    Known limitations

    • Not all settings can be exported (e.g TextEditor/AllLanguages)
    • Not all settings can be imported (surprisingly TextEditor/AllLanguages CAN be imported if vsconfig is written by hand)
    • Some settings can be exported but not imported and vice versa
    • Some extensions' settings cannot be accessed at all

    If something can't be exported, imported or some error occurs, check messages in 'Output' window, 'Show output from' 'PerProjectConfig' dropdown.

    If automatically exported file contains settings that can't be imported, feel free to edit the .vsconfig file and remove the affected entries.

    Contact me

    Feel free to ask questions if something is not clear, I am ready for CONSTRUCTIVE feedback and suggestions.

    Please, if you did not understand how this works, read this document or ask question, do not give me 1 star. Also, if you don't need such functionality, do not rate it with 1 star and comment 'Useless'. I have written this extension for myself 3 years ago and it never crashed my Visual Studio, so please do not 1-star me - the problem will probably be somewhere else, e.g. conflicting extensions.

    Updates

    • Contact us
    • Jobs
    • Privacy
    • Manage cookies
    • Terms of use
    • Trademarks
    © 2025 Microsoft