# Tuesday, 11 November 2008

At Vertica we employ a wide range of Microsoft server products in our solutions to maximize customer value. To help us manage these often complex environments we rely heavily on virtualization. For the longest time the obvious choice was Microsoft Virtual PC simply because it was there and freely available to use and just being able to run a virtual machine was amazing in its own right.

Our default setup when developing in the virtual environment is to install everything needed inside the virtual machine and use that exclusively. Running IIS, a couple of server products with Visual Studio and ReSharper works well but we’ve found that performance leaves something to be desired.

The obvious answer is to move Visual Studio out of the virtual environment, do development on the physical machine, and deploy the code to the virtual environment and test it there. Basically I require two things from this: 1) Pushing the build to the server should be very simple, 2) Debugging must be supported.

Pushing Code

We’ve got a bunch of options for pushing code to another environment: Publish Wizard in Visual Studio, msbuild or nant tasks, Powershell, and my personal favorite bat files :)

I wanted to create a generic solution which doesn’t dictate the use of msbuild or any other technology so I went with a bat file which in turns calls robocopy. With this in place we’re able to push files over the network to the target VM. Of course a one-time configuration of the virtual environment is needed but that isn’t in scope for this thing.

Download my deploy bat file. Basic usage Deploy c:\MyWebSite \\MyServer\MyWebSiteVDir.

Robocopy is part of the Windows Server 2003 Resource Kit.

Remote Debugging

Second requirement is debugging. I want a solution which is on par with running Visual Studio inside the virtual environment and that means debugging people! :)

The steps for doing remote debugging are well documented but for completeness sake I will include them here with nice screenshots to go along.

1) Copy Remote Debugger from \program files\Microsoft Visual Studio 9.0\Common7\IDE\Remote Debugger to somewhere on the virtual machine, e.g. desktop.

2) Run Remote Debugger on virtual machine (msvsmon.exe).

3) Grab the qualifier from the Remote Debugger (You’ll need it in a second).

Remote-Debugger-Qualifier

4) Connect to Remote Debugger from VS on physical machine via Debug > Attach to Process (CTRL + ALT +P)

5) In the Qualifier input field enter the qualifier from Remote Debugger window.

Visual-Studio-Attach-To-Process 

Volia. Set a break point on the remote machine and see the code break in Visual Studio.

VMWare

I stated earlier that we’re using Microsoft Virtual PC which is true but it’s also true that we’re looking into VMWare Workstation. My first reason for doing so is the performance boost which comes from running in VMWare. I haven’t done any sort of scientific testing of how much faster we’re talking about suffice it to say that it’s enough that you notice it when you’re going about your business in the virtual environment. VS is faster, compiles are faster, everything is just smoother. In my book the best sort of performance metric there is :)

Additionally VMWare provides other interesting features. The first one you’ll see is that storing and restoring state of a VM is blazingly fast. Enough so that you’ll actually find yourself using the feature all the time. I know I am.

Secondly VMWare supports multiple monitors. That’s right. Simply select how many monitors you want supported and it’ll do it. You can even switch on the fly. In case you’re wondering, yes, we do have three monitors setup for all the developer machine in the office :)

VMWare-Workstation-Multiple-Monitor-Support

The final feature is significant enough for our story to warrant a paragraph of its own. I accidentally stumbled across it this morning when I upgraded VMWare to version 6.5.

Remote Debugging Support in VMWare

You read my earlier steps to get remote debugging working which will work for any sort of virtual environment. VMWare however brings some nice debugging features to the table available right there in Visual Studio.

1) Goto the menu VMWare and select Attach to Process.

VMWare-Workstation-Debug-in-Virtual-Machine

2) Select the VM you want to start debugging on and point to the Remote Debugger that you’ve got locally in \program files\Microsoft Visual Studio 9.0\Common7\IDE\Remote Debugger\x86.

VMWare-WorkStation-Attach-to-Process-in-Virtual-Machine

3) Click the Attach button and the Remote Debugger will launch inside the VM and you’re ready to debug.

No need to copy anything to the VM. It just works. You can even setup a config for this which enables you to attach to the debugger with F6. Nice!

In conclusion running Visual Studio outside of the VM is not only possible but with the right tools like VMWare in hand it’s even an enjoyable experience. Have fun!

