roslyn-sdk
roslyn-sdk copied to clipboard
Update NuGetApiVersion to 5.11.0 to fix big-endian bug
The LibraryImportGenerator.Unit.Tests test case in the runtime repository currently fails on linux-s390x (a big-endian platform) with the following exception thrown out of NuGet, which is being called by Microsoft.CodeAnalysis.Analyzer.Testing to download a package:
NuGet.Protocol.Core.Types.FatalProtocolException : Error downloading 'Microsoft.NETFramework.ReferenceAssemblies.net48.1.0.2' from 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/45bacae2-5efb-47c8-91e5-8ec20c22b4f8/nuget/v3/flat2/microsoft.netframework.referenceassemblies.net48/1.0.2/microsoft.netframework.referenceassemblies.net48.1.0.2.nupkg'.
---- System.IO.InvalidDataException : Byte signature not found in package archive: 0x06054B50
Stack Trace:
at NuGet.Protocol.GetDownloadResultUtility.GetDownloadResultAsync(HttpSource client, PackageIdentity identity, Uri uri, PackageDownloadContext downloadContext, String globalPackagesFolder, ILogger logger, CancellationToken token)
at NuGet.Protocol.DownloadResourceV3.GetDownloadResourceResultAsync(PackageIdentity identity, PackageDownloadContext downloadContext, String globalPackagesFolder, ILogger logger, CancellationToken token)
/_/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing/ReferenceAssemblies.cs(342,0): at Microsoft.CodeAnalysis.Testing.ReferenceAssemblies.ResolveCoreAsync(String language, CancellationToken cancellationToken)
/_/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing/ReferenceAssemblies.cs(197,0): at Microsoft.CodeAnalysis.Testing.ReferenceAssemblies.ResolveAsync(String language, CancellationToken cancellationToken)
/home/uweigand/runtime/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/TestUtils.cs(278,0): at LibraryImportGenerator.UnitTests.TestUtils.ResolveReferenceAssemblies(ReferenceAssemblies referenceAssemblies)
/home/uweigand/runtime/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/TestUtils.cs(224,0): at LibraryImportGenerator.UnitTests.TestUtils.GetReferenceAssemblies(TestTargetFramework targetFramework)
/home/uweigand/runtime/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/TestUtils.cs(177,0): at LibraryImportGenerator.UnitTests.TestUtils.CreateCompilation(SyntaxTree[] sources, TestTargetFramework targetFramework, OutputKind outputKind, IEnumerable`1 refs, Boolean allowUnsafe)
/home/uweigand/runtime/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/Compiles.cs(664,0): at LibraryImportGenerator.UnitTests.Compiles.ValidateRequireAllowUnsafeBlocksDiagnosticNoTrigger(String id, String source, TestTargetFramework framework, Boolean allowUnsafe)
--- End of stack trace from previous location ---
----- Inner Stack Trace -----
at NuGet.Packaging.Signing.EndOfCentralDirectoryRecord.ThrowByteSignatureNotFoundException(Byte[] signature)
at NuGet.Packaging.Signing.EndOfCentralDirectoryRecord.SeekToEndOfCentralDirectoryRecord(BinaryReader reader)
at NuGet.Packaging.Signing.EndOfCentralDirectoryRecord.Read(BinaryReader reader)
at NuGet.Packaging.Signing.SignedPackageArchiveIOUtility.ReadSignedArchiveMetadata(BinaryReader reader, Boolean validateSignatureEntry)
at NuGet.Packaging.Signing.SignedPackageArchiveUtility.GetPackageContentHash(BinaryReader reader)
at NuGet.Packaging.PackageArchiveReader.GetContentHashForSignedPackage(CancellationToken token)
at NuGet.Packaging.PackageArchiveReader.GetContentHash(CancellationToken token, Func`1 GetUnsignedPackageHash)
at NuGet.Packaging.PackageExtractor.<>c__DisplayClass3_0.<<InstallFromSourceAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at NuGet.Common.ConcurrencyUtilities.<ExecuteWithFileLockedAsync>d__3`1[[System.Boolean, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
at NuGet.Common.ConcurrencyUtilities.<ExecuteWithFileLockedAsync>d__3`1[[System.Boolean, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
at NuGet.Packaging.PackageExtractor.InstallFromSourceAsync(String source, PackageIdentity packageIdentity, Func`2 copyToAsync, VersionFolderPathResolver versionFolderPathResolver, PackageExtractionContext packageExtractionContext, CancellationToken token, Guid parentId)
at NuGet.Protocol.GlobalPackagesFolderUtility.AddPackageAsync(String source, PackageIdentity packageIdentity, Stream packageStream, String globalPackagesFolder, Guid parentId, ClientPolicyContext clientPolicyContext, ILogger logger, CancellationToken token)
at NuGet.Protocol.GetDownloadResultUtility.<>c__DisplayClass3_0.<<GetDownloadResultAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at NuGet.Protocol.HttpSource.<>c__DisplayClass16_0`1.<<ProcessStreamAsync>b__0>d[[NuGet.Protocol.Core.Types.DownloadResourceResult, NuGet.Protocol, Version=5.6.0.5, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].MoveNext()
--- End of stack trace from previous location ---
at NuGet.Protocol.HttpSource.<ProcessResponseAsync>d__18`1[[NuGet.Protocol.Core.Types.DownloadResourceResult, NuGet.Protocol, Version=5.6.0.5, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].MoveNext()
at NuGet.Protocol.HttpSource.<ProcessStreamAsync>d__16`1[[NuGet.Protocol.Core.Types.DownloadResourceResult, NuGet.Protocol, Version=5.6.0.5, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].MoveNext()
at NuGet.Protocol.GetDownloadResultUtility.GetDownloadResultAsync(HttpSource client, PackageIdentity identity, Uri uri, PackageDownloadContext downloadContext, String globalPackagesFolder, ILogger logger, CancellationToken token)
LibraryImportGenerator.UnitTests.Compiles.ValidateRequireAllowUnsafeBlocksDiagnosticNoTrigger(id: "Compiles.cs:654", source: "\nusing System.Runtime.InteropServices;\npublic cl"..., framework: Framework, allowUnsafe: False) [FAIL]
It turns out this is due to an endian bug in the NuGet sources, which has already been fixed here: https://github.com/NuGet/NuGet.Client/pull/3930
The first NuGet version to include this fix was 5.11. However, the Microsoft.CodeAnalysis.Analyzer.Testing package specifically pulls in NuGet version 5.6, which still has this problem. This is due to this setting in src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing/Microsoft.CodeAnalysis.Analyzer.Testing.csproj:
<NuGetApiVersion>5.6.0</NuGetApiVersion>
I'm not sure what else depends on this particular version - would it be possible to update this to (at least) 5.11.0 to fix the bug on big-endian systems?
I've verified with a local build that setting NuGetApiVersion to 5.11.0 and forcing runtime to use the rebuilt Microsoft.CodeAnalysis.Analyzer.Testing package does indeed fix the above test case failure.
CC @sharwell
@jaredpar PTAL?
@mavasani, @sharwell, @jmarolf