有什么方法可以从FAKE构建目标中签入TFS? [英] Any way to check-in into TFS from FAKE build target?

查看:72
本文介绍了有什么方法可以从FAKE构建目标中签入TFS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建FAKE(F#Make)构建目标,该目标将在成功构建后更新项目中的AssemblyInfo文件.版本信息文件存储在TFS CVS中,因此我需要从FAKE构建任务中将更新的文件检入到TFS中.

I'm trying to create FAKE(F# Make) build target that will update AssemblyInfo files in my project after sucsess build. Version info files are stored in TFS CVS, so I need to checkin updated files to TFS from FAKE build task.

使用TFS 2010,从自定义活动中调用FAKE.

Using TFS 2010, call FAKE from custom activity.

我的流程是: -...清理,调用构建目标 -更新AssemblyInfo文件 -将文件检入到TFS

My flow is: - ... cleanup, call build target - Update AssemblyInfo files - Check-in files to TFS

面对签入TFS问题...

Faced with check-in to TFS issues...

有什么方法可以从FAKE(F#Make)目标中签入TFS?

Is there any way to check-in to TFS from FAKE (F# Make) target?

推荐答案

是的,但这分为两部分.此外,这适用于TFS 2015新的Build Definitions和TFS Git存储库.您可以根据需要修改此值以适合您的特定情况.您可以根据需要调用这两个目标.

Yes, but this will come in two parts. Also, this is working for TFS 2015 new Build Definitions and TFS Git repository. You can modify this as necessary to fit your particular situation. These two targets can be called as you wish.

第一部分-更新AssemblyInfo文件

Part I - Update the AssemblyInfo files

let AssemblyInfoFiles = !! @"src\**\AssemblyInfo.cs";
Target "SetVersions" (fun _ ->
  AssemblyInfoFiles
  |> Seq.iter (fun a ->
                  if tfBuildNumber <> null then
                    if isLocalBuild = false then
                      UpdateAttributes a [ Attribute.FileVersion tfBuildNumber]
              )
)

第二部分-检入修改后的AssemblyInfo文件

Part II - Check in the modified AssemblyInfo file(s)

let CheckInMessage = "Files related to versioning where checked in.  ***NO_CI***"
let tfBuildSourceBranchName =  environVar "BUILD_SOURCEBRANCHNAME"
let tfBuilderRepositoryProvider = environVar "BUILD_REPOSITORY_PROVIDER"
Target "CheckinFiles" (fun _ ->
  AssemblyInfoFiles
  |> Seq.iter (fun a ->
          //This is for GIT REPOSITORY in TFS 2015 Build Definition
          if isLocalBuild = false &&  tfBuilderRepositoryProvider = "TfsGit" then
            checkoutBranch solutionDir tfBuildSourceBranchName
            trace ("File to stage: " + a)
            StageFile solutionDir a |> ignore
            Commit solutionDir CheckInMessage
            pull solutionDir "origin" tfBuildSourceBranchName
            push solutionDir
          )
)

第二部分的问题是它对EACH AssemblyInfo进行了提交,而我想将它们分批提交到一个提交中.我可以做到,我只是懒于修复它.

The problem with Part II is that it does a commit for EACH AssemblyInfo, whereas I would like to batch these in one single commit. I can do that, I'm just lazy to fix it.

这篇关于有什么方法可以从FAKE构建目标中签入TFS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