Errr, some catchy title.... RSS 2.0
 Tuesday, March 27, 2007

I was writing a Powershell script today to automate deployment for application we’re currently working on. Part of the requirement was to get latest files from Visual Studio SourceSafe. VSS provides us only with COM wrappers; however I wanted to do that via .NET objects.

 

Luckily googleing the problem has produced some valid resources. Check out VSS Code Samples. From there, download OLE Sample Code Written in Visual Basic .NET and C#. This exe contains a .NET solution with 2 projects: .NET VSS Library written in C# and a VB.NET explorer application that is basically a VSS Explorer that uses the Library under the hood. The problem is this has been written for version 6 of VSS and I had version 8 (the 2005 release).

 

Due to this, the explorer application couldn’t compile, since it relied on some ActiveX that simply wasn’t there anymore. Luckily, the underlying VSS Library still worked. Below is a sample code that I used to do my small task with the VSS Library. The code gets all items (recursively) from the given path.

 

clIVSSLibrary lib = new clIVSSLibrary();

string errorOccured = null;

errorOccured = lib.OpenDB("Martin.Waligora", "somepassword",  "\\192.168.1.75\vss_application");

errorOccured = lib.SetCurrentProject("project");

errorOccured = lib.SetWorkingFolder(@"$/project/DistributionImage", @"C:\VSSTest");

VSSFlags flag = new VSSFlags();

long flags = flag.FlagGetLocalCopyYes() + flag.FlagRecursiveYes()

                        + flag.FlagReplaceLocalReplace() + flag.FlagRights_All();

 

string getPath = null;

errorOccured = lib.GetItem(@"$/project/DistributionImage", ref getPath, (int)flags);

lib.CloseDB();

 

 

After writing the code I’ve added it to my Powershell script. Here’s it:

 

$VssDllPath = 'C:\IVSS_Sample\IVSSDLL\bin\Debug\IVSSLibrary.dll';

"Loading the .NET VSS DLL $VssDllPath"

$ass = [reflection.assembly]::LoadFrom($VssDllPath);

 

"Creating object of type IVSSFunctionLibrary.clIVSSLibrary"

$VssLib = New-Object IVSSFunctionLibrary.clIVSSLibrary;

 

#We create a function to help us with calls to the vss library

function ErrorOccured

{

      if($args[0].Length -gt 1)

      {

            "Error has occured: $args[0]"

      }

}

 

#We insantiated the object, now let's get all data to specified directory

ErrorOccured $VssLib.OpenDB("Martin.Waligora", "fakepass", "\\192.168.1.75\vss_app");

"Starting to copy all the files"

ErrorOccured $VssLib.SetCurrentProject("project");

ErrorOccured $VssLib.SetWorkingFolder("$/project/DistributionImage", $remotePath);

#$flags = 67117199;

$getPath = "";

ErrorOccured $VssLib.GetItem("$/project/DistributionImage", [ref] $getPath, 67117199);

ErrorOccured $VssLib.CloseDB();

"Success, finished copying files to $remotePath";

Tuesday, March 27, 2007 4:02:45 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Powershell
 Monday, March 26, 2007

Last week I've passed 70-229 exam by Microsoft. It was the final one out of 5 exams required. Hence, now I am Microsoft Certified Solution Developer and I can use those logos (MCAD is a subset of MCSD):

 

                                                                 

 

To sum up: Awesome :D .....

Monday, March 26, 2007 4:27:00 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Other
 Thursday, March 22, 2007

I just finished week long second trimester of my Masters course. The module was about Design Patterns. Every day we had lectures in the morning and then labs in the afternoon. During the lectures we went through most of the Gang of Four patterns, they were pretty interesting even though I knew most of the stuff. What I really loved about the course were the labs.

 

Every day we were given some working application and we were supposed to apply some specific pattern to extend the functionality of the application. I always believed, that it’s impossible to learn design patterns just by reading a book, you gotta look at the code and try to incorporate it into it, or just ‘get it’. What was good about the exercises in the lab is the fact that the applications were easy enough to understand their inner workings immediately, but complicated enough to see, that some pattern would help here a lot.

 

Oh yeah, and I was able to refresh my memory of Java and Swing. Win-win situation.

Thursday, March 22, 2007 3:00:34 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Other
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2008
Marcin Waligora
Sign In
All Content © 2008, Marcin Waligora
DasBlog theme 'Business' created by Christoph De Baene (delarou)