我正在编写PowerShell v5脚本来启动基于NAnt的自动构建过程。我还有一个用C#编写的自定义任务(GetLatestFromLabel)。当我在DOS命令窗口中运行构建时,构建成功完成,但是当我从PowerShell v5脚本运行构建过程时,它似乎在将本地Windows文件路径添加到TFS源代码位置。
C:\Windows\sysWOW64\WindowsPowerShell\v1.0\$\AHLTAPrint\AWP 2.x.
以下是我遇到的错误:
SourceControl.GetLatestFromLabel:
[echo] NewFolderVersion = 2.0.0.2
BUILD FAILED
INTERNAL ERROR
Microsoft.TeamFoundation.VersionControl.Client.ItemNotMappedException: There is no working folder mapping for C:\Windows\sysWOW64\WindowsPowerShell\v1.0\$\AHLTAPrint\AWP 2.x.
at Microsoft.TeamFoundation.VersionControl.Client.Client.GetLocalWorkspace(String localPath, Boolean throwIfNotFound)
at AHLTA.NAnt.TFS.Tasks.GetFromLabelTask.ExecuteTask() in c:\Workspaces\Ahltaprint\Build\NAnt.Extensions.Extended\AHLTA.NAnt.TFS.Tasks\Tasks\GetFromLabelTask.cs:line 66
at NAnt.Core.Task.Execute()
at NAnt.Core.Target.Execute()
at NAnt.Core.Project.Execute(String targetName, Boolean forceDependencies)
at NAnt.Core.Task.Execute()
at NAnt.Core.Target.Execute()
at NAnt.Core.Project.Execute(String targetName, Boolean forceDependencies)
at NAnt.Core.Project.Execute()
at NAnt.Core.Project.Run()
这是我的NAnt目标:
<target name="SourceControl.GetLatestFromLabel">
<property name="Private.SourceCodeFoldersfolders" value="$/AHLTAPrint/AWP 2.x" />
<property name="Private.SourceCodeFoldersDelimiter" value="|" />
<echo message="NewFolderVersion = ${NewFolderVersion}" />
<tfsgetfromlabel tfsfolders ="${Private.SourceCodeFoldersfolders}"
labelname="${NewFolderVersion}"
folderdelimiter="${Private.SourceCodeFoldersDelimiter}">
<connectioninformation refid="TFSConnection" />
</tfsgetfromlabel>
</target>
这是自定义任务的执行任务部分:
protected override void ExecuteTask()
{
VersionControlServer vcs = base.TheConnectionInformation.GetVersionControlServer();
if (vcs != null)
{
if (String.IsNullOrEmpty(TheFolderDelimiter))
{
/*** Only one folder ***/
if (!String.IsNullOrEmpty(TheTFSFolders))
{
LabelVersionSpec version = new LabelVersionSpec(TheLabelName);
Workspace ws = vcs.GetWorkspace(TheTFSFolders);
if (ws != null)
{
string[] items = { TheTFSFolders };
GetStatus gs = ws.Get(items, version, RecursionType.Full, GetOptions.Overwrite | GetOptions.GetAll);
}
}
}
else
{
// multiple folders in a string
string[] folders = TheTFSFolders.Split(TheFolderDelimiter.ToCharArray());
LabelVersionSpec version = new LabelVersionSpec(TheLabelName);
for (int i = 0; i < folders.Length; ++i)
{
if (!String.IsNullOrEmpty(folders[i]))
{
Workspace ws = vcs.GetWorkspace(folders[i]);
if (ws != null)
{
string[] items = { folders[i] };
Console.WriteLine("Getting Latest Code in " + items[0].ToString() + " From Label " + version.Label);
GetStatus gs = ws.Get(items, version, RecursionType.Full, GetOptions.Overwrite | GetOptions.GetAll);
}
}
}
}
}
}
知道发生了什么或我如何纠正这个问题?