Jun 11 2010

Execute Command Files from Visual Studio 2010

Category: Visual StudioJay Smith @ 08:47

On a recent project we used custom Visual Studio build files to build and deploy the code to different environments, i.e. Test and Production.  We created command files to pass the correct arguments to the build so it would be easier to run.  We never liked the fact that we need to open a command window and navigate to our solution folder to run the builds.  We thought, “There has got to be a way to do that from with in visual studio”, and we were right.  Devlin Liles details the steps we used to set that up in Visual Studio 2008 in his blog post titled Batch File and Command File running In Visual Studio.

I wanted to set that up in Visual Studio 2010 today and found the steps a little different so wanted to share how to set it up in Visual Studio 2010.

To realize the ability to execute command or batch files from within Visual Studio 2010 we need to perform the following steps:

  1. Create the External Command
  2. Adding the Command to the Context Menu

Setting up the External Command

  • Open the External Tools dialog by opening the Tools->External Tools menu.

image

  • Click the add [Add]  button to create a new External Tool and enter the following information:
Title E&excute Command…
Command C:\WINDOWS\System32\cmd.exe
Arguments /K $(ItemPath)
Initial directory $(ItemDir)
Use Output Window Checked
Prompt for arguments Not Checked
Treat output as Unicode Not Checked
  • Click the [Apply] button to save these changes, but before you click [OK] take now of a how many External Tools are listed here.  In my case it was the only external tool that had been defined so it will be assigned to External Tool 1
  • You can click [OK] now to close the External Tools dialog.

Adding the Command to the Context Menu

Now that we have our external command created we need to add it to the context menu for Solution Explorer items.

  • Open the Customize dialog by right clicking somewhere in the toolbar area to bring up the context menu and selecting Customize from the bottom of the menu.

image

This is where the steps for Visual Studio 2010 are different than Visual Studio 2010.  If you are using Visual Studio 2008 follow the instructions on Devlin Liles blog.

  • Select the [Commands] tab

image

  • Under Choose a menu or toolbar to rearrange: select Context menu: and in the drop down select Project and Solution Context Menus | Item.

image

I want my “Execute CMD…” command to be positioned above the “Edit WCF Configuration” items, so select “Edit WCF Configuration” and click the [Add Command…] button.

image

  • On the Add Command dialog in the Categories list select Tools.  Know in the Commands list scroll down until you see the External Command you are looking for.  Remember ours was External Command 1.  Once you find it select it and click [OK].

image

Now we see that External Command 1 is shown above the “Edit WCF Configuration” command, right were I wanted it. 

  • Now you can click [Close] button, open a solution and when you open the context menu in Solution Explorer you see the following:

image

Summary

This addition to Visual Studio has come in really handy for running common commands or batch files you might need to automate more mundane task.

Tags:

May 25 2010

Shared Assembly Info Files in Visual Studio Reborn

Category: Visual StudioJay Smith @ 13:33

The last project I worked on had a lot of class library projects in it and we really struggled with file versions.  We really wanted a good way to give all the class libraries the save version number other information.  I seem to remember that in an older version of Visual Studio, 2005 I think, if you created a setup project you could tell it to make all the file versions the same.  I couldn’t get this to work in Visual Studio 2008, or 2010, and it doesn’t work for web applications.

After talking with several of my colleagues, Devlin Liles and Rob Tennyson, and others we came up with a solution of using a Shared Assembly Info file across the projects.  I am starting a new project and since I didn’t remember how we did it of course I consulted the great oracle of all collected knowledge, Google and found this article Shared Assembly Info in Visual Studio by Jeremy Jameson and this solution worked great.  I was able to get my new project well underway with Shared Assembly Files and got to bed early.

The benefits I have found so far are that all outputs of the build have the same number and you only have to update the product and file versions in one place.

If you have struggled with this in the past check be sure to check this out.

enjoy

Tags:

Jan 7 2010

Visual Studio 2008 Test Item Templates Missing

Category: Visual StudioJay Smith @ 07:12

This week my current project decided to start using Visual Studio Team Test for manual UI test.  So, naturally someone had to write the test, but we didn’t have Visual Studio Team Tester Edition installed.  After installing it, which looked good, when I went to add a new “Manual Test (Word Format) none of the new Item Templates where there. 

After a little searching I can across this post from 2007 that said to run  the following to correct it.

   1:  C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE>devenv.exe /setup

From the post they believed that the issue was that the Item Template cache was not getting updated.  Running devenv.exe /Setup forces Visual Studio to merge the resource metadata that describes, menus, toolbars, and command groups from the VSPackages.  Evidently it also updates the Item Template Cache as well.

All is good and I am off created Manual Test now.

Tags:

Jan 2 2010

Visual Studio 2008 requires SQL Server Express 2005 to function properly.

Category: Visual StudioJay Smith @ 13:20

A few months ago I rebuilt my laptop and reinstalled Visual Studio 2008 and installed the SQL Server Express both x64 versions.  When in a solution and trying to add a SQL Server database I would get the following error.

“Connections to SQL Server files (*.mdf) require SQL Server Express 2005 to function properly.”

I have been searching for a fix for this for the last few weeks and finally found this Microsoft Support hotfix.

This issue is only experiences on 64bit systems, 32bit systems are working correctly.  Your system should also have Visual Studio 2008 SP1 or Visual Studio 2008 Express Edition with Service Pack 1 installed to apply this hotfix.

Tags:

Aug 13 2008

.NET Framework 3.5 SP1 and Visual Studio 2008 SP1 Released

Category: .NET | Visual StudioJay Smith @ 00:08

Microsoft has released the .NET Framework 3.5 SP1 and Visual Studio 2008 SP1 this week to Microsoft Downloads only a few days after releasing SQL Server 2008.

Two of the main features added in the .NET Framework service is pack is the ADO.NET Data Services and the ADO.NET Entity Framework. Visual Studio 2008 Service Pack 1 comes with a better WPF designer, a rich entity designer and full compatibility with SQL Server 2008 that was released a few days ago.

Thanks to by buddy John Oswalt for keeping me in the loop.

Tags: