Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2010 doesn't set .CSHTML (Razor View Engine) as Content

I've been trying to deploy my ASP.NET MVC 3 Beta Application to my hosting. It supports all the necessary technologies and through trail and error I set the needed references' Copy Local to True. Then I got the error that my app cannot find the view. It listed .cshtml files it tried. I had those files in my project but they weren't deployed. I found that Visual Studio 2010 doesn't set .cshtml files' property Build Action as Content as it does for the .aspx files.

Is there a way to make Visual Studio automatically set .cshtml as Content, or will I have to set this manually to every Razor View I add?

like image 274
gligoran Avatar asked Oct 11 '10 16:10

gligoran


2 Answers

While waiting for the final release which will have full Visual Studio integration and Intellisense with the Razor view engine you may checkout this blog post and especially the section: Changing The Default Build Action For a File-Type.

like image 124
Darin Dimitrov Avatar answered Sep 29 '22 07:09

Darin Dimitrov


My team has been running into this problem as well. Even though we're all aware of the gotcha, it's too easy to forget to change the build action, and as a result you end-up w/ a runtime error.

I filed a bug on Connect to address this. Please up-vote and comment so this issue gets some traction.

http://connect.microsoft.com/VisualStudio/feedback/details/619539/mvc3-razor-views-and-partial-views-cshtml-are-not-marked-as-content

like image 21
Chris Snyder Avatar answered Sep 29 '22 05:09

Chris Snyder