Monday, December 29, 2008

VS 2010 for Web Developer Previews


At PDC 2008 in LA and TechEd EMEA 2008 in Barcelona we announced key new features for Visual Studio 2010 for Web Developers...  Apart from our focus on MVC, Dynamic Data, Silverlight and other key ASP.NET runtime functionality, this was the first time we announced the key investments pillars for Web Developers in VS 2010...  Over the next year or so we will be writing in details about these new features, but to start off  I thought it would be great to share various videos which are available to view online today ...

Visual Studio 2010 - Web Development Overview

In this talk we provided the glimpse of the major investment areas in VS 2010.  The talk is divided into following key areas

  • Design View - Improved CSS 2.1 Support &  standards compliance
  • Source View
    • HTML Snippets
    • JScript Intellisense
  • Web Deployment
    • Web.Config Transformation
    • Web 1-Click Publish

Jeff did a great presentation at PDC on this topic which can be viewed at the link below: (77.32 mins)

I also presented a similar talk at TechEd EMEA which is available for viewing below: (62.42 mins)

Visual Studio 2010 - Web Deployment

In this talk we talk about Web Deployment in detail and how next wave of Web Deployment technologies will make deployment a much easier task.  The key focus areas of this talk are:

  • Web Packaging - Packaging your web applications into .zip files
  • Web.Config Transformation - Transforming your web.config file (i.e. connection string, debug flags etc) from dev environment to production environment
  • DB Deployment - Packaging and deploying your SQL Server databases along with your web application
  • Web Publishing - Using Web 1-Click Publish functionality to deploy your web application with ease.

I did a presentation on web deployment at PDC and TechEd EMEA; the PDC presentation can be viewed at the below link:  (84.42 mins)

If you would like to see a more compressed version of the talk then I also did a talk with Jason Olson in Visual Studio 2010 and the .NET Framework 4.0 Week! you can view this video at the below link: (34.40 mins)

Hope you will enjoy these videos...

Friday, December 26, 2008

KritZu: Zune playlist generator based on folder structure


Some time back we got Zune and uploaded our thousands of songs on to it... 

One of the things that we had earlier done was arranging all the songs based on playlists on our computer hard disk in folder structure; things like "Classic Rock", "Heavy Metal", "Jazz", "Ghazals", etc... Many a times we also had multiple level of folder hierarchy set up like My Music --> English --> Rock --> Classic Rock OR Hindi --> Ghazals --> Movie Ghazals and so on...

Anyway's we painfully learnt that Zune's software runs out of meta-data; although it allows me to sort songs based on genres, album, artist etc it does not create playlists based on the directory structure on my computer hard disk...  Well we initially started off doing this manually but soon realized that this will take days for us to complete...  So I wrote this quick utility which will create Zune playlists based on the folder structure on the hard disk...

Following are the easy steps to use it:

  1. Download KritZu from
  2. Unzip KritZu.Exe at the location you want...
  3. Launch KritZu... 


Few points to note:

  • KritZu will pick up .mp3, .wma, .m4v, .mp4, .m4a, .m4b and .mov files inside the playlists...
  • To find out the location where Zune playlists should be placed (i.e. second textbox on KritZu) follow below steps:
    • Open Zune software, on top right you should find settings options:image
    • Go to the Zune Folder section as shown below and note the location of Zune folder image
    • Notice that the Audio location in the above example is C:\Users\user\Music\Zune... In this situation the playlist location for audio will be C:\Users\user\Music\Zune\Playlists
    • If the Playlists folder does not exist then feel free to create it or else KritZu will create it for you...  Now the output of KritZu will automatically be picked up by Zune next time you connect to your machine.

Hope this will help...


PS: Do make sure that you have atleast one media file in the root folder coz KritZu is little silly, it gets confused if no media file is present in the root folder :-)

Saturday, October 04, 2008

Exclude Files and Folders from WDP Output

Web  Deployment Projects (WDP) allows you to pre-compile your web into binaries and further also allows you to merge the assemblies produced in the format that you like.

In my earlier posts I had talked about various WDP features and the latest release of WDP for VS 2008.  You can read more about this at: 

By default in the WDP output you will find project files (.csproj/.vbproj), user files (.user), .PDB, obj folders and other artifacts which are not required for web to run.  It is pretty easy to get rid of these files by following these simple steps:

Step 1 - Open WDP project file for editing

Open WDP project file by right clicking on the WDP project and clicking "Open Project File"


Step 2 - Exclude .pdb, .user, .csproj/.vbproj files from Build

In the ItemGroup section of WDP project which looks like below:


Add the files which you would like to exclude from the SourceWebPhysicalPath like below


ExcludeFromBuild will allow you to remove these files even though they are present as part of the parent project.  After this step your item group should look as below:


In the similar fashion above you can remove other items which you do not need in the output

Step 3 - Removing items after Build

As you know folders like OBJ are produced during build process hence if you do not want them to appear in the output then they need to be removed after build.  to do this we need to add one more item to the above ItemGroup as below


Do note that this time we are using the property $(OutputPath) instead of the property $(SourceWebPhysicalPath)

Now the last step is actually use the itemgroup value as part of the AfterBuild target.  Your WDP project file by default has these commented section as shown below


We need to uncomment the call to Target "AfterBuild" and call "RemoveDir" on the OBJ folder Item we declared in the ItemGroup above... This can be done as shown below:


Finally at the end your WDP project file will look as below:


Step 4 - Save WDP project file, and rebuild WDP

After the above changes to the WDP project file when you rebuild your WDP project you should have your output folder without PDB, Project file, user file or OBJ folder in it.

Hope this helps!!

Friday, August 22, 2008

Web Application Projects - Publish Options

In Web Application Projects (WAPs) we have the following Publish Dialog box.



It has the target location text box which takes destination to be HTTP (which uses Front Page Server Extensions (FPSE) behind the scenes), FTP, or File System.

Publish settings also allows you to have a clean install or just incremental updates.  Although what is interesting to notice are the various Copy options.  Let us try to understand what these mean:

  • Only files needed to run this application - In a WAP we usually have a Project file, User File,  Bin folder, Obj Folder, ASP.NET pages, User Controls, WCF and Web Services etc.  ASP.NET Pages and other similar files have two additional artifacts in a WAP project as shown below:

image When you build the WAP project the sources from both the .aspx.cs as well as .aspx.designer.cs files are taken and compiled into the intermediate output folder (i.e. OBJ folder) and then finally moved to the (BIN folder)...   

You do not really need the Project Files (.csproj/.vbproj); User File (.user)  to run your web neither do you need any of the code behind or designer files as they are compiled into your Bin folder.  At the same time you also do not need the OBJ folder as that is just the intermediate folder VS uses before produces the final output in the BIN folder.  Based on this rationale VS removes all those files from the publishing process and only publishes the files which are required to run your application (which are your .aspx and other similar markup files), your referenced DLLs and your bin folder.

  • All Project Files - Based on the above discussion it is apparent that your code behind and designer files are part of your project, so are your .user and .csproj/.vbproj...  If you select this option then your entire project with these files is published to remote location.  You can usually use this option to move your working project to any remote location and get working on it without having to do a physical copy of select files.  If you want to share your project with your friends over FTP this is a good option to use. Do note Publish feature does not publishes OBJ folder as it is not a folder that a user should really be worried about, it is just for temporary compilation use.
  • All files in the source Project Folder - Many a times users chose to exclude files from their projects by choosing the "Exclude From Project" command


This command essentially removes the artifact from the Project File, although do note that these files are still present in your source project folder.

Apart from this many a times users want to add help files, read me files, references docs (e.g. requirements doc) and other misc items in their project folder while they do not really want to publish these artifacts most of the time.

By choosing "All files in the source Project Folder" you can take all these files (excluding OBJ) folder and transfer it to any remote location via HTTP, FTP or simple disk IO to a UNC location.

The above three options kind of provides all the dials for a user to choose the appropriate publish option applicable to them.

  • Include files from the App_Data folder - App Data folder might potentially contain huge files and sensitive data, hence it is given a special status and you can choose whether or not you would like to publish your App_Data folder or not.  It is selected by default as VS assumes that you need the Data to run your application but if you really do not have anything in the App_Data folder or if you are hoping to use SQL Server in production (as opposed to MDF files & SQL Express during development) then you should go and uncheck this box.

Hope this summary of "Publish" feature for Web Application Projects helps...

Wednesday, August 06, 2008

Can't Go to Beijing? - Enjoy some cool Olympic Games with MS Popfly



