Skip to content

Generate F# assemblyinfo in new fsproj #3113

Description

@enricosada

new fsproj should generate assemblyinfo attributes from props.

ref dotnet/netcorecli-fsc#93

  • in dotnet/sdk is done in the language agnostic target Microsoft.NET.GenerateAssemblyInfo.targets#L93-L96 using the WriteCodeFragment task
  • atm the F# language is not implemented, so doesnt generate the file with attributes
  • the WriteCodeFragment is defined inside Microsoft/msbuild and contains a version with CodeDom and another for coreclr (just doing stringbuilder), and support both c# and vb

As a note i tried to add the F# in the same way as C#/VB, but atm PR was stopped for a design decision
dotnet/msbuild#2132 (comment) /cc @KevinRansom @cartermp

Activity

  1. KevinRansom commented on May 25, 2017

    @KevinRansom
    Contributor

    @enricosada

    To do this for the SDK we can override in our targets file and sdk apps will work fine.

    https://github.com/dotnet/sdk/blob/8204b6b1f3ff2f9717c5d66ab903795271de2e9c/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.GenerateAssemblyInfo.targets#L51

    But we should also send a PR to the dotnet sdk refactoring the current implementation a bit.
    @nguerrera said he would welcome a PR that improved this :-)
    The bit where the attributes are generated should be moved to a new target: GetAssemblyAttributes or some such name.
    And then : CoreGenerateAssemblyInfo just handles the write.
    We can override CoreGenerateAssemblyInfo to write the attributes with a build task added to the Microsoft.FSharp.Build library ... or something.
    Does that make sense?
    Enrico,

    thanks for pushing on this, it's really great that you take the time to dive into all of the stuff.
    Kevin

  2. enricosada commented on May 25, 2017

    @enricosada
    ContributorAuthor

    Does that make sense?

    Yes, didnt know a refactoring effort was needed or ongoing, but is getting better. love to override only what's needed 👍

    Let's wait a bit for new @dasMulli PR ( from dotnet/msbuild#2132 (comment) ) seems that refactoring is in progress already

    There's already dotnet/sdk#1007 which splits the target into _CalculateAssemblyAttributes and CoreGenerateAssemblyInfo but it probably won't land in its current form (see PR discussion. I'll be sending out a PR today for an alternative implementation)

    Meanwhile i'll prepare a task to write the file to be added in Microsoft.FSharp.Build because attrs need escape checks anyway.
    Cannot be done with msbuild target alone afaik, sigh why msbuild property functions are so limited, when i need just a string -> string and some % transformation).

    So as your said we'll need to just override CoreGenerateAssemblyInfo later, i'll PR soon, meanwhile copying the current CoreGenerateAssemblyInfo from sdk to check is everything working ok end2end

  3. KevinRansom commented on May 25, 2017

    @KevinRansom
    Contributor
  4. added
    Impact-High(Internal MS Team use only) Describes an issue with extreme impact on existing code.
    on May 25, 2017
  5. enricosada commented on May 25, 2017

    @enricosada
    ContributorAuthor

    @KevinRansom yes @dasMulli is doing that with dotnet/sdk#1255

    1. _CalculateAssemblyAttributes which creates all AssemblyAttribute items.
    2. _CreateGeneratedAssemblyInfoInputsCacheFile creates an obj/tfm/projectname.AssemblyInfoInputs.cache file containing the hash of all AssemblyAttribute items. This filename is available as $(GeneratedAssemblyInfoInputsCacheFile). The target uses msbuild 15's WriteOnlyWhenDifferent="True" feature for WriteLinesToFile so the file doesn't change unnecessarily.
    3. CoreGenerateAssemblyInfo which generates the projectname.AssemblyInfo.cs file, using the cache file as input for incremental build.

    The _CreateGeneratedAssemblyInfoInputsCacheFile is transparent for us

    we will override just CoreGenerateAssemblyInfo to generate the file from AssemblyAttribute items.
    i'll send a PR for that, you can assign this to me

  6. dasMulli commented on May 26, 2017

    @dasMulli
    <Target Name="CoreGenerateAssemblyInfo"
            DependsOnTargets="CreateGeneratedAssemblyInfoInputsCacheFile"
            Inputs="$(GeneratedAssemblyInfoInputsCacheFile)"
            Outputs="$(GeneratedAssemblyInfoFile)">
    

    Should now do the trick, the $(GeneratedAssemblyInfoInputsCacheFile) input is only to trigger the target on incremental builds if any attribute changes but the file's contents can be ignored.

  7. added this to the milestone on Jun 3, 2017
  8. dsyme commented on Jun 19, 2017

    @dsyme
    Contributor

    @enricosada @KevinRansom Where are we with this - does it have to be done for the SDK work to count as feature complete? thx

  9. dsyme commented on Jun 21, 2017

    @dsyme
    Contributor

    @enricosada @KevinRansom ping... (I'm trying to clarify the status of all the "Urgency Now" bugs)

  10. enricosada commented on Jun 21, 2017

    @enricosada
    ContributorAuthor

    @dsyme i half finished it, i hope one or two days

  11. rmunn commented on Aug 7, 2017

    @rmunn

    I recently found SuaveIO/suave#635 (assembly version should be 2.1.1.0 but is coming out as 0.0.0.0 when built with the dotnet core CLI tools -- when built with the .Net Framework tools or the Mono tools the assembly version is correct). At first I thought that was caused by an incorrect build step in the Suave project. But could that bug possibly be getting caused by this one? If the project is specifying the assembly version, but it's not making it into the DLL because of this bug, that would also explain the symptoms I'm seeing.

    I'm completely lost when it comes to the .NET Core build system at the moment -- too many changes that I haven't been able to find documentation for -- so it's entirely possible that I'm barking up the wrong tree. But the fact that this bug is still open does make me wonder...

  12. dsyme commented on Aug 18, 2017

    @dsyme
    Contributor

    @enricosada @KevinRansom ping... (I'm trying to clarify the status of all the "Urgency Now" bugs)

  13. zvirja commented on Aug 22, 2017

    @zvirja

    @dsyme @enricosada @KevinRansom Thank you guys for working on this one! happy to that I'm not the only one who have spotted it 😉

    I'd say that this is very important (or even critical) issue as it breaks unification between C# and F#. Our solution contains both csproj and fsproj projects and currently I need to handle all fsproj files separately in the build scripts and patch their assembly info files manually.

    Is there any chance that this issue will be resolved in the nearby future, so build scripts could be much simplified?

  14. 65 remaining items

  15. nguerrera commented on May 23, 2019

    @nguerrera

    @dasMulli I believe the issue is that the dll won't have the resources in the first place when compiled with the F# compiler running on .NET Core.

  16. rojepp commented on Jun 20, 2019

    @rojepp
    Contributor

    @dasMulli I still see this issue in 3.0.100-preview6-012264 using dotnet publish/dotnet build.
    Building from VS does work.

    I also wanted to note that passing in version as a property does not work either: dotnet build /p:FileVersion=1.1.0

  17. added a commit that references this issue on Jun 20, 2019
    da881d8
  18. matthid commented on Jun 21, 2019

    @matthid
    Contributor

    I've sent a PR for this, so I hope we can finally get this sorted out. I understand this has low priority but it disturbs me every time I see it and makes it harder for people - especially for newcomers - to figure out version related issues... I have seen this several times

  19. realvictorprm commented on Aug 11, 2019

    @realvictorprm
    Contributor

    So the FileVersion thingy still needs to be fixed if I understand correctly?

  20. nguerrera commented on Aug 11, 2019

    @nguerrera

    I commented on the PR: #7024 (comment)

    It seems there's a misunderstanding about work for managed resources becoming useful for this problem when they are actually separate.

  21. cartermp commented on Aug 21, 2019

    @cartermp
    Contributor

    This might be affecting #7220

  22. added a commit that references this issue on Aug 26, 2019
    c22fa0b
  23. modified the milestones: Backlog, 16.5 on Jan 17, 2020
  24. added a commit that references this issue on Feb 23, 2021
    f225f12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions