摘要
我目前有一个NAnt构建脚本,它可以对最新的源代码或特定的分支(使用${branch}参数)执行vssget。
每当我们进行生产构建/部署时,生成的代码树都有一个分支创建,(这样我们就可以继续开发,并且仍然知道生产中的代码基是什么,非常标准的东西…)
问题
创建该分支的过程仍然是手动的,由进入并执行分支过程的人执行。我想知道在NAnt中是否有任何创建VSS分支的方法。
当前计划
我已经知道如何使用<exec program="ss">,并试图避免这种情况,但在没有任何更好的解决方案的情况下,这是我最可能采取的方法。
是否有人知道是否有一个NAnt或NAntContrib目标,或者是否有人有一个脚本任务,他们过去曾这样做,并可以提供代码,这将是非常感谢的。
免责声明
我知道cvs、svn、git和所有其他源代码管理解决方案,而改变这个工具目前还不是一种选择
发布于 2010-08-25 00:37:50
在我工作的地方我们真的需要这个。我把一个名为‘vss支’的小任务组合在一起(不是特别有创意,但这里是code...an示例构建文件及其执行的输出:
代码:
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);
}
}
}
}生成文件:
<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>
产出:
NAnt 0.85 (Build0.85.2478.0;release;10/14/2006)版权(C) 2001-2006年Gerry http://nant.sourceforge.net
构建文件: file:///C:/scm/custom/src/VssBranch/bin/Debug/test.build目标框架:指定的MicrosoftWebFramework2.0目标:运行
跑:
加载任务扫描程序集"NAnt.Contrib.Tasks“的扩展。加载任务扫描程序集"VssBranch“的扩展。即将执行的回波: VSS分支
……
分支Source/C#/DailyLive/proto/test-branch/SecurityProto路径:$/VSS/Endur的SecurityProto路径
……
建设成功
总时间: 12.9秒。
很明显,输出是不同的,我是从一个名为‘pars.txt’的文本文件中提取条目来分支的。这个任务在VSS世界中被称为“共享和分支”(共享后立即分支)...other源代码管理系统在分支之前不需要共享,嗯.这是另一天
发布于 2010-08-20 10:41:49
vss任务驻留在NAntContrib项目中,而不是,目前没有支持分支的任务。不过,按照NAntContrib中现有vss任务(添加、签出、签出等)的模型,您可以自己对其进行抓取源和扩展。也就是说,如果 VSS支持分支,则为。
https://stackoverflow.com/questions/3524256
复制相似问题