Monday, February 4, 2013

Getting Umbraco 6 to play nicely with Visual Studio

When developing Umbraco 6 thru Visual Studio (in my case VS2012) it (VS) was not playing nicely.

My main issue was that intellisense and even compilation didn't work for SurfaceControllers. Compilation would succeed every time not giving me errors until run-time.

The issue is that Visual Studio thought this was a Web Forms project (wich Umbraco is), but I was working with MVC. I found the solution in this blog post by Colin Angus MacKay at the bottom.

Solution:

To do this, you need to right click on the web project and click “Unload Project”, when it has unloaded, right-click again and click “Edit xxx.csproj”.
Look for the element named “ProjectTypeGuids” and add in the guid:
{E3E379DF-F4C6-4180-9B81-6769533ABE47}

Separate the GUIDs with semi-colon. Then reload the project.

The project is the main Umbraco project (in case you have more than one). You will have to re-set the project as Start-up project after this.

Update: It seems to be a little unstable, as VS suddenly reverted to old (bad) behaviour. Unloading then reloading project fixed it, but hopefully there is a better solution. Will update if I find one.

Note: Umbraco 6 already ships with MVC 4 and has built in support for Controllers (called SurfaceControllers) so the rest of Colin's blog entry is not necessary for Umbraco 6.

Update: When retrying this I found that I had to put the new GUID first in the list. The project refused to load when I put the GUID at the end.