PowerShell 2.0实践(十)管理TFS 2010 (1)
近日工作中设计了一套TFS自定义流程,使用了一些命令行工具,这两天看了看TFS 2010 中的PowerShell支持,特地总结一下,熟练使用这些命令行工具可以完成一些高级任务。
本系列所有脚本均在Windows Server 2008 R2 DataCenter (PowerShell 2.0) + PowerGUI Script Editor Free Edition x64中测试通过。
TFS 2010系列使用了TFS 2010 Ultimate x64、TFS 2010 Power Tools April 2010。
- TFS 2010 新特性(原文地址)
Visual Studio Team Foundation Server 2010
- Work Item Tracking and Project Management
- New MSF templatesfor Agile and CMMI (V 5.0)
- Hierarchical Work Items
- Custom Work Item Link Types
- Ready to use Excel agile project management workbooks for managing your backlogs (including capacity planing)
- Convert Work Item query to an Excel report
- MS Excel integration
- Support for Work Item hierarchies
- Formatting is preserved after doing a 'Refresh'
- MS Project integration
- Hierarchy and successor/predecessor info is now synchronized
- NEW: Test Case Management
- Version Control
- Public Workspaces
- Branch & Merge Visualization
- Tracking of Changesets & Work Items
- Gated Check-In
- Team Build
- Build Controllers and Agents
- Workflow 4-based build process
- NEW: Lab Management (only a pre-release is avaiable at the moment!)
- Project Portal & Reporting
- Dashboards (on SharePoint Portal)
- Burndown Chart
- TFS Web Parts (to show data from TFS)
- Topology enhancements
- Application tier network load balancing (NLB)
- SQL Server scale out
- Improved Sharepoint flexibility
- Report Server flexibility
- Zone support
- Kerberos support
- Separation of TFS and SQL administration
- Setup
- Separate install from configure
- Improved installation wizards
- Optional components
- Simplified account requirements
- Improved Reporting Services configuration
- Setup consolidation
- Upgrading from previous TFS versions
- Improved IIS flexibility
- Administration
- Consolidation of command line tools
- User rename support
- Project Collections
- Archive/restore individual project collections
- Move Team Project Collections
- Server consolidation
- Team Project Collection Split
- Team Project Collection Isolation
- Server request cancellation
- Licensing: TFS server license included in MSDN subscriptions
- TFS 2010体系结构
- TFS 2010对象模型
通过 Team Foundation Server 的对象模型,Team Foundation 的逻辑层可以进行通信,软件集成商及其他公司可以自定义和扩展 Team Foundation Server 功能。
Team Foundation Server 的对象模型是一组包含下列接口的托管 API:
- Team Foundation Framework 服务
- 管理服务
- 事件服务
- 团队项目集合服务
- 注册服务
- 安全性服务
- 位置服务
- 标识管理服务
- 目录服务
- 作业服务
- 属性服务
- 版本控制对象模型
- 工作项跟踪对象模型
- Team Foundation Build 对象模型
- 使用PowerShell管理TFS 2010
4.1、准备工作
要使用PowerShell管理TFS 2010,必须要安装TFS 2010的Power Tools,可以在这里下载。
下载后安装在32位操作系统上没有问题,在64位操作系统下,需要手动修复下注册表。
将下面的代码保存为.reg文件,注意将标记为红色的替换你本机TFS 2010 Power Tools的安装目录:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\PowerShell\1\PowerShellSnapIns\Microsoft.TeamFoundation.PowerShell]
"PowerShellVersion"="2.0"
"Vendor"="Microsoft Corporation"
"Description"="This is a PowerShell snap-in that includes the Team Foundation Server cmdlets."
"VendorIndirect"="Microsoft.TeamFoundation.PowerShell,Microsoft"
"DescriptionIndirect"="Microsoft.TeamFoundation.PowerShell,This is a PowerShell snap-in that includes the Team Foundation Server cmdlets."
"Version"="10.0.0.0"
"ApplicationBase"="E:\\Dotnet\\Microsoft Team Foundation Server 2010 Power Tools"
"AssemblyName"="Microsoft.TeamFoundation.PowerTools.PowerShell, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
"ModuleName"="E:\\Dotnet\\Microsoft Team Foundation Server 2010 Power Tools\\Microsoft.TeamFoundation.PowerTools.PowerShell.dll"
"CustomPSSnapInType"="Microsoft.TeamFoundation.PowerTools.PowerShell.TFPSSnapIn"
在64位系统下,导入该注册表后,就可以添加Snapin了:
Add-PSSnapin Microsoft.TeamFoundation.PowerShell
Snapin是一组.NET程序集,或者程序集集合,其中包含了Cmdlets、提供程序、类型扩展和格式元数据。
查看TFS 2010 Snapin中包含哪些命令:
Get-Command -Module Microsoft.TeamFoundation.PowerShell
运行结果:
4.2、连接TFS 2010
Clear-Host
$ServerUrl = "http://brookspcnb:8080/tfs"
Get-TfsServer -Name $ServerUrl
运行结果:
IIS中照例会有TFS 2010的网站:
TFS 2010 Web Access和2008时类似:
小结:
本次对TFS 2010进行了一次概括,熟悉了下其体系结构与对象模型,搭建了64位操作系统下的开发、测试环境。后续篇章会深入研究TFS 2010的对象模型,测试一下常用的PowerShell命令。我们也可以尝试着扩充一下TFS 2010的PowerShell命令,自己动手开发印象会更加深刻。TFS 2010的改进很大,除了对象模型、体系结构外,TFPT等命令行工具也进行了更新,后面逐一进行测试。