Monday, 27 August 2007

Setting up slick run shortcuts quickly

I use slickrun for lots of things, but what I find it most useful for is opening up visual studio with the correct solutions. The reason its so useful is that our project is based on about 80+ vs solution files, and numerous more project files, carefully organised in to appropriate directories and subdirectories. After getting bored setting up 10 odd shortcuts in slickrun (even using drag and drop) I decided that code would be a quicker solution. Anyway 5 minutes in notepad++ (qrs.cs) and using c# from command line I had:


using System;
namespace qrs {
public class p {
[STAThread] public static void Main(string [] args) {
Console.WriteLine("[{0}]", args[1] );
Console.WriteLine("Filename=\"{0}\"", args[0] );
Console.WriteLine("Path=\"\"");
Console.WriteLine("Params=\"\"");
Console.WriteLine("Notes=\"\"");
Console.WriteLine("GUID={{{0}}}", Guid.NewGuid().ToString());
Console.WriteLine("StartMode=5");
Console.WriteLine("UseRunAs=0");
Console.WriteLine("");
}
}
}


(yes thats a rubbish name :-)

This only requires you to run the exe with the first parameter as the sln file, and the second parameter as the shorcut name. To generate the list I did a simple command line "for".


for /f "tokens=*" %f in ('dir c:\project_root\*.sln /s/b') do @echo qrs.exe "%f" "%~nf" >> myqrs.txt



This generated a load of entries in a file called myqrs.txt ,that I was able to cut and paste into the slickrun ini file.



[Solution2]
Filename="C:\project_root\Subdir\Solution2.sln"
Path=""
Params=""
Notes=""
GUID={29647410-3995-45bf-9e46-cd8540f94c35}
StartMode=5
UseRunAs=0
[Solution1]
Filename="C:\project_root\Solution1.sln"
Path=""
Params=""
Notes=""
GUID={443ba4c0-339a-45d7-bae4-97a2d7bc511f}
StartMode=5
UseRunAs=0

Thursday, 23 August 2007

Finding the .net framework path programattically

This seemed to be an easy question to answer when my colleague Jamie first asked. But it took a while to track it down.


System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()


Thanks to Stephen Toub