TFS: How do I view .cs files in the VS IDE when viewing details of a shelveset?

2.4k views Asked by At

For our code review process we open the details of a shelveset to see all files that have been worked on. Right clicking and choosing "Compare" works great for existing ( modified ) files. But, when a file has been added I just want to view the file. Double clicking ( or right click -> view ) opens .cs ( and .sql )files in notepad. When I try to open a .PRC file ( extension for our stored procedures ) I get a prompt that allows me to choose what program to use for viewing.

Does anyone know how to get this prompt to show up for .cs files ( and all other files, for that matter )

Thanks!

Configuration: Visual Studio 2008 SP1 Visual Studio 2008 Team Explorer .net 3.5 SP1 Team Foundation Server 2005

3

There are 3 answers

3
AakashM On BEST ANSWER

Double clicking ( or right click -> view ) opens .cs ( and .sql )files in notepad. When I try to open a .PRC file ( extension for our stored procedures ) I get a prompt that allows me to choose what program to use for viewing.

This isn't really a TFS issue, but more to do with how your local Windows is set up. If you navigate in Windows Explorer to a folder with .cs and .sql files in, and double-click them, you will be able to see that TFS is simply invoking the standard behaviour that is configured for these files.

To change it, again in Windows Explorer, go to Tools | Options, and on the File Types tab find the .cs file extension, and with it selected click Delete. Now attempting to open a .cs file will make Windows ask you what to do with it (note that if you check the 'Always use the selected program to open this kind of file' checkbox, you will be back where you started).

This is a global setting - I don't know if there's a way to make TFS do something different from just asking Windows to deal with the file. So if you want to keep the ability to launch notepad when double-clicking .cs files in Explorer, but still have TFS ask what to do with them, this won't help. Also, these instructions are pre-Vista - I don't know what's changed in Vista. You might want to ask on superuser.com what to do if you're on Vista and these instructions don't help.

0
Proto On

Inspired by AakashM's reply, and since I am using Notepad2 recommended by @shanselman here, and since there is a way to permanently replace Notepad with Notepad2, as mentioned in the link provided in the same article (method 2 in that MSDN blog page), I first replaced Notepad with Notepad2 and then implemented AakashM's suggestion.

After that there are two options:

  1. You can set .cs files to be opened always in VisualStudio in which case the Changeset window -> Open prompted me to select an application to open cs files.
  2. Or even better, set .cs files to be always opened in Notepad2, and now that we have replaced Notepad with Notepad2, when we click Open from Changeset window it automatically opens in Notepad2 (with syntax highlighting).

Perhaps you can do it with any good text editor, but I haven't tried it with anything other than Notepad2.

0
Spyder On

your solution does not work for me. I checked windows explorer and my .cs files are actually associated with VS2008 (so when i double click a .cs file in windows explorer it will open in vs2008, which makes sense) but what is strange is I dont really use vs2008. I use VS2010 as code editor and regardless of the Windows Explorer file association my files are still opened in Notepad.exe (when i compare or view a shelveset and open a newly added file).

I think there must be a different association within visual studio 2010 or TFS somewhere ? (Im on Windows 7 if it makes any difference)