Moving To Subversion… Step-by-Step

Posted by Dave Bouwman | Posted in .NET, Team System | Posted on 12-11-2007

3

This week we finally completed our transition over to Subversion. As part of this transition, we moved 52 project out of a very old version of Source Gear Vault, and 13 project out of Microsoft Team System.

With this much code, we needed an automated way to clear out source control bindings. Our code base has 3 types of projects – Visual Basic 6, Visual Studio 2003 and Visual Studio 2005.

Here are the steps we followed:

  1. Get all source code out of both the Vault and Team System
  2. Backup the entire source tree (just in case!)
  3. Search for .scc files and delete them. This removes the bindings for VB6 projects
  4. Download SCC Remover tool from CodeProject.com. This will clean out the source control information in solution files (.sln), solution user option files (.suo) and the projects themselves (.csproj and .vbproj).
  5. Modify code so that it can recurse down a tree (see below), and run it.
  6. Open some projects in Visual Studio to ensure no bindings are present.
  7. Copy entire tree to new location like c:\svnload\code
  8. Create an svnimport script - I did this instead of using tortoiseSVN because I wanted to inject \src\trunk into the path, and having 65 directory trees (containing 100’s of actual projects), anything manual was out of the question.
  9. Run the import script – this just imports the files into Subversion – it does not create a working copy folder!
  10. Get the active projects using tortoiseSVN’s Checkout command.

After that, we changed out CruiseControl.net settings to run against Subversion, and our main project was back up and running.

As for why we are bailing on Team System – simple – we found that we simply do not use many of it’s functions. Instead of it’s work item system (or the Scrum add-in from Conchango), we use Rally. Instead of the MS Build Server, we use CruiseControl.net. We did use the SharePoint integration, but nothing beyond what you’d get with a vanilla SharePoint site. We will miss some of the features of MSTest, but NUnit and TestDriven.net are more than capable replacements.

By changing to Subversion, we can down-grade our MSDN licenses to “Professional”, and save ~$5000 per year. This will allow us to purchase some other productivity tools – CodeSmith, ReSharper, TypeMock, TestDriven.net and Red Ants Profiler to name a few.  

FIX: Visual Studio Not Connecting to Team Foundation Server

Posted by Dave Bouwman | Posted in Team System | Posted on 30-10-2007

0

I ran into this problem last week, and it had me stumped for quite a while.

Problem:
I’d start Visual Studio 2005, and try to connect to our Team Foundation Server, but all I would get is a pop-up box stating “Team Foundation Error – object reference not set to an instance of an object”. Boom. All of the sudden I could not connect. Things had been working smoothly the day before, and I could connect on other systems so it was not my credentials.

Non-Fixes:
I tried repairing Visual Studio Team Edition, and the Team Foundation Explorer – neither made any difference, but it did eat 2 hours of time.

What Worked:
As usual Google came through – Dave Donaldson had experienced the same problem, and had written up the solution on his blog.

Turns out the culprit was un-installing the Source Gear Vault client software. We are in the (slow) process of migrating all our source code into SubVersion. At this point we have moved all our code out of our (very) old vault instance. Once that was done, I figured I’d un-install the client as well.

Seems that the uninstall unregisters / changes the registration of a number of IE dlls. Read Dave’s post for more background, but the solution was to re-register the following dlls:

regsvr32 /s urlmon.dll
regsvr32 /s actxprxy.dllregsvr32 /s shdocvw.dllregsvr32 /s mshtml.dllregsvr32 /s browseui.dllregsvr32 /s jscript.dllregsvr32 /s vbscript.dllregsvr32 /s oleaut32.dll

After doing that, things were back to normal. Now I just need to migrate our Team System projects into SubVersion!

Taking the Plunge: Moving to Subversion…

Posted by Dave Bouwman | Posted in Devt Tools, Team System | Posted on 06-08-2007

1

This week I will be transitioning from Microsoft Team System to Subversion for our source control system. There are two main reasons for this change - cost and ease of use.

Cost

The cost issue is two fold – first there is the internal cost of using the Team Editions of Visual Studio. For the MSDN subscription, Team Edition (not Team Suite) runs $1000 more per develper, per year than Visual Studio Professional. While this is not bad for a small team, it’s prohibitive if you are looking at growing significantly, or standardizing across large group. I can think of many useful ways to spend $7,000 per year besides sending it to Microsoft. Not that Team System is not cool and useful, but in the end, I just don’t see it being $7,000 per year cooler than Subversion + TRAC (open source issue/bug tracking system) and that’s the real bottom line – value. 

