Skip to content
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

RAR Caches are Broken in .NET 6 Preview 4 #6389

Closed
Forgind opened this issue Apr 29, 2021 · 0 comments · Fixed by #6395
Closed

RAR Caches are Broken in .NET 6 Preview 4 #6389

Forgind opened this issue Apr 29, 2021 · 0 comments · Fixed by #6395

Comments

@Forgind
Copy link
Member

Forgind commented Apr 29, 2021

Issue Description

RAR is slower when using the .NET 6 Preview 4 SDK.

MSBuild caches assembly reference information on behalf of users to make the ResolveAssemblyReference task faster. This caching includes serializing the cache to disk and reading it back if necessary. A change that went into the .NET 6 preview 4 SDK prevented creating strong name key pairs for AssemblyNames. RAR's serialization currently tries to set the KeyPair to null when reading the cache, which fails for that reason. The error is caught and turned into a message, so the user only sees a slower build.

The change (from MSBuild's perspective) that introduced the serialization code was #6094. The change that suppressed the warning (turning it into a message) was #6243.

Steps to Reproduce

Use the .NET 6 Preview 4 SDK to build twice.

Expected Behavior

Correct deserialization of RAR caches and fast RAR execution (for the second build, at least).

Actual Behavior

On the surface, a message (in a diagnostic (maybe normal?) verbosity build log) like:

Could not read state file "obj\Debug\net6.0\cons.csproj.AssemblyReference.cache". Strong-name signing is not supported on this platform. (TaskId:62)

Debugging into it:

Strong-name signing is not supported on this platform.
   at System.Reflection.AssemblyName.set_KeyPair(StrongNameKeyPair value)
   at Microsoft.Build.BackEnd.TranslatorHelpers.Translate(ITranslator translator, AssemblyName& assemblyName) in /_/src/Shared/TranslatorHelpers.cs:line 254
   at Microsoft.Build.Shared.AssemblyNameExtension.Translate(ITranslator translator) in /_/src/Shared/AssemblyNameExtension.cs:line 1021
   at Microsoft.Build.Tasks.SystemState.FileState.<>c.<Translate>b__8_0(ITranslator t) in /_/src/Tasks/SystemState.cs:line 173
   at Microsoft.Build.BackEnd.TranslatorHelpers.Translate[T](ITranslator translator, T& instance, NodePacketValueFactory`1 valueFactory) in /_/src/Shared/TranslatorHelpers.cs:line 38
   at Microsoft.Build.Tasks.SystemState.FileState.Translate(ITranslator translator) in /_/src/Tasks/SystemState.cs:line 174
   at Microsoft.Build.Tasks.SystemState.<>c.<Translate>b__22_0(ITranslator t) in /_/src/Tasks/SystemState.cs:line 331
   at Microsoft.Build.BackEnd.TranslatorHelpers.Translate[T](ITranslator translator, T& instance, NodePacketValueFactory`1 valueFactory) in /_/src/Shared/TranslatorHelpers.cs:line 38
   at Microsoft.Build.BackEnd.TranslatorHelpers.<>c__DisplayClass1_0`1.<AdaptFactory>g__TranslateUsingValueFactory|0(ITranslator translator, T& objectToTranslate) in /_/src/Shared/TranslatorHelpers.cs:line 51
   at Microsoft.Build.BackEnd.BinaryTranslator.BinaryReadTranslator.TranslateDictionary[T](Dictionary`2& dictionary, IEqualityComparer`1 comparer, ObjectTranslator`1 objectTranslator) in /_/src/Shared/BinaryTranslator.cs:line 600
   at Microsoft.Build.BackEnd.TranslatorHelpers.TranslateDictionary[T](ITranslator translator, Dictionary`2& dictionary, IEqualityComparer`1 comparer, NodePacketValueFactory`1 valueFactory) in /_/src/Shared/TranslatorHelpers.cs:line 88
   at Microsoft.Build.Tasks.SystemState.Translate(ITranslator translator) in /_/src/Tasks/SystemState.cs:line 332
   at Microsoft.Build.Tasks.SystemState.DeserializeCacheByTranslator(String stateFile, TaskLoggingHelper log) in /_/src/Tasks/SystemState.cs:line 302

Analysis

Serializing should work fine because nothing is actually being written. Deserializing attempts to set the (StrongName) KeyPair to null, which caused the above exception. It should instead not be set.

I put my fix in #6395

/cc: @rokonec

@Forgind Forgind added bug needs-triage Have yet to determine what bucket this goes in. labels Apr 29, 2021
@Forgind Forgind changed the title Strong-name signing is not supported on .NET 6 RAR Caches are Broken in .NET 6 Preview 4 Apr 30, 2021
@marcpopMSFT marcpopMSFT added this to the 17.0 milestone May 13, 2021
@benvillalobos benvillalobos removed the needs-triage Have yet to determine what bucket this goes in. label May 18, 2021
@Forgind Forgind closed this as completed in c1d3185 Jun 1, 2021
@AR-May AR-May added the triaged label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants