MVC#

ASP.NET MVC 2 RC 2 & VS 2010 RC

Posted in ASP.NET MVC, Controllers, jQuery, Views by BlueCoder on 17/02/2010

Abstract: Visual Studio 2010 RC comes with MVC 2 RC 1 but if you had VS 2008 with MVC.NET 2 RC 2 installed ,as Phil Haack mentioned in his blog post, when you install VS 2010 RC you have using RC 2 version of MVC.NET automatically but without new item and project templates. In this post I’m going to show how you can manually use the latest version of templates which comes with RC 2 release of MVC.NET. I assumed you had installed VS 2008 with MVC.NET 2 RC 2 and then installed VS 2010 RC now want to update to latest version of templates. You can use this idea to install any other version of MVC.NET which comes in future.

Step 1: We are going to change the files in these locations:

Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\CSharp\Web\MVC 2\
Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplatesCache\CSharp\Web\MVC 2
Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplates\CSharp\Web\1033\
Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplatesCache\CSharp\Web\1033

So before we have chance to ruin all of our VS 2010 templates we are going to back up these files. Although we are not going to change all of files in these locations but I suggest you back up all of them so if something goes wrong you don’t miss anything.

Step 2: As I said I assume you already have VS 2008 and MVC 2 RC 2 installed on your machine. First go to “Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Web\MVC 2\” and copy all the files in MVC 2 folder to the corresponding folder in VS 2010 folder (the first location in the list of step one) you should replace the current files with these new ones and you are not worry because you have already  a fresh back up of these files somewhere in your machine!

Step 3: Do the same work with files in
Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplatesCache\CSharp\Web\MVC 2
Then go to “Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\CSharp\Web\1033\” and just copy these two files to the corresponding folder in VS 2010:
EmptyMvcWebApplicationProjectTemplatev2.0.cs.zip and MvcWebApplicationProjectTemplatev2.0.cs.zip and as the previous steps you are going to replace the current ones with these new files.

Step 4: Do the same job with the same two files in
Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplatesCache\CSharp\Web\1033
So we now done with replacing files but if you now try to add a new project in your VS 2010 RC IDE you get an error says the project template tries to load from wrong assembly. But don’t worry we are one step to develop with the latest version of MVC.NET in VS 2010 RC.

Step 5: If you want to fix this issue you should dirty your hands with some manual fix of corresponding xml files in templates.
Go to “Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\CSharp\Web\MVC 2\” and extract all zip files in the same location and delete zip files then open the unzipped files and find this section in each .vstemplate files in each folder:

“<Assembly>Microsoft.VisualStudio.Web.Mvc.2.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35</Assembly>”

Then change the “Version=9.0.0.0” to “Version=10.0.0.0” then save each file in the same location. The last job is to zip back all the files. At this point you have the same zip files you had at first but with the changed version from 9 to 10. Do the same job with files at
Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplatesCache\CSharp\Web\MVC 2” but this time you don’t need to do zip and unzip part.

Step 6: Repeat the exact job with that two file you copied to
Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplates\CSharp\Web\1033” you need to do the zip and unzip steps and the last step is to changing the assembly section in that two files at “Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplatesCache\CSharp\Web\1033” and this time without zip and unzip part. OK now we done! Open your VS 2010 RC IDE and create the new project you see the newly added project used the MVC 2 RC2 project template the more obvious changes are that the new template has jQuery 1.4.1 in its scripts folder and has the new “Optional Url parameter” in its global.asax.cs file at default route section.For more info about this new feature check out Phil Haack’s blog post.

Summary: We just updated our VS 2010 RC to use MVC.NET 2 RC 2 templates and for that we just had done some copying and pasting job and changed the assembly section in the .vstemplate files that had that section. As I said I assumed you have already VS 2008 with MVC.NET 2 RC2 installed on your machine.

Update: So after all this steps you may need do some other versional ! changes in Project Template so I uploaded the new project template (normal and  cache) so you can just download and compare it the original one to see the changes I zipped the file belong to cache folder so after copy you need to unzip and rename it as the original file. You can download the new template files here :

For copy to Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplates\CSharp\Web\1033 : here

For copy to Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplatesCache\CSharp\Web\1033: here (don’t forget to unzip and rename it as original file)


Shout it

kick it on DotNetKicks.com

About these ads

3 Responses

Subscribe to comments with RSS.

  1. D. Lambert said, on 19/02/2010 at 21:30

    I’m still having trouble trying to get this to work. I followed the steps on Phil’s site, and was still seeing problems, so I tried the steps here next. I’m still seeing the same behavior:

    When I try to create a new MVC 2 project, I see entries for ASP.Net MVC 2 Web Application and ASP.Net MVC 2 Empty Web Application, and when I choose them, they appear to start creating the files (I’m prompted if I want to create a unit test project, for instance), but then I see the following error:

    “The project file ‘\rfhjrrfd.3ui\Temp\MvcApplication1.csproj’ cannot be opened. The project type is not supported by this installation.”

    Obviously the temp folder name is different each time. The most recent time I saw this, I tried navigating to that location to see what, exactly, was being written there, and I was surprised to see that nothing at all was being written there. I haven’t yet gone as far as loading up any sysinternals tools to see if they can see a file error of some sort.

    I’ll post this over on Phil’s site, too, in case he might be interested.

    Thanks for any clues you might be able to throw my way.

    • ali62b said, on 19/02/2010 at 22:15

      I updated my post and uploaded the new template files. So you may download and use them and see the problem will gone or not.
      Hope this helps.

      • D. Lambert said, on 20/02/2010 at 01:41

        Thanks. I ended up doing a repair / reinstall of VS2010 — I hadn’t installed “Web Developer” initially. I fixed that, and ended up uninstalling & re-installing the MVC RC bits. In any event, it seems to be ok now.

        Thanks


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: