问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/27954563/any-way-to-check-in-into-tfs-from-fake-build-target