How to setup Umbraco 6.1.2 in Visual Studio 2012 w

2019-06-08 02:08发布

问题:

What I want is a development environment in Visual Studio 2012 for Umbraco version 6.1.2 (latest stable version at the moment) with MVC as rendering engine so I can use Razor and integrate a MVC project in Umbraco.

I also want to be able to use a Team Foundation Sever to share and store the code.

The problem lies here: When I just download the Umbraco files from Umbraco or use WebMatrix to install an Umbraco site, I do not have access to the core files or a way to properly debug my install in Visual Studio.

So I need a way to build and debug/run Umbraco from Visual Studio.

I looked at a lot of posts, articles etc. (also on StackOverflow) but none seemed to address the latest Umbraco version (most about 4.5.x) and only a few about MVC. Old references, non existing project templates or templates to old versions of VS made me have to dig further. When I then found a solution, I thought about 2 things: - 1 I need to check this solution - 2 I should share this solution to a wider audience then it is getting now

Both two reasons are what made me post it here (clarification as asked)

回答1:

Actually, all you need to do is create an empty MVC4 project and add the Umbraco NuGet package, as this will also add the Core binaries package and set the dependencies for you.



回答2:

I found http://www.ben-morris.com/using-umbraco-6-to-create-an-asp-net-mvc-4-web-applicatio, which is the lastest article about the subject I could find (the download link in the article is to the old repository and not the current download page of Umbraco, though).

This setup worked really well for me (Umbraco version 6.1.2)

  1. Firstly, start an empty MVC 4 project in Visual Studio – make sure it is an empty project as you will not need any of the baggage that comes with other project templates.
  2. Add the NuGet Umbraco Cms Core Binaries package which will manage the various dependencies and references that Umbraco 6 requires for you.
  3. Copy all the files from the Umbraco installation ZIP archive directly into your project in Visual Studio except the App_Code and Bin folders – you won’t need the binaries as they are managed by NuGet and the App_Code folder is not used in a web application project.

If you want Umbraco to play nice to MVC and be able to use Razor views, you should change the default rendering engine to MVC in Config\UmbracoSettings.config like so:

<templates>
  <useAspNetMasterPages>true</useAspNetMasterPages>
  <defaultRenderingEngine>Mvc</defaultRenderingEngine>
</templates>


回答3:

One problem you will have is ensuring all necessary files are checked in when modifying your umbraco site locally.

For example if you add a media image using the umbraco backend. Visual studio won't automatically add it to the project and therefore source control for you so a check in will miss it. You have to include the files in the project manually which can become tricky when big changes are made.

I'd like to know if anyone else has a better way of managing it.