Geeks With Blogs
Drewby Made from 60% post-consumer recycled fiber.

I've been trying to get CruiseControl.NET to work with PVCS and finally found the source of my headaches. If you are not familiar with CruiseControl.NET, it is a continous integration tool from ThoughtWorks. It monitors your source code control database or file-based repository for changes and launches your build process whenever changes are detected. Its great for projects with many developers that are creating code that needs to frequently be fit together and tested.

CruiseControl.NET is a cinch to setup for most source control providers, but I really got frustrated with PVCS. The source of my problem was that we use UNC paths to access our PVCS database. CruiseControl.NET generates and executes a PCLI script file to query the database for changes. The first step in that script file is to generate a list of the archive files in the database. The second step reads the file list and generates a statistics report for any files that have changed. Ok, simple enough.

The command that is inserted into that PCLI file outputs lines in the file list that look like the following:

"\\servername\share\filepath\filename.cs.arc(C:\workspace\filepath\filename.cs)"

The first part of that line is the location in PVCS. The second part is the work location on your machine where you have a local copy of that file. When I ran this script, I'd get errors from PVCS that said it couldn't locate the file "\servername\share\filepath".

I found a section in the PCLI online manual that talks about UNC paths. It states that the tools that read in the list file expect a UNC path to have an additional backslash (\) preceding the line. It also provides script to output a file with the correct UNC paths. I took that script, refined it a bit and updated the CruiseControl.NET code to support UNC paths. If you are having a similar issue, you can try making the following modifications to the source:
  1. Locate the file project\core\sourcecontrol\pvcs.cs.
  2. Near the top of the file is a constant called INSTRUCTIONS_TEMPLATE.
  3. Change this constant to the following:
    const string INSTRUCTIONS_TEMPLATE = 
    @"set -vPCLI_PR ""{0}""
    set -vPCLI_PP ""{1}""
    set -vi 0
    for file in $[listversionedfiles -a -z]
    {{
        if test ""$file"" = ""\\*""
        {{
            set -vfile ""\$file""
        }}
        set -a -i$i -vGetList '""'""$file""'""'            
        calc -vi $i+1
    }}
    run -ns ->{2} echo -ns $GetList[]
    run -e vlog  ""-xo+e{3}"" '-d{4}*{5}' ""@{2}""
    ";
    
  4. You'll also have to update the test in project\core\sourcecontrol\test\PvcsTest.cs:
    private string CreateExpectedContents() 
    {
          return 
                     @"set -vPCLI_PR ""fooproject""
    set -vPCLI_PP ""barsub""
    set -vi 0
    for file in $[listversionedfiles -a -z]
    {
        if test ""$file"" = ""\\*""
        {
            set -vfile ""\$file""
        }
        set -a -i$i -vGetList '""'""$file""'""'            
        calc -vi $i+1
    }
    run -ns ->pvcstemp.txt echo -ns $GetList[]
    run -e vlog  ""-xo+epvcsout.txt"" '-dbeforedate*afterdate' ""@pvcstemp.txt""
    ";
    }
    
  5. In the project directory is command file called b.bat you can execute to rebuild the project. You should now have a ccnet server and service that support UNC paths with PVCS.
The configuration file (ccnet.config) needs to be changed a little to support the new PCLI script. Instead of preceding the value in the project element with a -pr, simply put the unc path in this element:
<sourcecontrol type="pvcs">
    <executable>C:\Program Files\Merant\vm\win32\bin\pcli.exe</executable>
    <project>\\servername\share\project</project>
    <subproject>/NiSource.LDC</subproject>
</sourcecontrol>

We are using v8.0.0.3. I don't know if these changes still work with non-UNC paths or if it works with earlier versions of PVCS.

Posted on Thursday, September 30, 2004 11:47 PM .NET | Back to top

Copyright © Drew Robbins | Powered by: GeeksWithBlogs.net