- Home /
How to force monodevelop to use my code policy on new projects
I have found a few things around the internet about doing this, but none of them are permanent. I can get mono to use my policy, but the next time I switch to Unity and back it is using the default policy again.
I'm a bit of a neat freak when it comes to how my code looks and am getting really frustrated with having to write a block of code and then go back and put it how I typed it in the first place.
Any help appreciated.
Answer by Landern · Jun 10, 2014 at 02:45 PM
From my experience and i'm similar that i present my code layout in a particular way, a new solution in monodevelop gets all the defaults, creating a custom policy that i save, allowing me to apply it to new solutions when created is the trick.
From StackOverflow:
MonoDevelop->Custom Policies->Add Policy->New Policy
Edit the policy inside of the 'Custom Policies' window, making sure your policy is selected.
Project->Apply Policy->Apply Stock or Custom Policy Set (select your policy)->Apply
but you want to apply it to your solution:
(right click the solution, then Tools->Apply Policy) and save the solution under a new filename. That way, Unity won't overwrite your settings every time it regenerates the projects.
Edit again: after closing everything and manually rena$$anonymous$$g the solution it seems to be working, thanks for your help :)
What do you mean by 'manually rena$$anonymous$$g the solution' ? Every time I quit and re-open $$anonymous$$ono it's reverted back.
AHA, I think I solved it.
After creating your own policy and applying it by following the steps above, I did this:
Double check your formatting is showing correctly.
Rename the solution in $$anonymous$$onodevelop (right click the pink icon in the left sidebar and 'Rename' from '$$anonymous$$yUnityProject' to e.g. '$$anonymous$$yUnityProject fixed')
Close $$anonymous$$onoDevelop and find the folder the solution is saved into (should look something like /User/$$anonymous$$yUnityProject/) — You should see both your original solution '$$anonymous$$yUnityProject.sln' and your new one '$$anonymous$$yUnityProject fixed.sln'. Remove the original and then you can rename '$$anonymous$$yUnityProject fixed.sln' to your original file name '$$anonymous$$yUnityProject.sln'. Also do the same for the .userprefs files.
Reopen $$anonymous$$onoDevelop — everything should be working now! :)
Answer by fserb · Dec 11, 2015 at 12:35 PM
I think I found a better solution than forking the sln project.
Find where MonoDevelop store the policies.
In the case of Mac is: ~/Library/Preferences/MonoDevelop-Unity-5.0
.
You will find there a Default.mdpolicy.xml
and your own mdpolicy file ( WhateverYouNamedIt.mdpolicy.xml
).
Just overwrite the default with yours and suddenly it all goes to your policy as the default. I've tried a couple times and seems to be working fine.
Your answer
Follow this Question
Related Questions
MonoDevelop Doesn't Remember Policy File 0 Answers
Monodevelop formatting [Header] weirdly 0 Answers
Monodevelop Tab Error 0 Answers
Precompiler directives break MonoDevelop autoformat 0 Answers
MonoDevelop 4.0.1 auto (de)formatting 0 Answers