TFS 2010跟踪构建定义更改?

时间:2013-08-21 19:27:05

标签: visual-studio msbuild tfs2010 team-explorer build-definition

有没有办法在TFS 2010中跟踪构建定义的更改?请转到'团队资源管理器> ProjectName>建立视觉工作室,看看我在说什么。您需要访问TFS服务器才能看到我所指的内容。现在,一旦你进入团队资源管理器> ProjectName>构建时,您可以创建构建定义以在TFS上编译csproj或sln文件。我想知道的是,如果我对现有构建定义进行任何更改或添加新构建定义,有没有办法对这些构建定义进行版本化?

3 个答案:

答案 0 :(得分:2)

当团队成员修改了构建定义时,我遇到了同样的问题,我试图找到所有可用的选项,但除了Xeam Build Definition Extension之外没有找到任何一个,只支持VS 2012以后并且有一些缺点,所以最后为了立即解决问题,我编写了一个小应用程序,它返回Last Modified ByLast Modified Date以及完整的Build Definition详细信息,您可以将这些信息与之前的版本进行比较,以查找更改内容。

导入Microsoft.TeamFoundation.Build.Client

Private Const RootFolder As String = "C:\TFS Utility Reports\"

    ''' <summary>
    ''' To Get the Build Definition Details
    ''' </summary>
    ''' <param name="teamProjectName"></param>
    ''' <param name="buildDefinitionName"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function GetBuildDefinitionDetails(teamProjectName As String, buildDefinitionName As String) As String
        Dim buildDefinitionSummary As String = Nothing
        Dim buildDefinitionDetails As String = Nothing
        Dim reportPath As String = RootFolder & "Build Definitions\" & buildDefinitionName
        Dim buildDefinitionDetailsFileName As String = reportPath & "\" & buildDefinitionName & "_" & Date.Now.ToString(CultureInfo.CurrentCulture).Replace("/", String.Empty).Replace(":", String.Empty) & ".txt"
        Dim buildService = CType(TfsTeamProjectCollection.GetService(GetType(IBuildServer)), IBuildServer)
        Dim buildDefinition As IBuildDefinition = buildService.GetBuildDefinition(teamProjectName, buildDefinitionName)
        If buildDefinition IsNot Nothing Then
            GetAllBuildDefinitions(teamProjectName)
            buildDefinitionSummary = buildDefinition.ToString()
            UpdateFile(buildDefinitionSummary, buildDefinitionDetailsFileName, reportPath)
            If buildDefinition.Workspace IsNot Nothing Then
                buildDefinitionDetails = String.Format(CultureInfo.CurrentCulture, "Last Modified By: {0}, Last Modified Date: {1}",
                                                                                                    buildDefinition.Workspace.LastModifiedBy,
                                                                                                    buildDefinition.Workspace.LastModifiedDate)
            End If
        End If
        Return buildDefinitionDetails
    End Function


    ''' <summary>
    ''' Generate Log/Summary/Report
    ''' </summary>
    ''' <param name="lineToWrite"></param>
    ''' <param name="filePath"></param>
    ''' <param name="folderPath"></param>
    ''' <remarks></remarks>
    Private Shared Sub UpdateFile(ByVal lineToWrite As String, ByVal filePath As String, ByVal folderPath As String)
        Dim strFileName As String = String.Empty
        lineToWrite = lineToWrite.Trim()
        strFileName = filePath
        Dim di As IO.DirectoryInfo = New IO.DirectoryInfo(folderPath)
        If Not di.Exists Then
            di.Create()
        End If
        Dim streamWriter As New StreamWriter(strFileName, True, System.Text.Encoding.ASCII)
        Try
            Dim strOutput As String
            strOutput = lineToWrite.ToString
            streamWriter.WriteLine(strOutput)
        Catch ex As Exception
            Throw
        Finally
            streamWriter.Dispose()
        End Try
    End Sub

答案 1 :(得分:1)

无法跟踪构建定义的更改。如果您需要构建多个分支/版本,我建议创建不同的构建定义。

在对构建进行排队时可以设置一些属性,因此如果您希望CI构建不将其输出复制到删除服务器,则可以使用,但是如果要部署版本,则可以在对构建进行排队时设置一个drop文件夹。

TFS Power Toys中,您将获得“克隆构建定义”上下文菜单,以便在您希望保持相似的许多设置时更轻松地复制构建。

答案 2 :(得分:0)

有一种方法。 vsgallery中有这个工具:

http://visualstudiogallery.msdn.microsoft.com/ec36f618-d122-48a3-8236-7d9cd19791ee

我在tfs2012上使用它。我不知道它是否适用于tfs2010