posted on Tuesday, 11 November 2008 10:35:21 (Romance Standard Time, UTC+01:00)  #    Comments [0] Trackback
# Saturday, 13 September 2008

ReSharper-Logo I was fortunate enough to attend a special event at Trifork at which the manager, Oleg Stepanov, of the Jetbrains team creating ReSharper gave a talk on ReSharper functionality. He basically demoed a bunch of R# features most of which are pretty well known to the Vertica team and myself but a couple of nuggets did present themselves and I figured if we don't know about them probably others don't as well.

Please note that all keyboard shortcuts mentioned in this post are based on the standard R# Visual Studio keyboard layout.

Smart Code Completion

On the light side I'll start with a feature I knew was in there but I never quite got why it was useful. The feature in question is smart code complete or as I like to thing about it Smart Intellisense. You find the feature in the ReSharper menu under Code > Complete Code > Smart (CTRL + ALT + SPACE). Smart Code Completion is basically smart intellisense, you could say that it puts the "intelli" in the intellisense :)

What it does is that when you activate the feature it suggests methods and properties based on the types in the local scope. So if you're in the process of assigning an int variable from somewhere it will only suggest methods based on matching return types, not just name as is the case with standard Visual Studio intellisense. Check out the screenshots below, the one to the right is standard Visual Studio intellisense (CTRL + SPACE), the left one is R# Smart Code Completion where the list is greatly reduced.

ReSharper-4x-Smart-Code-Completion-Normal-Intellisense  ReSharper-4x-Smart-Code-Completion 

Complete Statement

Probably the most useful feature that I picked up at the meeting is Complete Statement. Complete Statement is available from the R# menu under Code > Complete Code > Complate Statement (CTRL + SHIFT + ENTER).

It bascially tries to complete the current statement that you writing so if for example you're writing a method signature you and you use the feature it will complete the method signature and move the cursor to the method body enabling you to write your code in a more fluent manner. It works in a number of situations so you really want to learn the shortcut and start experimenting with it.

Complete Statement for if-statement. First step inserts the missing parenthesis and the curlies. Second step moves the cursor to the body of the if-statement.

ReSharper-4x-Statement-Completion-If-Step1  ReSharper-4x-Statement-Completion-If-Step2 ReSharper-4x-Statement-Completion-If-Step3

Complete Statement for method signature. Inserts the curlies and moves the cursor to the method body.

ReSharper-4x-Statement-Completion-Method-Step1 ReSharper-4x-Statement-Completion-Method-Step2

And for a string variable. Inserts the semi colon and moves the cursor to the next line.

ReSharper-4x-Statement-Completion-string-Step1 ReSharper-4x-Statement-Completion-string-Step2

Generate in Solution Explorer

You probably know about the Generate feature in Visual Studio which enables you to generate properties, constructors, etc.. What I didn't know about this feature is the fact that it's also availble in the Solution Explorer and basically enables you to create a class, interface, struct, or folder. Very handy indeed.

Generate is available from the R# menu Code > Generate (ALT + INS).

ReSharper-4x-Generate-In-Solution-Explorer

Camel Case Navigation

I love the code navigation features of R#. They let me find my way around a code base very simply. I've found this particularly useful in code bases I don't know very well because I usually have an idea of what another developer might choose to call something so I just go look for part of that type name. Anyway a twist on the navigation features is the fact that you can navigate via Camel Casing so if you have a type named OrderManagementService you could look for it by typing the entire thing but with Camel Casing you basically enter the upper case letters of OrderManagementService (OMS) and it will find that type for you. Very handy and my second favorite new feature of R# :)

BTW Navigate to Type is CTRL + T, Navigate to Any Symbol is CTRL + ALT + T, Navigate to File Member is ALT + <, and Navigate to File is CTRL + SHIFT+ T. Learn 'em, love 'em.

ReSharper-4x-Navigate-by-CamelCase-Standard ReSharper-4x-Smart-Code-Completion

Coming Features

Oleg also told us a little bit about what we can expect to see in R# 4.5. The main "feature" of the 4.5 release is performance tuning and bringing down the memory footprint. They're look at speeding up R# by a factor 2 and bringing down the footprint by 100 mb. Certainly very welcome. They are sneaking in new features though and one of them is to include "Find unused code" in Solution Wide Code Analysis.

Download ReSharper 4.1

posted on Saturday, 13 September 2008 15:37:02 (Romance Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Friday, 23 November 2007

I had a problem today where a file exported from a system was showing up correctly in my text editor but whenever I tried to re-import it elsewhere my special characters where messed up; ÆØÅ showed up as garbled characters.

Of course the reason for this is the fact that the export sets an old code page on the file which isn't recognized by the receiving system so I simply had to change the code page of the file.

My instinct was to go with UltraEdit but I didn't have a license around so I thought that Visual Studio probably would get the job done for me and it did but it isn't too obvious how to do it; not that UltraEdit is intuitive in this area either :)

  • Open the file in Visual Studio.
  • From the file menu select Advanced Save Options
  • Select the code page

Visual-Studio-Advanced-Save-OptionsVisual-Studio-Advanced-Save-Options-Dialog

posted on Friday, 23 November 2007 11:32:44 (Romance Standard Time, UTC+01:00)  #    Comments [0] Trackback
# Tuesday, 09 October 2007

VisualStudioLogo Have you ever spent more time looking for the item you wanted to add to your project than actually writing the code for it? I've spent plenty of time not being able to find that particular item in my Add New Item dialog because Microsoft just threw everything in there with a huge pitch fork.

Luckily for us K. Scott Allen found this annoying as well and went digging in the Visual Studio project templates and found that he could sort the list using a little Powershell script he did.

So he went from this to this:

clip_image002image

Download his Powershell script for sorting the Add New Item dialog and remember to grab Powershell as well to make it go. Please note that Powershell has policies in effect which means that you have to allow the script to run. I simply did a Set-ExecutionPolicy Unrestricted and then ran the script. I know I shouldn't be allowing all scripts to run but I don't really use Powershell for anything serious at this point so it doesn't matter.

Thanks to Daniel for this tip.

posted on Tuesday, 09 October 2007 18:23:54 (Romance Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Wednesday, 11 April 2007

Great news to the people annoyed by the fact that Team System isn't available to everyone: Some of the unit testing features from Team System will start appearing in Visual Studio Professional in the Orcas release. Also Microsoft is looking into adding more stuff from Team System into Visual Studio so be sure to voice your opinion on that.

"Due to popular demand we have decided to add the majority of the unit testing features of Team System to the Pro Sku of Visual Studio.  With the release of Orcas, the support for authoring, generating and running unit tests, will become available to the users of the Pro Sku of Visual Studio. Pro customers will also take advantage of the some of the unit testing improvements we have added into Orcas"

[Unit Testing Trickling into Pro!]

I'm still thinking that we need to see much more especially with projects like TestDriven.NET and NCover providing so much more. Also Team Foundation Server is a big part of the equation. Of course we have the ability to duck tape together an open source solution which does approximately the same thing. At this point I would even argue that an open source solution would be better but taking the future into consideration the open source solution will never be able to keep up with Team System simply due to the fact that the one thing Microsoft does extremely well is product integration. They have all the basics down and they have been moving on the round two for some time now.

posted on Wednesday, 11 April 2007 11:23:01 (Romance Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Thursday, 01 February 2007

Visual Studio 2005 SP1 is getting pushed out via Microsoft Update and the one question which keeps popping up here at the office is why the installation fails. Typically this is caused because some version of Web Application Project is installed. WAP is included in SP1 which is why the install fails.

 You will need to remove it before you can successfully install SP1. It would appear that the SP1 installation isn't very clear on this.

Just a little heads up. Scott Guthrie posted about this a while back.

posted on Thursday, 01 February 2007 09:39:29 (Romance Standard Time, UTC+01:00)  #    Comments [0] Trackback
# Friday, 10 December 2004
  1. Open Visual Studio without a loading a solution
  2. Go to Tools / Options
  3. Open Source Control folder
  4. SCC Provider
  5. Change the login name in the Login ID textbox (if the textbox is grayed out you need to close the currently open solution from the File menu)

From Visual Studio 101 series :)

posted on Friday, 10 December 2004 11:20:19 (Romance Standard Time, UTC+01:00)  #    Comments [0] Trackback