The second cost aspect is somewhat inverse – if we are using Subversion and an open source build/unit testing/coverage/installer stack, then we can ship this to our clients. Since we build state level enterprise systems, and most of our clients expect to take on the longer term support and maintenance of the system, there is some serious value in being able to turn it all over to them as a comprehensive development platform. If we are on Team System, then it would be doubtful if we could ship the whole stack.

Ease of Use

Since Team System is fully integrated into Visual Studio Team Edition, the user experience for most things is pretty good. Actually I really like the check-in rules you can implement. However, we have had many issues working with web projects, as well as dealing with “other” files such as CodeSmith templates. Of course CodeSmith does not “know” about Team System, so it can’t automatically “check out” the files prior to editing them. Since Team System sets your working copy to read-only when you check in (there may be a way to change this – not sure), in order to make a change to my template, I need to open Visual Studio (slow), connect to Team Server (slow), navigate to the templates in source control, check out the file, make the change, go back to Visual Studio and check in the file again. Compared to working with  Subversion, this is a major pain.

The Transition

At this point we have our Subversion server setup, and our domain accounts are authenticating through Apache. All is well. The next step is at the end of our current Sprint, get the latest code from Team System, do a build, run all the tests, clean the solutions (using Omar Shahine / Jeff Atwood’s Clean Sources) and then load the files into Subversion. I did some Googling for tools which would take the history etc. along for the ride, but I did not find anything. At this point we are early enough in the project where losing history would not be too much of a problem, and we’ll be able to have the Team Server running for at least 6 months incase we really need to get some old version.

Tools

At this point we are planning on using the very well regarded TortoiseSVN as the main client for Subversion, but we’ll also be trying AnkhSVN and VisualSVN to handle the Visual Studio integration. I’ll let you know how those tools pan out.

Debugging ASP.NET Unit Tests on Classes in App_Code

Posted by Dave Bouwman | Posted in ASP.NET, Team System, Unit Testing | Posted on 27-03-2007

0

As if the title of the post is not painful enough, I thought I’d just whip up a quick post for others who have run into issues with getting debugging of ASP.NET unit tests working for classes in App_Code.

Just a quick note – ordinarily I’d create a separate assembly, but part
of this code is working with the ProfileCommon class, which is created
on the fly by ASP.NET based on settings in web.config, and as far as I
could find, you can’t access this class outside of an ASP.NET web app.

So – I’ve created myself some classes and had Visual Studio cook up some unit tests for me. I jumped in there and added some legit code, and went to run the test and… I was not getting an error per se – the break points were simply not being hit. In the border of the code, there was a small icon as shown below…

Mousing over this, I got the highly informative message: “The breakpoint will not currently be hit. No symbols have been loaded for this document”. So the obvious thing you’re thinking is that I need to attach the debugger to the ASP.NET Worker process. Anyhow, that’s what some intensive Googling revealed.

The MSDN guidelines on setting up debugging of ASP.NET Unit Tests is here. And while it is conceptually correct, the only issue is that my version of Visual Studio 2005 (Team Edition) does not have “Attach to Process” on the debug menu (not sure why) . Which led to this article which notes that it may also found at “Tools –> Attach to Process”. Armed with this, I was able to make some headway…

Here are the abridged steps:

  1. Write some classes in App_Code that you want to test
  2. Create a test project, and have it generate the tests – this is critical as it will build private accessors for you.
  3. Attach the VS debugger to aspnet_wp (XP) or w3wp.exe (Windows Svr 2003)
  4. Then run your test from the Test View (Test –> Windows –> Test Viewer)

Even like this, it’s not exactly bomb-proof. I need to re-attach a lot, and start/stop standard debugging of the site occasionally. All the more reason to put your business logic in another assembly if at all possible!

MySpace.com runs ASP.NET

Posted by Dave Bouwman | Posted in .NET, ASP.NET, Team System | Posted on 17-12-2006

0

While we all know that Microsoft/Live/MSN etc are all running on ASP.NET, I was just reading a post on Paul Wilson’s blog, which referred to an earlier post by Scott Guthrie (for those who don’t know, he’s General Manager in Microsoft’s Developer Division) that says MySpace is also running on ASP.NET 2.0.

