-
Notifications
You must be signed in to change notification settings - Fork 803
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
CopyRefAssembly Could not extract the MVID from reference assembly #13216
Comments
Yeah, we probably should start emitting it as part of our work of FSharp.Build support of refassemblies. |
Agree. The code in |
The MVIDsection is simply a build performance optimization for dotnet builds. It is not standard and very few if no other tools than copyrefassembly will expect it. It was added to roslyn to simplify the deterministic replacement of assemblies. The PR that added it is here: dotnet/roslyn#19133 We will add the MVID section to F# reference assemblies to ensure that Projects that depend on F# reference assemblies can build and consume them correctly. It should be noted that it is not required for reference assemblies to have this section, merely reference assemblies that are created and consumed during the build. Kevin |
Thanks all for clarifying this. I'd like to take a stab at adding the |
It's just a PE file, there is nothing interesting to learn about doing it. I will do it, since I just suffered through figuring it out for the Arm64 stuff. |
Fine by me 😸, thanks Kevin! |
Ref assembly referencing works fine on the preview4 of net 6.0. It only seems to fail on net 7.0. I suppose that's when the build optimization was introduced. |
Following up on #12334, I've noticed that a project B (csproj) cannot consume a reference assembly of a project A (fsproj) because the
mvid
cannot be read from the assembly.Project structure:
A.fsproj
B.csproj
Expected behavior
dotnet build
ofB.csproj
will find the reference assembly of project A that was specified using therefout
flag.Actual behavior
In the MSBuild log we saw the following:
This warning was logged by
CopyRefAssembly
,https://github.com/dotnet/roslyn/blob/b7838e90db7c7f1de309f8ef314e0aa8bfc6dab1/src/Compilers/Core/MSBuildTask/CopyRefAssembly.cs#L56
The main problem is that the mvid guid is empty.
The current
Number of Sections
inside theCOFF Header
is3
, whereas compared to a C# reference assembly this is4
. The.mvid
section is missing from the F# generation.The MSBuild task uses this section to read that guid.
https://github.com/dotnet/roslyn/blob/b7838e90db7c7f1de309f8ef314e0aa8bfc6dab1/src/Compilers/Core/MSBuildTask/MvidReader.cs#L90-L137
This entire section could be added around
fsharp/src/Compiler/AbstractIL/ilwrite.fs
Lines 3884 to 3886 in 36af364
Similar to
.text, .sdata, .reloc
I would assume. Conditional logic could be implemented usingoptions.referenceAssemblyOnly
.Known workarounds
Besides adding the additional section, it is possible to extract the guid currently from the Module metadata table.
We were able to read it using:
So, from a certain point of view, the
mvid
is there. Just not in the way thatCopyRefAssembly
reads it.Related information
Provide any related information (optional):
//cc @dsyme @vzarytovskii @baronfel @jaredpar
The text was updated successfully, but these errors were encountered: