C# Formatter Import/Export Settings

How do you import/export your C# formatter code-settings found in the integrated IDE that comes with Unity?

I would like to import/export my C# formatter code-settings (in Unity) and make it a standard in my workplace.

I know this is a pretty old post, but I think you can just copy ~/Library/MonoDevelop-Unity-2.8/Policies/Default.mdpolicy.xml to the same folder on other machines. I wanted to do the same thing recently and found this article about exporting the formatter and other settings:

http://www.patridgedev.com/2013/06/18/making-monodevelop-for-mac-more-like-visual-studio/

Forewords

I found that post when I had a problem about importing an exported config file (called policy in this software), later on I managed to solve my problem so I want to share my solution for those of you who had this problem.

In order to have a correct policy file to import you have to create it by hand in the Tools > Custom Policies... menu, otherwise your beloved policy file won’t work during the import process.

So let’s begin with the policy file creation !

Create a policy file

As said previously you need to create it in Tools > Custom Policies... from scratch. Why does I insist on that? Because MonoDevelop allow you to generate a new policy from project or solution, but it’s a trap! Doing so the export process will create a corrupted policy file… pointless.

So to avoid this do:

  1. Add Policy > New policy..., name it and set its base settings, then OK.
  2. You will see your new policy name selected in the Editing Policy list.
  3. Set all the stuffs you want (like Code Formatting).
  4. Click OK, very important because if you skip this you’ll lost your beloved policy

Now you have customized policy, you can then export it…

Export your policy

  1. go to Tools > Custom Policies...
  2. then Export > To file..., and save where you want.
  3. Here no need to click OK if you did it earlier.

You now have a file ready to be imported.

Import a policy file

  1. Tools > Custom Policies…
  2. Click “Add Policy” and “From file…”
  3. Open your exported policy file
  4. Confirm with OK

Et voilà !
Hope it helps.

This post managed to helped me to find a way to make it works. This one is from the MonoDevelop forum archives.