Brian Hartsock's Blog

Tag: Visual Studio

Powershell script to Register Visual Studio Schemas

by bhartsock on Sep.15, 2009, under Uncategorized

I always have to Google how to add an XML schema to Visual Studio because I forget the directory (even though it is super easy). Never again will I forget.

function register-vsschemas()
{
	begin
	{
		$schema_folders = gci $env:ProgramFiles -Filter "Microsoft Visual Studio*" | 
							gci -Filter "Xml" | 
							gci -Filter "Schemas"
	}
 
	process
	{
		if(!$_ -or !(Test-Path $_))
		{
			Write-Error "File '$_' not found"
			break;
		}
		if((gi $_).Extension -ine ".xsd")
		{
			Write-Warning "File $_ does not end in an .xsd extension"
		}
 
		foreach($folder in $schema_folders){
			#It is very interesting I had to use .FullName...
			cp $_ $folder.FullName -Verbose
		}
	}
}

Call it as follows:

gi .\lib\NHibernate\*.xsd | register-vsschemas

Post to Twitter Post to Digg Post to Facebook Post to Reddit

Leave a Comment :, , more...

Visual Studio Tip: Show All Files

by bhartsock on Sep.14, 2009, under Uncategorized

I discovered a Visual Studio feature that I probably should have noticed years ago. It is pretty awesome, and right in front of your face. Show All Files

9-13-2009 8-36-34 PM

Just click the icon in the Solution Window highlighted in the above screenshot.

9-13-2009 8-40-15 PM

Bam, all files in the directories get shown, even if they aren’t part of the project. Pretty awesome, especially because of the Include in Project functionality. Much quicker to add items to a project than Add Existing Items.

Post to Twitter Post to Digg Post to Facebook Post to Reddit

Leave a Comment :, more...