Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1051139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:52:59+00:00 2026-05-16T16:52:59+00:00

Summary I currently have a NAnt build script that performs a vssget on either

  • 0

Summary
I currently have a NAnt build script that performs a vssget on either the latest source code, or a specific branch (using a ${branch} parameter).

Whenever we do a production build/deployment the code-tree that was built has a branch created, (so that we can continue development and still know what codebase is on production, pretty standard stuff…)

Problem
The process of creation of that branch is still a manual one, performed by someone going into Visual Source Safe Explorer and performing the branching procedure. I was wondering if there is any way in NAnt of creating a VSS branch.

Current Plan
I already know about using <exec program="ss"> and am trying to avoid that, but in the absence of any better solutions, that is the most probable route I will take.

Does anyone know if there is a NAnt or NAntContrib target for this, or if anyone has a script task that they have used to do this in the past and could provide the code for that, that would be very much appreciated.

Disclaimer
I know about cvs, svn, git and all the other Source Control solutions, and to change the tool is not an option at present

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:53:00+00:00Added an answer on May 16, 2026 at 4:53 pm

    We actually need this where I work. I whipped together a small task called ‘vssbranch’ (not particularly creative but here is the code…an example build file and the output of its execution:

    CODE:

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Text;
    
    using SourceSafeTypeLib;
    
    using NAnt.Core;
    using NAnt.Core.Attributes;
    
    namespace NAnt.Contrib.Tasks.SourceSafe
    {
        [TaskName("vssbranch")]
        public sealed class BranchTask : BaseTask
        {
            /// <summary>
            /// The label comment.
            /// </summary>
            [TaskAttribute("comment")]
            public String Comment { get; set; }
    
            /// <summary>
            /// Determines whether to perform the branch recursively.
            /// The default is <see langword="true"/>
            /// </summary>
            [TaskAttribute("recursive"),
            BooleanValidator()]
            public Boolean Recursive { get; set; }
    
            [TaskAttribute("branchname", Required = true)]
            public String BranchName { get; set; }
    
    
            protected override void ExecuteTask()
            {
                this.Open();
                try
                {
                    if (VSSItemType.VSSITEM_PROJECT != (VSSItemType)this.Item.Type)
                        throw new BuildException("Only vss projects can be branched", this.Location);
    
                    IVSSItem newShare = null;
                    this.Comment = String.IsNullOrEmpty(this.Comment) ? String.Empty : this.Comment;
                    if (null != this.Item.Parent)
                        newShare = this.Item.Parent.NewSubproject(this.BranchName, this.Comment);
    
                    if (null != newShare)
                    {
                        newShare.Share(this.Item as VSSItem, this.Comment,
                            (this.Recursive) ?
                                (int)VSSFlags.VSSFLAG_RECURSYES : 0);
                        foreach (IVSSItem item in newShare.get_Items(false))
                            this.BranchItem(item, this.Recursive);
                    }
                }
                catch (Exception ex)
                {
                    throw new BuildException(String.Format("Failed to branch '{0}' to '{1}'", this.Item.Name, this.BranchName), this.Location, ex);
                }
            }
    
            private void BranchItem(IVSSItem itemToBranch, Boolean recursive)
            {
                if (null == itemToBranch) return;
    
                if (this.Verbose)
                    this.Log(Level.Info, String.Format("Branching {0} path: {1}", itemToBranch.Name, itemToBranch.Spec));
    
                if (VSSItemType.VSSITEM_FILE == (VSSItemType)itemToBranch.Type)
                    itemToBranch.Branch(this.Comment, 0);
                else if (recursive)
                {
                    foreach (IVSSItem item in itemToBranch.get_Items(false))
                        this.BranchItem(item, recursive);
                }
            }
        }
    }
    

    BUILD FILE:

            <echo message="About to execute: VSS Branch" />
    
            <echo message="Source Safe Path: ${SourceSafeRootPath}/${CURRENT_FILE}" />
    
            <vssbranch
                  username="my_user_name"
                  password="my_password"
                  recursive="true"
                  comment="attempt to make a branch"
                  branchname="test-branch"
                  dbpath="${SourceSafeDBPath}"
                  path="${SourceSafeRootPath}/${CURRENT_FILE}"
                  verbose="true"
                />
    
        </foreach>
    </target>
    

    OUTPUT:

    NAnt 0.85 (Build 0.85.2478.0; release; 10/14/2006)
    Copyright (C) 2001-2006 Gerry Shaw
    http://nant.sourceforge.net

    Buildfile: file:///C:/scm/custom/src/VssBranch/bin/Debug/test.build
    Target framework: Microsoft .NET Framework 2.0
    Target(s) specified: run

    run:

    [loadtasks] Scanning assembly “NAnt.Contrib.Tasks” for extensions.
    [loadtasks] Scanning assembly “VssBranch” for extensions.
    [echo] About to execute: VSS Branch

    ….

    [vssbranch] Branching SecurityProto path: $/VSS/Endur’s Source/C#/DailyLive/proto/test-branch/SecurityProto

    ….

    BUILD SUCCEEDED

    Total time: 12.9 seconds.

    Obviously the output would vary, I was pulling in the items to branch from a text file named ‘params.txt’. This task performs what is known in the VSS world as ‘Share and Branch’ (Branching immediately after Sharing)…other source control systems do not need to share before branching, eh…that’s for another day

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.