Earlier this week I realized that I had let the development environment on my laptop get a bit out of date. Sure, it was running Visual Studio 2010, but I had not applied Service Pack 1, nor any of the big buzzy out-of-band add-ons from the first half of 2011.
So, I sat down to install Visual Studio 2010 Service Pack 1, ASP.NET MVC3, Entity Framework 4.1, and the Nuget package manager. I learned a few things along the way. Following is a recap of the upgrade process, along with some notes about what I know now that I didn’t know before.
Step 1) Install Visual Studio 2010 Service Pack 1. This installation was a painless hands-off procedure, although it did take 2-3 hours to complete. My dev tools are set up in virtual machines (one for Visual Studio 2010 and related tools, one for WAMP platform tools), so running the upgrade against the virtual machine probably slowed things down. Regardless, it was a lengthy install.
Step 2) Go to nuget.org and install the NuGet Visual Studio extension. Again, this was painless; I downloaded the installation package, chose Run, and that was it. NuGet is a package manager for easily installation and updating of open source libraries and tools in Visual Studio. Package managers are already popular in other environments, but are a relatively new addition to the Microsoft development stack.
Step 3) Start Visual Studio. So far, so good.
Here is where things started to go awry. My own fault, as you will see. I followed the instructions found at http://docs.nuget.org/docs/start-here/Using-the-Package-Manager-Console to attempt to install the latest versions of ASP.NET MVC and Entity Framework. I could have just done this via the usual download-and-install process, but I wanted to give NuGet a spin.
Step 4) From the Tools menu, use NuGet by selecting Library Package Manager and then clicking Package Manager Console. This opens a PowerShell dialog within Visual Studio.
Step 5) Type "get-help NuGet" to view all of the available NuGet commands.
Step 6) Type "Get-Package -ListAvailable" to view a list of all available NuGet packages. Locate the “Entity Framework” package in the list.
Step 7) Type "Install-Package Entity Framework". Oops… FAIL. I received the following error:
Install-Package : The current environment doesn’t have a solution open.
At line:1 char:16
+ Install-Package <<<< EntityFramework
+ CategoryInfo : InvalidOperation: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetNoActiveSolution,NuGet.PowerShell.Commands.InstallPackageCommand
What I’d uncovered was a fundamental misunderstanding on my part about what NuGet does. My desire was to add capabilities to Visual Studio itself, not just to a single project or solution. Turns out that’s not what NuGet is for.
Step 8 ) Type "get-help Install-Package" to get more information about what I had just attempted. Included in the description of the “Install-Package” command is the statement "Installs a package and its dependencies into the project." Ok then, that confirms it… NuGet is for individual projects, not for the development environment as a whole.
My initial misunderstanding of NuGet stems from my only previous Package Manager experience, which was with the “apt” system that is a part of Ubuntu Linux.. Using that Package Manager, I was able to add capabilities and tools to the operating system… things like MySQL and Apache. This, in fact, is somewhat similar to the Web Platform Installer from Microsoft. But not NuGet. NuGet is actually more like RubyGems, which are used to adding capabilities to software projects written in Ruby.
So, I learned some useful information, but as far as installing ASP.NET MVC and Entity Framework, it was back to the drawing board
Step 9) Shut down Visual Studio.
Step 10) Install ASP.NET MVC 3. Speaking of the Web Platform Installer, I hadn’t used it a while, so I decided to go that route to install ASP.NET MVC 3. I browsed to http://www.microsoft.com/web/gallery/install.aspx?appid=MVC3, and clicked Install Now. The Web Platform Installer itself installed first, followed by ASP.NET MVC 3. This took much longer than expected to install. Overall, though, Web Platform Installer was as painless to use as I remembered. Nice.
Step 11) Install IIS Express 7.5. Though not part of the original plan, I decided to also install IIS Express 7.5. I did this using a "normal" download-and-install procedure. Easy. As advertised, very lightweight.
Step 12) Install Entity Framework 4.1. I did this via the download-and-install process (choosing to "save" and then run the downloadable installer… Web Platform Installer was not used). This installation was very quick when compared to MVC3. I’m not sure if that was due to the NON-use of Web Platform Installer to install EF, or if EF is simply a much more lightweight install than MVC.
While looking for the correct Entity Framework 4 installer package I noticed the following statement on the ADO.NET blog: "Note: The NuGet package only includes the EF 4.1 runtime and does not include the Visual Studio item templates for using DbContext with Model First and Database First development." So, that provides further clarification that NuGet adds the necessary run-time libraries to specific projects, but does NOT add full development tools to VS.
Step 13) Start Visual Studio and verify all installs. To confirm that everything was as it should be, I checked the following:
Step 13a) File/New/Project shows ASP.NET MVC3 Web Application as a project type.
Step 13b) EntityFramework 126.96.36.199 shows up as an option when adding a reference to a project.
Step 13c) There is a new option for Add Library Package Reference when adding a reference to a project.
Step 13d) On the property page for a a web project, there is a new option for running under IIS Express.
That’s it. My Visual Studio 2010 development environment is now up-to-date. Along the way, I gained greater insight into NuGet, the hot new Package Manager add-on for Visual Studio In particular, I learned that if you’re looking to upgrade your entire development environment, and want to use a package-manager type application, Web Platform Installer is your choice. On the other hand, if you want to add libraries to a project on which you are working, Nuget is the tool to use.