简体   繁体   中英

Any way to check-in into TFS from FAKE build target?

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.

Using TFS 2010, call FAKE from custom activity.

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

Faced with check-in to TFS issues...

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

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.

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] ) ) 

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 ) ) 

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM