Search This Blog

Monday, September 28, 2009

Simple PowerShell way to change a string across multiple files

This situation comes up only occasionally and I keep forgetting how to do it, so here it is so I can save myself the time next time:

1) Position myself in the directory where the files are located
2) Type in this quicky applet in PowerShell:

$filenames = ls *.exe.config
$match = "devserver2"
$replacement = "prodserver1"
$filenames | %{
>> $content = get-content $_
>> $content = $content -creplace $match, $replacement
>> $content | set-content $_
>> }

Note that I used the case-sensitive PowerShell replace verb. I wish this could be a one-liner but I haven't been able to figure out how to do that.

Monday, September 21, 2009

Helpful tip when using VS2008 over slow network connection

Disable the animations in VS2008 to improve performance over slow network connections:

Tools / Options / Environment / General -> uncheck the "animate environment tools" checkbox

Saturday, September 12, 2009

Installing VS2008 C# services under Vista

There's something wrong with using a Visual Studio 2008 setup project ot install a windows service under Vista.

It's a pretty deep problem (see Alek Davis's post at http://alekdavis.blogspot.com/2007/09/deploy-windows-services-on-vista.html for details) ... and not worth the effort, in my estimation.

Just use INSTALLUTIL under the C:\Windows\Microsoft.NET\Framework\v2.0.50727 directory to install the service the old-fashioned way (INSTALLUTIL ) using the machine's administrator account (make sure to run INSTALLUTIL using "RunAs as Administrator" -- it doesn't seem to work if you try running it with an account with administrator privileges).

I included the Alek Davis link in case I need to actually create a service setup program in the future, here's hoping I don't.

I'm curious as to whether this problem persists in Windows 7.

This is another reason that Vista is not working out for me. If I hadn't gotten that free copy at the Microsoft Roadshow I'd have never touched it; perhaps this is why it was free.

Thursday, September 10, 2009

Forcing Tortoise/SVN to refresh icon overlays

I use Tortoise/SVN at a client site as the tool for handling source control. The client's computers are rather underpowered, unfortunately, and often the Tortoise icon overlays can get really out of date (or disappear entirely). It's hard to tell what has been committed, what's changed, etc.

The easiest way I've found to force a "refresh" on these icons is to close the Windows Explorer window and run "TSVNCache.exe" from the command prompt. Give it a chance to run and wait a while (I'm finding that it takes my client's machines about 20 seconds), then start Windows Explorer. The icons should be back and (more importantly) should correctly reflect the status of files/directories.

Tuesday, September 8, 2009

Checking Session variables during Visual Studio 2008 debugging session

Often during debugging I need to enumerate the current session variables in use plus get their current values. It isn't documented but it isn't hard to do by examining the "Session" variable which is available during a debugging session.

  • Add a "Session" watch variable in the watch window
  • Under the "Session" watch variable, look under "Keys"
  • Look under "Non-public members"
  • Look under "_col"
  • Look under "Non-public members"
  • Look under "_entriesarray"

Each Session variable will be listed along with its current value.