How to set up visual studio to create CSHTML files in (Umbraco) Project
Asked Answered
H

4

8

So, i'm developing my razor macroscripts in Visual studio for my Umbraco project. Everything is working fine, but there are two things really annoying.

  • If I want to make a new CSHTML file the best solution for this is to duplicate an existing file.
  • I dont have full razor IntelliSense like e.g. Html.Raw

Is there a way to configure my project to use this features? Didn't find a .cshtml template yet.

Heidi answered 8/5, 2012 at 15:33 Comment(0)
G
5

You need to have the MVC Framework installed, then when you open the project as a website, you should be able to create and edit cshtml files with syntax highlighting. See my answer to the following post for more details:

Setting up local development environment for Umbraco

Glyceryl answered 17/5, 2012 at 0:11 Comment(2)
A problem now is the following: Normally, I use a web application project with post build events to upload my files to my server (ftp commands). In a Web Site project this isn't possible i see. Big disadvantage now.Heidi
You could put those same commands into a batch file that you run when you are ready to push updates.Glyceryl
S
3

If your project is a web site/application then the mvc templates aren't available (they only show up in MVC projects). You can just create a text file and name it with the .cshtml extension though (you could set up your own template for this in VS if you wanted to).

To get intellisense in your Razor files, see Doug Robar's blog post on the subject

Soap answered 9/5, 2012 at 10:12 Comment(1)
So the best solution for this I guess is to make your project as an MVC project? The intellisense shown in the video is the umbraco intellisense. I'm more looking for the standard razor intellisense e.g. when you want to type Html.Raw and ask voor intellisense after type Html....Heidi
X
1

As an alternative if you go into the Umbraco admin, go to the 'Developer' section and right click on 'Scripting Files' you can create razor scripts directly (and this will save the new .cshtml directly into your 'macroScripts' folder - although in VS2010 you will need to right click on the new script and choose 'include in project').

Also this will allow you to base your new razor macroscript on one of the pre-built snippets so you may get a bit of core functionality for free.

enter image description here

Xray answered 11/5, 2012 at 10:2 Comment(0)
H
0

From Umbraco 6 on it's very convenient to install Umbraco on your local file system with Visual Studio and NuGet. Given that you have the MVC Framework installed and you use Visual Studio 2012 or above, you get full Razor support in Visual studio. Umbraco Our has a great blogpost about this where they described the steps below in detail (with screenshots!).

  1. Create an Empty Web Application.
  2. Install Umbraco using Manage Nuget Packages ('Umbraco CMS') or the Package manager console (Install-Package UmbracoCms)
  3. NuGet will then download dependencies and will install all of Umbraco's files in your new solution. During this process it will ask if it is allowed to overwrite your web.config file. (Make a back up of your existing web.config if you install Umbraco in an existing project)
  4. Finally, don't forget to run your project hitting F5. You'll see that whenever you try to add or edit a file in your views folder you have razor support and intellisense
Heidi answered 11/1, 2015 at 0:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.