在激活独占检出的情况下使用 TFS 时如何使用 F#-Make (FAKE) 覆盖 AssemblyInfo.vb?

How to use F#-Make (FAKE) to override AssemblyInfo.vb when using TFS with exclusive check-out activated?

我正尝试在我们的一个旧项目中采用 FAKE,该项目使用 TFS2013 作为源代码控制,并将独占检出作为检出策略。我为 Clean、Build 和 RunTests 定义了目标,但我被 AssemblyInfo-Target 困住了。我收到以下错误(部分错误消息是德语的,因为我是在德国机器上开发的):

Running build failed.
Error:
System.UnauthorizedAccessException: Der Zugriff auf den Pfad "D:\SourcecodeTFS2013\AD ERP\AD ERP\ERP.PDFUTILITIES\My Project\AssemblyInfo.vb" wurde verweigert.
   bei System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   bei System.IO.FileInfo.Delete()
   bei Fake.AssemblyInfoFile.writeToFile(String outputFileName, IEnumerable`1 lines) in C:\code\fake\src\app\FakeLib\AssemblyInfoFile.fs:Zeile 134.
   bei Fake.AssemblyInfoFile.CreateVisualBasicAssemblyInfoWithConfig(String outputFileName, IEnumerable`1 attributes, AssemblyInfoFileConfig config) in C:\code\fake\src\app\FakeLib\AssemblyInfoFile.fs:Zeile 233.
   bei FSI_0005.Build.clo@47-2.Invoke(Tuple`4 tupledArg) in D:\SourcecodeTFS2013\AD ERP\AD ERP\build.fsx:Zeile 48.
   bei Microsoft.FSharp.Collections.SeqModule.Iterate[T](FSharpFunc`2 action, IEnumerable`1 source)
   bei FSI_0005.Build.clo@27-1.Invoke(Unit _arg2) in D:\SourcecodeTFS2013\AD ERP\AD ERP\build.fsx:Zeile 47.
   bei Fake.TargetHelper.runSingleTarget(TargetTemplate`1 target) in C:\code\fake\src\app\FakeLib\TargetHelper.fs:Zeile 492

这个错误似乎与该项目使用的独占签出策略有关。这就是 AssemblyInfo.vb 文件处于“只读”模式的原因。 FAKE 中是否有可能在生成新的之前检查 AssemblyInfo.vb?

这是我的 "AssemblyInfo"-Target(灵感来自 Forge 项目的 build.fsx 脚本:https://github.com/fsprojects/Forge):

Target "AssemblyInfo" (fun _ ->
        let getAssemblyInfoAttributes projectName =
          [ Attribute.Title (projectName)
            Attribute.Product project
            Attribute.Description summary
            Attribute.Company company
            Attribute.CLSCompliant clsCompliant
            Attribute.Version release.AssemblyVersion
            Attribute.FileVersion release.AssemblyVersion ]

        let getProjectDetails projectPath =
          let projectName = System.IO.Path.GetFileNameWithoutExtension(projectPath)
          ( projectPath,
            projectName,
            System.IO.Path.GetDirectoryName(projectPath),
            (getAssemblyInfoAttributes projectName)
          )

        !! "../**/*.vbproj"
        |> Seq.map getProjectDetails
        |> Seq.iter (fun (projFileName, projectName, folderName, attributes) ->
                      CreateVisualBasicAssemblyInfo ((folderName @@ "My Project") @@ "AssemblyInfo.vb") attributes
                    )
) 

我认为这很相似:Any way to check-in into TFS from FAKE build target?

否则您也可以在创建 assemblyinfo 之前更改文件属性。

我为使用 Paket 更新包做了类似的事情:

https://gist.github.com/magicmonty/858066629b08c0e2e310

看看tfsHelper.fsx