Ben Farmer

in
Remapping the Visual Studio F5 Key to Build Solution

I’m writing this mostly as a resource for myself for the next time I need to remember how to do this, but hopefully someone else out there will find it useful.

I’m currently working on a project where I am doing a lot of ASP.Net development.  For a couple of very good reasons the development team has decided to configure our development workstations to use the local IIS server that is built into Windows XP rather than working with the web server that is integrated into Visual Studio. I’m starting to really like this workflow, particularly when I’m doing a lot of jQuery or CSS tasks, because I don’t need to wait for the whole project to recompile and launch in Visual Studio’s web server just to check a tiny change. 

One thing that I can’t seem to get over is the entrenched reflex to mash the F5 key when I want to test a change.  I think it’s just too engrained in muscle memory as part of the test-fix-rebuild cycle I’ve done a million times before.  After a couple of months of trying to shift my F5 habit toward using “The Awkward Claw” (Ctr+Shift+B), I decided to change the behavior in Visual Studio to simply trigger a build when I hit F5.  Here’s what I did (Note: My team is kicking it old-school and using Visual Studio 2005.  You might need to do some translation to follow these steps in other versions of Visual Studio):

In Visual Studio open the Options dialog box (Tools > Options…), expand the Environment group and click on the Keyboard node. In the “Show command containing” text box, type “Debug.Start”. Find the command named “Debug.Start” and select it.  Under the label that reads “Shortcuts for selected command:” click the Remove button to unwire the F5 shortcut key.

Visual Studio Options dialog box

Now all those inadvertent presses of F5 won’t do anything.  This is marked improvement, but we can do better. We can harness all of those uncontrollable left-middle finger reaches to recompile our solution, which is what I want to do 95% of the time anyway.

To wire the F5 shortcut key to the build operation we can use the same section of the Options dialog box.  This time we are going to filter the available commands by typing “Build.BuildSolution” into the text box. Find the command named “Build.BuildSolution” and select it. Now in the drop down list under the label that reads “Use new shortcut in:” select “Global”. Put focus in the textbox under the label that reads “Press shortcut keys:’ and press the F5 key and then click the Assign button.  The build solution action is now wired up the F5 key.

Visual Studio options dialog box

Posted: Nov 12 2009, 01:06 PM by bfarmer | with 2 comment(s)
Filed under:
Microsoft Tag

Check out Microsoft Tag.  You can print barcode-like 2D tags that can be read by the Tag mobile app on a mobile phone. When the mobile app reads a tag it automatically takes the user to the URL that is associated with the tag.  The Tag website makes it very easy to make and print out tags.  Thankfully, they have a Tag app for the iPhone.  Pretty cool stuff.

Missing .designer Files

I found an interesting blog post that helped ease some problems I was having in an ASP.Net web application I am working on.  The original post can be found here: http://blog.bdapps.com/2008/07/15/RestoreDesignercsFilesInVisualStudio.aspx

 

I am working on an ASP.Net web application that started life as a Visual Studio website project and was later converted to a Visual Studio web application project.  Visual Studio provides a single-click operation to convert a website project to a web application project, but unfortunately this operation does not always go smoothly.  The problem I am having occurs when I have a control defined in markup in an .aspx or .ascx file and I attempt to reference the control in the codebehind (.cs) file, but Visual Studio is unable to find a control with the specified name.  When this occurs I get an error similar to the following:

 

'Page1' does not contain a definition for 'Lable1' and no extension method 'Lable1' accepting a first argument of type 'Page1' could be found (are you missing a using directive or an assembly reference?)

 

The root problem is controls created when I was still using a website project do not have a .designer file. To solve this problem you can right-click on an individual file and choose “Convert to Web Application”. This will force visual studio to create the .designer partial class file.  Once the .designer file is created, the controls you add in markup in the .aspx or .ascx file will be visible in the codebehind file, with IntelliSense.  This solution should also work if you already have a .designer file and it gets corrupted by Visual Studio. You should be able to delete the .designer file and then recreate it, but I have not yet verified that this works.

 

Posted: Sep 27 2008, 09:41 AM by bfarmer | with 1 comment(s)
Filed under:
First Post!

This is my obligatory first post! message.