Here’s a quote regarding scalability (circa March 2006)…

  • MySpace.com is now processing 1.5 Billion page views per day
  • MySpace.com handles 2.3 million concurrent users during the day
  • MySpace.coms average server CPU utilization went from 85% to 27% after moving (from another technology) to ASP.NET 2.0

Since then, MySpace has apparently surpassed Yahoo! in daily page views. In the comments on Paul’s post, we find more interesting news…

One other nice-to-know: They’re actually developing with Visual Studio Team System on top of Team Foundation Server. Not a big deal, but when you consider their all-up continuous integration solution, it definitely speaks to the power and capability of the VSTS/TFS combo.

As a developer working with Microsoft tools, it’s nice to hear about these sorts of things. Now if I could just cook up a site as popular as MySpace… ;-)

Mocking ArcObjects with NMock

Posted by Dave Bouwman | Posted in .NET, ArcGIS Devt, Team System | Posted on 18-09-2006

4

Things are going well with our ArcDAL project (Code Generation + Geodatabase = Goodness), and now that our base class library is pretty solid, I’m adding in unit tests. We want these tests to be run on every build, on any development system, so I want as much separation between the tests and any underlying required resources – for example – ArcSDE instances. Conveniently Scott Hanselman’s podcast from last week was all about using Mock objects in unit testing.

What is a Mock?
Basically, a mock object is a “fake” object that is created solely for the purpose of running a test. It’s generated on the fly using some mocking framework, and you basically tell it what to expect in terms of requests (properties / methods) and what to return. One place where this is really handy is when you want to avoid binding your tests to a specific instance of ArcSDE, or a specific file location for a personal geodatabase. It can also be used to avoid having to make calls out to other ArcObjects if you don’t actually need to.

I’ll go through a simple example to show what I mean…

Example:
Before I go any further, let me say that I’m using Visual Studio 2005, and the MSTest framework, but this will be pretty much the same in VS2003, and/or NUnit.

We’ll look at the tests for a Workspace Utility class…


This class just has 3 very simple shared methods which return information about an IWorkspace. The thing is that in order to test this with real instances IWorkspace, we’d need to actually connect to ArcSDE and a personal geodatabase. And this will make the tests brittle, as it’s unlikely that we’ll keep an instance up for a long time, and file paths will be different on different development machines.

Thus, we use Mock objects to “fake” the workspace. I’ve chosen to use the NMock2 framework for two basic reasons: a) free and b) works.

I’ve gone ahead and had Visual Studio create a set of tests for this class for me. This is a pretty handy feature of VS2005 – it looks at your classes and spits out a basic test harness to use as a starting point.

    ”’<summary>

    ”’A test for IsAccessWorkspace(ByVal ESRI.ArcGIS.Geodatabase.IWorkspace)

    ”’</summary>

    <TestMethod()> _

    Public Sub IsAccessWorkspaceTest()

        Dim workspace As IWorkspace = Nothing

        Dim expected As Boolean

        Dim actual As Boolean

        actual = ArcDAL.WorkspaceUtil.IsAccessWorkspace(workspace)

        Assert.AreEqual(expected, actual, “Did not return the expected value.”)

    End Sub

Now, if we were doing this without mocks, we’d need to actually connect to a personal geodatabase, and pass that into our WorkspaceUtil class. Like this…

    ”’<summary>

    ”’A test for IsAccessWorkspace(ByVal ESRI.ArcGIS.Geodatabase.IWorkspace)

    ”’</summary>

    <TestMethod()> _

    Public Sub IsAccessWorkspaceTest()

        Dim workspacefactory As IWorkspaceFactory = New AccessWorkspaceFactoryClass

        Dim connectionProperties As IPropertySet = New PropertySetClass

        connectionProperties.SetProperty(“DATABASE”, “C:\Test Data\ArcDAL\SampleData.mdb”)

        Dim workspace As IWorkspace = workspacefactory.Open(connectionProperties, 0)

        Dim expected As Boolean

        Dim actual As Boolean

        actual = ArcDAL.WorkspaceUtil.IsAccessWorkspace(workspace)

        Assert.AreEqual(expected, actual, “Did not return the expected value.”)

    End Sub

