Tools

The search result window from Visual Studio is not really the best. Sometimes it can be hard to find what you’re searching for, especially when you have long file paths. Unfortunately you cannot even copy/past the results to Excel and filter/sort there.

Luckily there is a hidden Registry Key you can use to format the output on your own.

The Registry Key is in  HKCU\Software\Microsoft\VisualStudio\<your VS Version>\Find and should be named Find result format (type is string). Just create it if it doesn’t exist.

It holds a formatting string and you can use a combination of the following variables:

Value Explanation Example
 $p Path
 $f Filename
 $v drive / unc share
 $d Directory
 $n Name
 $e Extension
 $l Line
 $c Column
 $x end col if on first line, else end of first line
$L span end line
$C span end col
$0 Matched text
$t text of first line
$s summary of hit
$T Test of spanned lines
\n Newline
\s Space
\t Tab
\\ Slash
\$ $

My favorite is $p($l,$c):\t\t\t$s\r\n This one allows you to copy/paste the result to Excel for very easy further filtering and sorting (columns are detected correctly because of the tabs).

Another nice one is $f$e($l,$c):$t\r\n which just shows the file names and not the entire paths.

Sources:

Today was one of the days when I found a feature in Visual Studio which could have helped me already years ago.

If you’re working with many tabs (like for migrating something) you find yourself searching the right tab quite often. To solve this, there is a (for me unknown) setting in Visual Studio to move pinned tabs to it’s own row in the Document Well.
See the following screenshot for this setting:

Sometimes, if that is not enough, there are Add-Ins available to go further with that.
One is Productivity Power Tools which is free and enables also other possibilities for the tabs.

Then there’s also the commercial Tabs Studio which should provide pretty anything you need.

After some time, your TFS-Workspace can get quite crowded with files and folders which were deleted.

To clean your workspace and delete all unversioned files, navigate to a folder which is under source control and run the following command:
tfpt treeclean /exclude:*.suo,*.user /recursive
After some time, you’ll get a dialog which shows all files which will get deleted.

Sometimes after formatting a Harddrive and re-installing Windows, the NTFS-Permissions for other drives are kinda corrupted (need Admin-Rights for everything, “Unknown User” is there, …).

There is a simple command-line command you can execute to reset the permissions.

  1. Start “cmd” as Administrator
  2. Navigate to the Drive you want to reset the permissions
  3. Run the following command: icacls * /T /Q /C /RESET

After a while, your permissions are all fixed!

Source: http://lallousx86.wordpress.com/2009/06/14/resetting-ntfs-files-security-and-permission-in-windows-7/

More Info about icacls.exe

This error has greeted me several times before in the past when working with Msysgit on Windows. It alway appears for no apparent reason; sometimes from one boot to the next, and sometimes it suddenly starts happening while the system is running. Once the error is there, it stays consistently at the very least until the next reboot. Sometimes it only happens for specific commands like “git log”, sometimes it seems to affect every cygwin command.
Continue reading Msysgit couldn’t reserve space for cygwin’s heap

Recently I stumbled on a piece of PowerShell syntax that confused me massively on first glance

$ some-command |% {some-expression}

It took me a while to find the documentation for that since I was of course looking in the wrong place. It looked to me like some sort of special pipe, when in fact it is just a pipe “|” followed by the ForEach-Object CmdLet which has an alias that (unfortunately) is “%”. So what was actually happening is:

$ some-command | ForEach-Object {some-expression}

For example, I used this to basically fill in some placeholders in a template file

$ Get-Content "mytemplate.txt" |% {$_ -replace "PLACEHOLDER", "42"}

Sometimes you want to step into Source Code which comes from the core components of Microsoft. You can either decompile the .Net Libraries with .Net Reflector or ILSpy or use the Microsoft Reference Source Code Packages.

The Reference Source Code allows you to directly lookup the source or even debug into the core components of Microsoft. Just download the Packages you want, install them and you’re done. You now can Debug into (F11) the source or look it up (F12).

Alternative for Visual Studio 2010
Setting up Visual Studio 2010 to step into Microsoft .NET Source Code

Today, I tried to make a Release Build of a rather large solution and I got this exception:

Could not load file or assembly ‘file:///C:\some.dll’ or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515) C:\somepath\SGEN

The solution is simpler than it looks like:
The DLL was downloaded from the web and somehow, Windows “blocked”. To unblock it, just right-click the DLL in your explorer and click the “Unblock” button (make sure, you have write access to the file).
That’s all what is needed to fix this problem (at least in my case).