仅从工作区下载所需的解决方案 [英] Download only required solutions from workspace
本文介绍了仅从工作区下载所需的解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一段代码,它以编程方式设置工作空间并从 tfs 工作空间下载文件.我想扩展以指定我可以在该工作空间中下载哪些解决方案.我有什么想法可以做到这一点吗?
I have a piece of code that sets up a work space and download files from tfs work space programmatically. I want to extend to specify what solutions can I download in that work space. Any ideas how I can do this?
private GetStatus DownloadLatestFiles()
{
Workspace workspace = null;
try
{
workspace = SetupWorkSpace();
workspace.Map(_repositoryCredentials.RepositoryProjectPath, _repositoryCredentials.WorkingDirectory);
GetRequest request = new GetRequest(new ItemSpec(_repositoryCredentials.RepositoryProjectPath, RecursionType.Full), VersionSpec.Latest);
return workspace.Get(request, GetOptions.GetAll | GetOptions.Overwrite);
}
catch
{
throw;
}
}
private Workspace SetupWorkSpace()
{
VersionControlServer sourceControl = SetupVersionControlRepositoryConnection();
Workspace workspace = sourceControl.QueryWorkspaces(
Environment.MachineName,
sourceControl.AuthorizedUser,
Environment.MachineName).SingleOrDefault();
if (workspace == null)
{
workspace = sourceControl.CreateWorkspace(Environment.MachineName, sourceControl.AuthenticatedUser, "newworkspace");
}
return workspace;
}
我进行了更改,所以现在显示...
I made a change so now it shows...
private GetStatus DownloadLatestFiles()
{
Workspace workspace = null;
GetStatus status = null;
try
{
workspace = SetupWorkSpace();
List<Solution> services = _serviceList.GetAll();
foreach (Solution solution in services)
{
WorkingFolder workingFolder = new WorkingFolder(ConvertLocalToTfsPath(solution), GetSolutionFolder(solution));
workspace.CreateMapping(workingFolder);
//GetRequest request = new GetRequest(new ItemSpec(_repositoryCredentials.RepositoryProjectPath, RecursionType.Full), VersionSpec.Latest);
//status = workspace.Get(request, GetOptions.GetAll | GetOptions.Overwrite);
status = workspace.Get();
}
}
catch
{
throw;
}
return status;
}
目前仍在下载所有文件.
Currently still downloads all files.
推荐答案
我找到了答案.只是对上述答案的一点点改编.
I found the answer. Just a little bit of an adaption from what the above answer.
private List<GetStatus> DownloadLatestFiles()
{
Workspace workspace = null;
List<GetStatus> statusResult = new List<GetStatus>();
try
{
workspace = SetupWorkSpace();
List<Solution> services = _serviceList.GetAll();
foreach (Solution solution in services)
{
WorkingFolder workingFolder = new WorkingFolder(ConvertLocalToTfsPath(solution), GetSolutionFolder(solution));
workspace.CreateMapping(workingFolder);
GetRequest request = new GetRequest(new ItemSpec(ConvertLocalToTfsPath(solution), RecursionType.Full), VersionSpec.Latest);
statusResult.Add(workspace.Get(request, GetOptions.GetAll | GetOptions.Overwrite));
}
}
catch
{
throw;
}
return statusResult;
}
这篇关于仅从工作区下载所需的解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文