-
Notifications
You must be signed in to change notification settings - Fork 652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GitVersionTask does not work correctly with fsharp projects building an exe. #1831
Comments
I might be missing something here but I think.. What is needed here is that the gitversion__.fs is placed first in the list of fs files to compile. F# Does not like any file to exist after the Program.fs file. It doesn't make sense to place it in the project file but how could one make it appear first in the list of files to be sent to the compiler? |
Yay, I found the cause of the problem and a workaround! <ItemGroup>
<Compile Include="$(AssemblyInfoTempFilePath)" />
</ItemGroup>
<!-- and -->
<ItemGroup>
<Compile Include="$(GitVersionInformationFilePath)" />
<FileWrites Include="$(GitVersionInformationFilePath)" />
</ItemGroup> This appends these two files to the list of files to be compiled. Since F# requires that the Workaround <ItemGroup>
<Compile Include="SomeFunctions.fs" />
<Compile Include="Program.fs" />
</ItemGroup>
<Target Name="GitVersionInfoBeforeEntryPointFileWorkaround"
AfterTargets="GenerateGitVersionInformation;UpdateAssemblyInfo"
DependsOnTargets="GenerateGitVersionInformation;UpdateAssemblyInfo">
<ItemGroup>
<Compile Remove="Program.fs" />
<Compile Include="Program.fs" />
</ItemGroup>
</Target> |
That's great, @da9l! Is there something that can be adjusted in GitVersion to make this experience better out of the box? If you have ideas, we would love a PR. |
Yeah, I've got some ideas. I'll get back with them. Hopefully in a PR.
Den tors 31 okt. 2019 22:51Asbjørn Ulsberg <[email protected]> skrev:
… That's great, @da9l <https://github.com/da9l>! Is there something that
can be adjusted in GitVersion to make this experience better out of the
box? If you have ideas, we would love a PR.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1831?email_source=notifications&email_token=AABD23JQM2CK2TUSB36EBC3QRNHOVA5CNFSM4I3FI562YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECZLSUI#issuecomment-548583761>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABD23PU2KNBCGXRWM57P2LQRNHOVANCNFSM4I3FI56Q>
.
|
Basically, in f# exe projects the include of the last fs file in project
need to be included after gv generated gitversioninformation and assembly
info.
Not sure how it's best done but I have a few ideas.
/D
Den fre 1 nov. 2019 08:23daniel hegner <[email protected]> skrev:
… Yeah, I've got some ideas. I'll get back with them. Hopefully in a PR.
Den tors 31 okt. 2019 22:51Asbjørn Ulsberg ***@***.***>
skrev:
> That's great, @da9l <https://github.com/da9l>! Is there something that
> can be adjusted in GitVersion to make this experience better out of the
> box? If you have ideas, we would love a PR.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#1831?email_source=notifications&email_token=AABD23JQM2CK2TUSB36EBC3QRNHOVA5CNFSM4I3FI562YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECZLSUI#issuecomment-548583761>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AABD23PU2KNBCGXRWM57P2LQRNHOVANCNFSM4I3FI56Q>
> .
>
|
Hey, I've seen this issue on Twitter and thought I'd chime in. The .NET SDK generates an assembly info file for F# projects by default, too, but it doesn't add the newly generated file as an |
Wow! I really didn't know that. Thanks! |
@asbjornu do you think it would be a good idea to always add the gitversion generated files as CompileBefore? Regardless of the language? |
Ok, some searching tells me this is a F# thing. |
For anyone following this, I've made some progress but it's not complete. I've made the I'm testing it in this repo: https://github.com/da9l/testgitversiontask4fsexe |
Blergh. I've managed to make dotnet build on fsproj to behave nicely when gitversiontask is included. nuget packages are being generated with nice versions. I'm however unable to get version info into the assemblies. Doing some searching this seems to be a problem with the F# dotnet core compiler that it can't make this work atm. dotnet/fsharp#7220 It should work with Visual Studio 2019. |
Keep in mind that this dialog doesn't show the actual attribute values. .NET assemblies carry some Windows specific resources, which is what the "Properties" dialog shows. You can check the assembly with the IL Disassembler. If it has the |
Perhaps the presence of |
@inosik I tried to view the dll using ildasm and it shows
Don't know if that counts. |
Note to anyone looking for this: |
Thanks!
|
When adding the GitVersionTask to a fsharp fsproj that build an exe one get this error message when running
dotnet build
My best guess is that the generated GitVersionInformation.fs file is placed last in the list of files to compile. The Program.fs containing the decorated main function must always be last. See below for details.
Shortest steps to reproduce:
If one run with
dotnet build --verbosity detailed
one can find the following input to the fsc compiler (redacted for clarity). Notice the order of the files in the end.Same error with both SDK 2.2.300 and 3.0.100
The text was updated successfully, but these errors were encountered: