在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
#region 获取最新版本 /// <summary> /// 获取最新版本 /// </summary> /// <param name="server_url">http://192.168.3.202:8080/tfs/projectcollection_single</param> /// <param name="server_path">$/TP_publish/WebSln_Test_For_Publish/WebTest</param> /// <param name="loacl_path">E:\Tfs\Project_Collection_Single</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public static bool GetLastVersionByPath(string server_url, string loacl_path) { var teamProjects = new TfsTeamProjectCollection(new Uri(server_url)); var teamVersion = teamProjects.GetService<VersionControlServer>(); //Workspace workspace = teamVersion.GetWorkspace(loacl_path); var workspace = teamVersion.GetWorkspace(System.Net.Dns.GetHostName(), teamVersion.AuthorizedUser);//参数1 工作区名称,默认电脑名称 workspace.Get(); return true; } #endregion #region 获取集合 解决方案 项目 public void Init() { Uri tfsUri = new Uri(this.TfsUrl); //TFS配置服务获取所有项目的名称和所有的团队集合名称 TfsConfigurationServer configserver = TfsConfigurationServerFactory.GetConfigurationServer(tfsUri); ReadOnlyCollection<CatalogNode> collectNodes = configserver.CatalogNode.QueryChildren(new[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None); this.Collotion = new List<Model.Collotion>(); foreach (CatalogNode collect in collectNodes) { Guid collectid = new Guid(collect.Resource.Properties["InstanceId"]); TfsTeamProjectCollection teamproject = configserver.GetTeamProjectCollection(collectid); var collotion = new Model.Collotion()//集合 { Name = collect.Resource.DisplayName, Path = teamproject.Uri.Host + "\\" + collect.Resource.DisplayName, Url = teamproject.Uri.ToString(), Solution = new List<Model.Solution>() }; var teamVersion = teamproject.GetService<VersionControlServer>(); var workspace = teamVersion.GetWorkspace(Dns.GetHostName(), teamVersion.AuthorizedUser); var folders = workspace.Folders; foreach (var folder in folders) { var items = teamVersion.GetItems(folder.ServerItem, RecursionType.Full).Items; var arr = items.Where(ex => ex.ServerItem.EndsWith(".sln")).ToList(); foreach (var item in arr)//解决方案 { if (teamVersion.GetItems(item.ServerItem.Substring(0, item.ServerItem.LastIndexOf("/")), RecursionType.Full).Items.Where(ex => ex.ServerItem.EndsWith("Web.config")).Count() > 0) { var solution = new Model.Solution() { Name = Path.GetFileName(item.ServerItem), Path = item.ServerItem, Url = collotion.Url, Project = new List<Model.Project>() }; var dirPath = System.IO.Path.GetDirectoryName(item.ServerItem).Replace("\\", "/") + "/"; var projects = items.Where(ex => ex.ServerItem.StartsWith(dirPath) && ex.ServerItem.EndsWith(".csproj")).ToList(); foreach (var project in projects)//项目 { if (teamVersion.GetItems(project.ServerItem.Substring(0, project.ServerItem.LastIndexOf("/")), RecursionType.Full).Items.Where(ex => ex.ServerItem.EndsWith("Web.config")).Count() > 0) { solution.Project.Add(new Model.Project() { Name = Path.GetFileName(project.ServerItem), Path = project.ServerItem, Url = collotion.Url, mappingPath = workspace.GetWorkingFolderForServerItem(project.ServerItem).LocalItem }); } } collotion.Solution.Add(solution); } } } Collotion.Add(collotion); } } #endregion 代码下载: 没找到上传文件的地方:qq 674613047 |
请发表评论