Saturday, January 22, 2005

Managing your AS2 class files with VSS

One of the cool features of MX2004 was VSS integration but it turned out this was only as part of managing a project.

At first glance this seemed limiting, apart from needing a "project" in the first place, before you could activate VSS in a particular project you needed to create a "site" and then select that "site" for use by the project. A site seemed like it was assuming your project was for developing a flash web site particularly as it will automatically read sites you may have defined in Dreamweaver for your web site maintenance. Cool if that's what you are doing but not so useful if your not. Indeed I didn't really find documentation about using it in any other way so I quickly forgot about it.

As a component developer I wanted a way to manage all my AS2 class files which amount to several hundred files. There was no "site" as such, nor really a "project". It didn�t really seem that the whole project thing fitted with what I wanted.

At first I thought this might become a wish list item for Flash8 but after poking around I found a way to make it work. Of course if you have done this already it will just be "obvious" but if you haven't got that far your might struggle as I did and give up. Don't know about you but if something is important I will keep searching till I find a way but if its not so important I just give up very quickly if it is not made obvious to me as I have better things to do with my time, so here is how I got it to work for me.

First I am assuming you already have VSS installed on your system and you have a user account setup. I am using VSS6 by the way.

In the Flash IDE I created a project which I called "XPSource" though you can name it anything you like. At the same time I also created a project in VSS called "XPSource" under "$/".

The next task is to add all you class source files to the flash project.
My class files are under the "xp" branch located at C:\Documents and Settings\XXXXXX\Local Settings\Application Data\Macromedia\Flash MX 2004\en\Configuration\Classes. The structure there mimics the classpath and package structure i.e. there is a folder "xp/util" which contains a file MathUtil.as.
Unfortunately there isn't a way to adds all files recursively to a project so this has to be done folder by folder. So first I recreated the folder structure i.e. in the IDE with my newly created project open I added a folder "xp" then double clicked it to open it and then again added a folder called "util". Now with that created I double clicked "util" and then selected "Add File(s)". This pops open a file dialog, navigate to the util folder and select all the files (click the first file, hold down the shift key and select the last file). Click the Open button and all the files will be added to the project "xp/util" folder. Repeat this for all folders and files in your class hierarchy.
When that is complete your project will look the same as a it does in Explorer if you looked at the root of Classes.

The next step is to create a "site" so we can activate VSS.
From the main menu choose Files/Edit Sites. Then click New on the Edit Sites dialog. This pops up the SiteDefinition dialog. Complete the fields as follows;
SiteName: "XPSource"
LocalRoot "C:\Documents and Settings\XXXXXX\Local Settings\Application Data\Macromedia\Flash MX 2004\en\Configuration\Classes\"
Email: "me@somewhere.com"
Checkout Name: "MyVSSUserName"
Below the last field is the Connection ComboBox, click it and select SourceSafe Database.
There is then a "Settings" button below the ComboBox. Click it and open the Open SourceSafe DB dialog. Again, complete the fields as below;
DatabasePath: The path to your srcsafe.ini file for example "D:\Program Files\Microsoft Visual Studio\Common\VSS\srcsafe.ini"
Project: "$/XPSource"
Username: "MyVSSUsername"
Pasword: "MyVSSPassword"

Then click Ok and close the dialog, then Ok again to close the SiteDefinition Dialog, and finally click Done to close the edit sites dialog.

Next go back to your project panel, right click and select "Settings" and in the dialog that opens, under Version Control, open the Site ComboBox and select "XPSource". Click Ok to close the dialog.

Ok now your done and ready to start loading VSS.

Select your top level folder under XPSource i.e. "xp" then right click and select "Check In" complete the usual check in dialogs and all your files are checked into VSS and marked as read only in your local folder.

That�s it basically, make sure your project is saved, and now anytime you want to check out a file open the XPSource project find the file double click it and you will prompted as to whether you want to just view it or check it out.

Once you have got this far its quite easy to customize this to you own needs. For example, create a new project that works on a subset of the class files, and in VSS create a new project and set it to share the files with your XPSource project. If your familiar with VSS this should be straight forward.

Rob

3 comments:

  1. Excuse my ignorance, but what is a VSS? I pretty much understood everything else you mentioned, just what does VSS stand for? Thanks!

    ReplyDelete
  2. VSS==VisualSourceSafe - Popular MS Version Control Software that comes with Visual Studio.

    ReplyDelete
  3. Ah right, now I understand. Thanks!

    ReplyDelete