简体   繁体   English

使用CreateCSharpAssemblyInfo会抛出错误:FAKE-F#MAKE

[英]Using CreateCSharpAssemblyInfo throws an error : FAKE- F#MAKE

I am using "CreateCSharpAssemblyInfo" function of FAKE for updating AssemblyInfo.cs. 我正在使用FAKE的“CreateCSharpAssemblyInfo”函数来更新AssemblyInfo.cs。 But I am getting error , ie 但是我得到了错误,即

  2) CS0579: Properties\AssemblyInfo.cs: Duplicate 'AssemblyProductAttribute' attribute
  3) CS0579: Properties\AssemblyInfo.cs: Duplicate 'AssemblyCompanyAttribute' attribute
  4) CS0579: Properties\AssemblyInfo.cs: Duplicate 'AssemblyCopyrightAttribute' attribute
  5) CS0579: Properties\AssemblyInfo.cs: Duplicate 'AssemblyVersionAttribute' attribute
  6) CS0579: Properties\AssemblyInfo.cs: Duplicate 'AssemblyFileVersionAttribute' attribute

here is the code that I am using : 这是我正在使用的代码:

let assemblyInfo = [
  Attribute.Title "My Project"
  Attribute.Product "My Product"
  Attribute.Company "XYZ"
  Attribute.Copyright "Copyright XYZ"
  Attribute.Version "14.8"
  Attribute.FileVersion "13.9"
]

Target "BuildApp" (fun _ ->
  CreateCSharpAssemblyInfo  "./Source Code/Project/Properties/AssemblyInfo.cs" assemblyInfo
  !! "/Source Code/Project.sln"
      |> MSBuildReleaseExt buildDir [("SolutionDir", currentPath @@ "\BuildTools")] "Build"
      |> Log "AppBuild-Output:"
)

I am not getting the reason of this error . 我没有得到这个错误的原因。

I'm new to FAKE and have not used F# much, so forgive me if this should be obvious. 我是FAKE的新手并没有多次使用F#,所以请原谅我,如果这应该是显而易见的。

If anyone can help , that would be really helpful. 如果有人可以提供帮助,那将非常有帮助。

Have you tried the CreateCSharpAssemblyInfoWithConfig argument? 您是否尝试过CreateCSharpAssemblyInfoWithConfig参数? It allows for an additional parameter: 它允许一个额外的参数:

CreateCSharpAssemblyInfoWithConfig
        assemblyInfoFile
        attributes
        (AssemblyInfoFileConfig(generateClass=false))

Alternatively, the UpdateAttribute would do a similar thing (in my case all developers work in Visual Studio and it is safe to assume default AssemblyInfo.cs files would be auto-generated). 或者, UpdateAttribute会做类似的事情(在我的情况下,所有开发人员都在Visual Studio中工作,并且可以安全地假设默认的AssemblyInfo.cs文件将自动生成)。 From the doc : 来自doc

Update a set of attributes in an AssemblyInfo file. 更新AssemblyInfo文件中的一组属性。 Fails if any attribute is not found. 如果找不到任何属性,则会失败。

See below example: 见下面的例子:

Target "UpdateAssemblyInfo" (fun _ -> 
    let csProjectDirs =
        !! "**/**/*.csproj"
        |> Seq.map (directory >> directoryInfo)

    let attributes =
        [ 
            Attribute.Title "My Project"
            Attribute.Product "My Product"
            Attribute.Company "XYZ"
            Attribute.Copyright "Copyright XYZ"
         ]
    let applyAssemblyInfo (projDir:DirectoryInfo) = 
        let assemblyInfoFile = projDir.FullName @@ "Properties/AssemblyInfo.cs"
        clearReadOnly assemblyInfoFile
        UpdateAttributes
            assemblyInfoFile
            attributes

    csProjectDirs |> Seq.iter applyAssemblyInfo
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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