Spin, jump and twirl through the air without ever leaving your chair!

To Play:




Dive through the water and hit the target – harder than it looks!

To Play:




Mirror your teammates movements with this synchronized swimming game!

To Play:



Try to light all 14 torches by clicking on them!  Watch out, they’re fast!

To Play:





Pick countries to go head-to-head in this game of Foosball Soccer!

To Play:



Ready… Set… Go!  It’s the 100-meter dash, pick your country and hurdle across the Finish Line to Victory!

To Play:



Pick your targets carefully, aim, and fire your arrows in this addicting game of Archery!

To Play:



Help Rocket Chicken score his longest Long Jump and win a Gold Medal!

To Play:



Test your ‘Strength’ by keeping the barbell off the floor and trying not to turn red in the face!

To Play:



Forget Tyson vs. Holyfield, this is the real Boxing match of the century: my Xbox versus your Playstation.  It’s Battle of the Game Consoles!

To Play:

Hope this will be fun!!


Saturday, August 02, 2008

Web Deployment with VS 2008

On July 21st 2006, during ASP.NET Insider summit I had a chance to do a podcast with Wally McClure...  We discussed a bunch of items around Web Deployment with .NET 3.5 and VS 2008...  Some of the topics covered in the podcast are:

  • General Web Deployment Scenarios
  • Web Application Projects vs. Websites
  • Pre-compiling Web Projects (aspnet_compiler.exe)
  • Merging Web Projects (aspnet_merge.exe)
  • Web Setup Projects (MSI files)
  • Web Deployment Projects (WDP)
  • Microsoft Deployment Tool (MSDeploy.exe) 
  • Sql Publising Wizard

    You can view the podcast at:

    Friday, July 11, 2008

    MSDeploy - Beta 1/Go Live Released


    We recently released Beta1/Go Live version of "Microsoft Web Deployment Tool (aka MSDeploy.exe) ".  MSDeploy is a very useful tool for creating web packages which can be used to move your web application from developer boxes to servers.  It can be used to replicate servers in web farm environments too.

    Download Location:  You can download MSDeploy.exe from the below location:

    Earlier I had written about the Technical Preview release of MSDeploy here.  Apart from the features I had mentioned in the above post following are other key features worth noting are:

    MSDeploy Remote Agent: MSDeploy comes with a remote agent service.  This service can be optionally installed with MSDeploy and usually is intended to be installed on the server side.  MSDeploy on your Dev/Test box can talk directly to the remote agent on the server and help move your IIS6/IIS7 web to equal or higher version of the webs on the server.

    Below is an example of how you can move an IIS 6 site from one machine to another.

      MSDeploy.exe -verb:sync -source:metakey=lm/w3svc/1,computerName=VJWin2k3 -dest:metakey=lm/w3svc/2

    Web Archive/Package:  MSDeploy can actually take a snapshot of your app from the local machine and move it to what we call as Archive Directory.  This will allow you to eventually take the Archive Directory on a different machine and use MSDeploy command line with elevated privileges to install your web on the server.  This can potentially solve a very common problem of developers not having admin rights on the server.   Developers in this scenario can run MSDeploy on your local IIS and create archive dir for their web.  This can be done from command line in the following way:


    (command: msdeploy -verb:sync -source:appHostConfig="Default Web Site" -dest:archiveDir="V:\Vishal\Archive")

    This Archive dir can then be shared with the server Admins who can examine the content of the archive dir by executing the following command:

    msdeploy -verb:dump -source:archiveDir="V:\Vishal\Archive"


    Now the admins can actually install the website from this archive package on to the production server.  This can be done by executing a command like below:

    msdeploy -verb:sync -source:archiveDir="V:\Vishal\Archive" -dest:appHostConfig="Production Web Site"


    On executing this command the "Production Web Site" will get installed (as shown below) and will be stopped by default.  Admin can then turn it ON as appropriate.


    I thought that apart from talking about the above feature referencing the New Features of this release from the "Read Me" file would be useful, so here are the extracts from the Read Me file...

    "What's New in this Release

    • PowerShell Support. PowerShell cmdlets are included, allowing you to use the Microsoft Web Deployment Tool conveniently with PowerShell. For more information about how the PowerShell cmdlets work, see the Help file as well as the Microsoft Web Deployment Tool Walkthroughs.

    • Enhanced Dependency Support. The dependencies that are checked for a web site or server can now be viewed on IIS 7.0 as well as IIS 6.0. They can be turned off on a granular level, such as disabling the drive space dependency check while still running the other dependency checks, or disabling the check for a single ISAPI script map. Additionally, when you view dependencies, you will be able to see the “trigger” for the dependency (what location(s) in configuration caused the Microsoft Web Deployment Tool to say that the module/component is a potential dependency).

    • Help file included in Setup. You can now see the full list of verbs, parameters and other detailed information about the Microsoft Web Deployment Tool in our .chm Help file, which will be included when you install the tool."

    In the future posts on this topic I will write more about various other features of MSDeploy and how they can serve some of your web deployment needs.

    Hope this was useful!!

    Thursday, June 26, 2008

    Seattle/Redmond/Bellevue Nerd Dinner - July 22nd, 2008


    Event details

    Seattle/Redmond/Bellevue Nerd Dinner - July 22nd, 2008

    Date and time:
    Tuesday, July 22, 2008
    6:30 PM - 9:00 PM

    Hosted by:

    Are you in the King County? Are you a huge nerd? Perhaps a geek? No? Maybe a spaz, dork, dweeb or wonk. Maybe you're in town for an SDR (Software Design Review) or the ASPInsiders meeting. Quite possibly you're just a normal person.

    Regardless, why not join us for some Mall Food at the Crossroads Bellevue Mall Food Court on July 22nd around 6:30pm?

    If you want to come and share something with the group, please do! We're language and technology agnostic and always eager to learn about new stuff.

    Crossroads Bellevue Food Court (
    15600 NE 8th St, Bellevue, WA 98008-3927, United States

    Get driving directions

    Add to your calendar

    Friday, May 30, 2008

    TechEd 2008, Orlando, FL & Web Development Features


    Simon and myself are doing a talk at TechEd 2008... The primary agenda of the talk is going to be as below:

    • Visual Studio 2008 & .NET FX 3.5
      •    Web Application Project, Website & Multi-targeting
      •     The design Surface & CSS
      •     ListView server control and ASP.NET AJAX
      •     JavaScript Intellisense enhancements
    • Visual Studio 2008 SP1 & .NET FX 3.5 SP1 (Beta)
      •     JavaScript Formatting  & 3rd Party Frameworks
      •     ASP.NET Dynamic Data
      •     ASP.NET AJAX enhancements
    • Out of Band Previews (OOBs)
      •     ASP.NET MVC Preview 3 (Model View Controller)
      •     Visual Studio Web Deployment Projects

    The session details are:

    Session code: WUX306: A Lap Around the Newest Features in ASP.NET and Microsoft Visual Studio 2008 for Web Developers

    Session Day/Time: 6/3/2008 10:30AM-11:45AM


    If you are coming to TechEd then we will look forward to seeing you there...

    Thursday, May 22, 2008

    ReSharper v 4.0 beta for VS2008 is out

    I just now receieved an email from Jet Brains team informing that ReSharper v 4.0 beta for VS 2008 is out... Below is the verbatim email in case anyone of you was interested...

    "I just wanted to let you know that ReSharper 4.0 beta for Visual Studio 2008 is now available for a test drive at:

    In addition to enhanced productivity features, ReSharper 4.0 beta offers several new features for C# 3.0 including:

    - New code analysis, context actions and quick-fixes;
    - New refactorings (such as Convert to Extension Method, Convert to Automatic Property, Convert Anonymous Type to Named);
    - Updated IntelliSense.

    Final release of ReSharper 4.0 is coming soon! If you would like to learn more about upgrade availability, please contact me directly."

    Some of you had reported some bugs in VS that ReSharper was causing some failures for you... Please go ahead and try this version, I am guessing those issues must be resolved here...

    Monday, May 12, 2008

    Visual Studio 2008 SP1 Beta Released


    Just today we released Visual Studio 2008 SP1 beta...  VS 2008 SP1 beta is truly a feature packed release for Web Developers...  From enhancements in WCF space to including WAP (Silverlight and MVC with download) in VWD Express there are tons of things you can do with VS 2008 SP1...

    John Dundon has written a very detailed post about the release on our team blog below:

    Also ScottGu has put forward a much more broader blog post about SP1 beta on his blog below... Do take time and read through the these two posts... 

    If you have question, queries or feedback do not hesitate to write to me at

    Dynamic Data's new Code Gallery SP1 Version Released


    Our team just released new version of ASP.NET Dynamic Data in Code Gallery.  This version of Dynamic Data release works on VS 2008 SP1 and also contains the new Blinq wizard for Dynamic Data.  You can read more about it at:

    Code Gallery is a new model that our team is using to share early previews of our work in Dynamic Data.  This allows our team to share the latest developments with the community as soon as they meet the minimum quality bar.  Usually we would release something only after it goes through rigorous quality bar but this model allows community to view and provide feedback while we are still completing our work on the feature...  Hope you will enjoy looking at this more transparent model of technology releases from Microsoft...

    Tuesday, May 06, 2008

    Computer World survey ranks MS Web Development higher than Google, Yahoo & Facebook

    Web 2.0 developers rank MSN/Live higher than Google, Yahoo and Facebook

    The top 7 web-based developer programs ranked:

    1. Microsoft
    2. Google
    3. Yahoo
    4. eBay
    5. Amazon
    6. Facebook
    7. PayPal

    Monday, March 24, 2008

    New French Coding4Fun site released


    New and exciting fun place to learn coding for French speaking friends...  Click here to go to Coding4Fun...

    Tuesday, March 11, 2008

    Upgrading Projects from ASP.NET MVC Preview 1 to Preview 2 (MIX 2008)


    If you previously had ASP.NET MVC Preview 1 (CTP 1) and had already created a few projects on it then you might have to take this additional step to convert your project to ASP.NET MVC Preview 2 (MIX 2008) [After installing MVC Preview 2 (Resources here)].

    In ASP.NET MVC Preview 2 we introduced a special MVC Project flavor GUID for MVC Projects.  Some of the special MVC project behaviors described in my previous post "Tooling Features Overview"  may not function as expected e.g. new 'MVC' node under the 'Web' node for 'Add new Items Dialog Box' may not show...



    To make the project features to function as expected in Preview 2, open the MVC project file (.csproj/.vbproj) of the project you created using MVC Preview 1.  Look for 'ProjectTypeGuids'... You will find the below piece of code...


    Replace the above with:


    When you reload/reopen your project your MVC Preview 2 functionality will be available in the projects you created MVC Preview 1.  Do note this in addition to other steps mentioned in the Readme Document for ASP.NET MVC Preview 2 which goes into greater details of upgrade scenario.

    Google's 9 Principles of Innovation


    This is worth a read:

    Friday, March 07, 2008

    ASP.NET MVC Framework Preview 2 (Mix 2008) Resources

    I am attempting to compile the relevant resources for ASP.NET MVC Framework Preview 2 at one place so that you will not have to keep searching around...

    ASP.NET MVC Preview 2 Download Location:
    Preview 2 Download (English-US) - download location to get the latest MVC bits...

    ASP.NET MVC Documentation:
    Home Page - Asp.Net home page where you can find latest updates on ASP.NET MVC Framework in general...
    User Documentation - The official Microsoft user documentation on ASP.NET MVC Framework...
    Readme File - Contains a ton of information on how to install the preview 2 and how can it play well if you already have MVC Framework Preview 1, Silverlight etc...

    ASP.NET MVC Learning
    Forums - There is a ton of activity on ASP.NET MVC Framework forums, this is a great way of getting your questions answered...
    Videos - There are some great quick start videos on ASP.NET MVC Framework available here, we will be adding more videos here going forward to do keep checking

    ASP.NET MVC Blogs
    Scottgu's Tutorials Root - Scottgu has a bunch of very walk-through on ASP.NET MVC Framework here...
    ASP.NET Tooling Overview - In this post I have explained the tooling features for ASP.NET MVC Framework...
    MVC Unit Test Framework Integration - In this post I have explained how you can integrate a new test framework like NUnit, MBUnit, xUnit etc into your MVC Application.
    NUnit & Rhino Mocks Integration - In this post Joe has taken a NUnit and Rhino Mocks framework as an example and he has created a Test Project Template for you to download... I will highly encourage you to check this out...
    Phil Haack's Blog - Phil keeps writing interesting posts about ASP.NET MVC Framework... It would be nice to routinely check his blog too...
    My Blog - I also intend to keep posting ASP.NET MVC Framework articles on my blog regularly so you might want to check that out too...
    Scott Hanselman's Blog - Scott has some ASP.NET MVC Zen stuff on his blog too, do find time to check that out...

    ASP.NET MVC CodePlex Source Code - CodePlex Home Page for ASP.NET
    MVC Preview 2 Source Code - CodePlex location to download MVC Preview 2 Source Code

    Hope this helps...

    Monday, March 03, 2008

    On Demand Webcast : Visual Studio 2008 for Web Developers

    VS 2008 brings a great deal of features for Web Developers...  As a part of VS 2008 launch I did a web cast on MSDN on Feb 26th 2008.  Below are few of the features that I did demos on, hope you will enjoy it:

    1. Multi-Targeting
    2. Split View & Nested Master pages
    3. CSS Features (Manage Styles, Apply Styles, CSS Properties & Summary)
    4. ASP.NET List View Control and Ajax
    5. Javascript Intellisense and Type inferencing
    6. Javascript Referencing & Commenting
    7. Calling Services (.asmx & .svc )from Javascript
    8. Javascript Debugging
    9. Web Deployment Projects (WDP) for VS 2008


    Sunday, February 24, 2008

    Webcast: New Enhancements for Web Developers in VS 2008


    Wanted to update you on a upcoming web cast that I am doing in support of Visual Studio 2008 launch event...

    Title: New Enhancements for Web Developers in VS 2008

    Date/Day: Tuesday, February 26th 2008

    Time: 11am to 12:30pm Pacific Standard Time (PST)

    Description :Get an overview of how Visual Studio 2008 takes web development to the next level. See highlights of the key new Web tools experiences in the Visual Studio 2008 product including support for multi-Targeting,  JavaScript enhancements, rich support for CSS standards, rapid development of data-bound web pages using LINQ To SQL, and more. Also learn about the new Web Application Project and Web Deployment Project enhancements to Visual Studio which adds an alternative Web application development, build and deployment models to the Visual Studio project system.  Also have a sneak preview of the work being done for Web Developers in out of band releases like ASP.NET MVC Framework.

    Registration URL:

    Hoping you will be able to join!!

    Tuesday, February 19, 2008

    Free Microsoft Software for Students

    Microsoft announced an unparallel program called "Microsoft Dreamspark which will offer free Microsoft Visual Studio 2008, Microsoft Expression Studio and Windows Server 2008 free to students...

    You can read more about this announcement at


    Monday, February 18, 2008

    ASP.NET MVC Test Framework Integration

    Previously I gave an overview  of new tooling features for ASP.NET MVC Framework that we are hoping to make available during MIX 2008 timeframe.  You can read more about Overview of MVC Tooling Features for MIX 2008 here

    Goals: ASP.NET MVC Framework is Microsoft's implementation of MVC framework which is hugely popular in the industry for best practices and conventions.  In lines with best practices one of the goals of this new ASP.NET framework is to enable easy unit testable web applications.  To ease unit testing and to make it part of our regular application development workflow Visual Studio is introducing integration of unit test projects with ASP.NET MVC Application.  Many in the community are already familiar with and are using test frameworks liked Visual Studio Unit Test, NUnit, MBUnit etc.  If you have Visual Studio Unit Test framework on your machine (i.e. in Visual Studio 2008 SKUs Professional and Above) then on creation of ASP.NET MVC Web Application you will automatically be prompted to create a test project.   Not only that, due to the popular community request Visual Studio will now also provide a mechanism to extend this test framework system to integrate external unit testing frameworks like NUnit, MBUnit, xUnit etc.

    Today I will be walking you through this new Test Framework integration for MVC Projects. Our goal today is:

    • To understand how to create test project templates
    • To understand how registration works for test project framework and how to register a custom test project template

    At the end we want to get to a point where your test framework of choice shows up in the drop down when you try to create a MVC Application (like 'NUnit' does in the figure below):

    (Fig 1: Create Test Project Dialog Box)

    Applies To:  This article applies to Visual Studio 2008 with ASP.NET MVC Framework Mix 2008 CTP installed.  This documentation is pre-release documentation intended to provide insights to the community on the work being done by MS on ASP.NET MVC Framework, we are still in development phase so please do note that this is subject to change, but we believe this is very close to what you can see during MIX timeframe.

    Video:  I have also created a screen cast (approx 30 mins in length) which covers the concepts of this post in detail, we will be making it available here soon...

    Step 1: Creating Test Project Templates : There is a very succinct article on MSDN on how to create Project Templates.    You can find this article at  Although the process may vary depending on the type of unit test framework and mock objects you choose, I am summarizing the process in context of MVC Test Project Template which I created using NUnit framework and Rhino Mocks library.

    • Create a new class library project with the Code Language of your choice, give it a good reusable name which will apply to your test project template.
    • Add reference to "System.Web.MVC", "System.Web.Abstractions" and "System.Web.Routing" dlls in your class library project.  These DLLs will ship along with ASP.NET MVC Framework in the MIX 2008 CTP.
    • Download required Test frameworks (NUnit, MBUnit etc)
    • Download required Mock object libraries (Rhino mocks, Type mocks etc)
    • In the class library project add the right references to to the test framework and mock objects which you want to use.
    • Make sure that you make all of the above references dll's  "Copy Local" property to "True" (Select the referenced DLL and hit F4 to access the property in the Property Grid)
    • Add required folders and classes to test an MVC Application.  You can pre-populate whatever tests you like, but at the minimum if you would recommend matching the default MVC Application template that ASP.NET MVC Framework will ship with.  In order to match the default application template use the following structure:
      1. Create a "Controller" folder under the project root and add "HomeControllerTests" class to it.  Add unit tests to cover "About" and "Index" actions
      2. Create a "Routes" folder under the project root and add "RouteTests" class to it.  Add unit tests to cover the two default routes that will come with ASP.NET MVC Framework.
    • Build your project so that the required binaries are present in the bin (note: my screen cast has this step missing and hence I get some unresolved references when I instantiate the template)
    • Go to File-->Export Template wizard and follow its easy directions.  The project template is usually created in the user's VS directory (the wizard will point you to the location).
    • Remove the from the user specific directory and move it to %Program Files%\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\Language\Test\Locale
    • Close all the instances of Visual Studio and open the command prompt (Start --> Run type cmd)
    • Navigate to the IDE folder on the command prompt (cd %Program Files%\Microsoft Visual Studio 9.0\Common7\IDE) and type devenv /setup, hit enter
    • This will take some time but should setup your newly created project template within Visual Studio .  If you now open VS 08, then in New Project dialog box you should be able to see your template show up under C#/VB-->Test directory.

    Step 2: Understanding Test Project Registration: We are introducing a very easy registry based registration model for your test project templates.  Please refer the registry structure below:


    (Fig 2: Test Framework Registry Info)

    We have a new MVC key under Visual Studio 9.0 registry location as highlighted above.  As you can see above I have NUnit and VisualStudio as my available test frameworks.  This is what is showing up in the  screen shot of "Create Test Project" dialog box in Fig 1 above.  If you would like to add more test frameworks please go ahead and create one more key under 'TestProjectTemplates' key.

    On the right side you see various string values, let me go ahead and explain what each one of these mean:

    • AdditionalInfo:  You can enter a URL for more information on the Test Framework here.  It is hopefully going to be used by 3rd parties who will be creating Test Project Templates.  This link shows in the Fig 1 as "AdditionalInfo" link
    • Package:  This is a pointer to the VS package that you may want to use in case you are adding UI elements or doing advanced functionality with your Test Project.  Visual Studio will be using this information to pull out localized resources when we localize MVC Test Project Template for Visual Studio
    • Path:  The Test Framework selection of VS expects that your test templates are registered with Visual Studio and are located some place under standard VS Project Templates location (i.e. %Program Files%\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\. The Path value mentioned here is actually the location under this standard VS Project Templates path. 
    • Template:  This is the actual zip file name which was created in the Step1 above.
    • TestFrameworkName: This is the name that will show up in the drop down of Fig1: above.  In order to localize the URL of AdditionalInfo or name of TestFrameworkName we will provide a special syntax like "#1209:NUnit".  This will indicate to Visual Studio to use resource # 1209 from the Package above for the localized string but if nothing is available then use the default "NUnit".

    Also one point to note over here is that VS Test Framework selection system will create a test project for the same language as your primary MVC Application Project. The same registry strings that we just discussed above can be replicated at the top node (e.g. 'VisualStudio') that I have highlighted in the Fig 2 above.  I would recommend having that replicated as it allows Visual Studio to fall back on this template in case your primary MVC Application is of languages  like 'IronPython' etc.  In nutshell that is the default template for that particular test framework within VS.

    Summary: On completing the steps above, when you go to File--> New Project --> Language --> Web and try to create a new "ASP.NET MVC Web Application" project then the dialog box presented in Fig1: will show up with your newly registered Test Framework in the drop down. 

    Hope this will get you unit testing your projects more and more...!!

    Vishal R. Joshi | Program Manager | Visual Studio Web Developer

    Sunday, February 17, 2008

    Tooling Features Overview of ASP.NET MVC Framework for MIX 2008

    There has been a tremendous positive response on ASP.NET MVC Framework from the community since we released the December 2007 CTP of ASP.NET Extensions.  With MIX 2008 coming closer our teams have been super busy in trying to bring out value additions to ASP.NET MVC Framework.  ScottGu, in his ASP.NET MVC Road-map post, recently introduced the new MVC features coming up with MIX preview.  He had mentioned that with this MIX release ASP.NET MVC will get much better Visual Studio 2008 integration and support.  My post today is to outline these integration points and support within Visual Studio.

    Features:  During December 2007 preview of MVC we just had project templates to support MVC development within Visual Studio, since then there have been some improvements which are as below:

    Project Template Filtering and Naming: MVC Project templates will now be filtered based on .NET Framework version and will be available only when you select Framework version 3.5.  You can now also name your projects and solutions as per your choice which was not possible in the Dec 2007 CTP.

    Test Framework Options: In Dec 2007 CTP we had 'MVC Application' project template and also had 'MVC Application and Test' project template.  We now do not expose the 'MVC Application and Test' project template instead we have a cool new Test Framework options dialog which shows up as soon as you click okay on you MVC Application creation.  This test framework dialog assumes that you want to create your test project in the same language as your primary MVC Application and so it does not show you that option.  TheTest Framework dialog box will look like below:


    When you select your Test framework and click okay Visual Studio will create a multi-Project template with the Test Project already having reference to your primary MVC Application.  In my follow up post on this topic will learn about the way 'Test Framework Options' dialog box works behind the scenes and understand the way by which we can extend it to use external 3rd party testing frameworks.

    'Add New Items' Dialog Box:   The new 'Add New Item' dialog box for MVC Applications will show a "MVC" node under the "Web" node as shown below.  This will allow you to locate your MVC item templates pretty easily:


    ASP.NET MVC framework (without any extensibility customizations) requires you to suffix your controller names with "Controller".  Visual Studio will now help you achieve this mundane task by reminding you about it and 'by default' naming it correctly in your project.

    Making Routes more Testable:    We have also gone ahead and changed global.asax to make your routes much more testable by default.  The new global.asax will look something similar to below:


    You can very easily now call RegisterRoutes externally to test your routes.

    Getting Designer.cs/.vb Files Back:  In December 2007 CTP our view pages did not have the .designer.vb and .designer.cs files attached to them, many of you asked us to get that in so that server control useage would become easier.  In the MIX 2008 CTP every View Page, Master Page and Content Page associated with MVC development will come with a pre-created designer.cs/vb file.


    Debugging Settings:   We have now made some default debugging settings so that your MVC application will debug no matter where you hit F5 in your solution explorer.  You will definitely have option to modify this behavior in the property pages of your MVC Application.

    Removing 'View in Browser' & 'Add a Content Page' Commands:  If you right click on .aspx pages within an MVC Application you will not see 'View in Browser' command.  This command has been intentionally disabled as in case of MVC application we want that the calls made are not handled directly to .aspx pages but rather get routed via a controller, which in turn will produce ViewData and redirect to the right View Page.  "Add a content Page' command was also removed from Master Pages in MVC application as creation of View Pages is expected to be location specific depending on the controller and 'Add a Content Page' was not directly applicable in such scenarios.

    New Look And Feel:  MVC Application right off the shelf will now also have a much more CSS friendly  and pretty UI which you can start customizing and converting into your real world application.  I am attaching a screenshot of how ASP.NET MVC Application will possibly look like as soon as you hit F5 on this new template.


    Hope these features help you with using ASP.NET MVC Framework.  In follow up posts on the ASP.NET MVC topic, I will write back about customization of Test Framework dialog box.  In the meantime hope this gets you up to speed with our efforts around ASP.NET MVC Framework.