But, now we have a hardcoded path in the test. Now, we could get crafty, and read the file location from a configuration file, but that’s not the point of this post!

So – to add in Mock objects, add a reference to NMock2 and include/import the NMock2 namespace in your test class. To make things easier, I setup the mock workspace in the ClassStartup method which runs before the tests are executed.

    Private Shared _mockWorkspace As IWorkspace

    ‘Startup

    <ClassInitialize()> _

    Public Shared Sub MyClassInitialize(ByVal testContext As TestContext)

        Dim mocks As New NMock2.Mockery

        _mockWorkspace = CType(mocks.NewMock(GetType(IWorkspace)), IWorkspace)

    End Sub

So – this has created a member variable of type “IWorkspace” which is in reality a mock. At this point we just have a mock, but we tell the mock what to “expect” and how to respond in the tests themselves.

    ”’<summary>

    ”’A test for IsAccessWorkspace(ByVal ESRI.ArcGIS.Geodatabase.IWorkspace)

    ”’</summary>

    <TestMethod()> _

    Public Sub IsAccessWorkspaceTest_Mock()

        Expect.Once.On(_mockWorkspace).GetProperty(“Type”).Will(NMock2.Return.Value(esriWorkspaceType.esriLocalDatabaseWorkspace))             

        Dim workspace As IWorkspace = _mockWorkspace

        Dim expected As Boolean = True

        Dim actual As Boolean

        actual = ArcDAL.WorkspaceUtil.IsAccessWorkspace(workspace)

        Assert.AreEqual(expected, actual, “Did not return the expected value.”)

    End Sub

Hopefully the word-wrap cleans up that line, but it’s pretty simple, and follows a conversational type of logic.

Expect.Once.On(_mockWorkspace).GetProperty(“Type”).Will(NMock2.Return.Value(esriWorkspaceType.esriLocalDatabaseWorkspace))

Translates into:

Expect one call on _mockWorkspace to a Property called Type, Return a value of esriLocalDatabaseWorkspace

Pretty simple. The NMock framework takes care of actually “faking” out the IWorkspace, and then returns the specified value when the request it made. Here’s a shot of the tests in the results viewer. All green!

So, while this is a very simple example of how to use Mock objects with ArcObjects, I’ll be using this same methodology in other places as I add tests through the entire ArcDAL class library. I’m sure that there will be places where Mocks will not work (I suspect IFeature maybe a bit of a bear to mock), but it’s a start.

Spring pace of postings…

Posted by Dave Bouwman | Posted in .NET, ArcGIS Devt, General, Team System | Posted on 18-04-2006

0

Given the drop in GIS interwebs, I guess Spring has come and people, myself included, have better things to do than pecking away at their keyboard in the evening. ;-)

Actually I’ve been crazy busy with my little boy and work. He’s learning to hold his head up, and we’ve just kicked off two more projects at work:

The first is using ArcGIS 9.1 / .NET 2.0 / ArcSDE / Oracle to build a forest managment system, including a Growth and Yeild modelling module (temporal data = fun!). This is in the requirements phase, so it’s all about documentation at
this point. Thus I’m doing conference calls and writing use cases for the next few weeks.

The other is using ArcGIS Server to create a web service to build on-demand pdf maps for a series based on the 1:100k quad sheets. This one is in the design phase, so it’s sequence diagrams, and class models for a week or so.

Once we’re past these two documentation phases – then we’ll be coding, and I’d expect more technical posts.

Beside these projects, we are also switching over to Team System for all our process managment & source control needs, so I’m sure I’ll post some stuff on that. Perhaps tommorrow…

Visual Studio 2003 and Team System Source Control

Posted by Dave Bouwman | Posted in .NET, Software, Team System | Posted on 30-03-2006

0

This is just a quick link dump for anyone looking to use Team System’s source control with Visual Studio 2003.

I know that for our office, we’ll be supporting a number of VS2003/.NET 1.1 apps for quite a while, but we’d like to migrate all our source control to Team Foundation Server.

Vertigo Software has a good blog post about collecting all the parts and pieces and getting it working. The basic steps are:

1) Download the MSSCCI provider for Team System
2) Run a registry hack to get it to work

If you need to access multiple source control systems, then you should check out Soenke Schau’s Sourcecode Control Switcher app

All the details are over at Vertigo’s site.