At first I was just going to update the original post NuGet Nightmares. But that post has enough whining. That post was about Visual Studio 2022, .NET Framework and NuGet. This post is about Visual Studio 2026 .net 10 and NuGet. I don't actually think this is about NuGet anymore, though two different A.I. models disagree. Upon Build of a newly created .net 10 console app with no NuGet dependencies this error was thrown:
The "ResolvePackageAssets" task failed unexpectedly. System.IO.FileLoadException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=6.0.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) File name: 'System.Runtime.CompilerServices.Unsafe, Version=6.0.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' at System.ReadOnlySpan`1..ctor(T[] array) at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader.ValidateHeader(BinaryReader reader, Byte[] settingsHash) at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader.OpenCacheStream(Stream stream, Byte[] settingsHash) at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader..ctor(ResolvePackageAssets task) at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ReadItemGroups() at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ExecuteCore() at Microsoft.NET.Build.Tasks.TaskBase.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll Running under executable C:\Program Files\Microsoft Visual Studio\18\Enterprise\MSBuild\Current\Bin\amd64\MSBuild.exe --- A detailed error log follows.
Publishing a pre-compiled site to Azure using the publish feature of Visual Studio threw this error:
LOG: DisplayName = System.Runtime.CompilerServices.Unsafe, Version=6.0.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/Program Files/Microsoft Visual Studio/18/Enterprise/Common7/IDE/
LOG: Initial PrivatePath = NULL
Calling assembly : System.Memory, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51.
LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Users\xxx\AppData\Local\Microsoft\VisualStudio\18.0_92984304\devenv.exe.config LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config. LOG: Post-policy reference: System.Runtime.CompilerServices.Unsafe, Version=6.0.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a LOG: Attempting download of new URL file:///C:/Program Files/Microsoft Visual Studio/18/Enterprise/Common7/IDE/System.Runtime.CompilerServices.Unsafe.DLL. LOG: Attempting download of new URL file:///C:/Program Files/Microsoft Visual Studio/18/Enterprise/Common7/IDE/System.Runtime.CompilerServices.Unsafe/System.Runtime.CompilerServices.Unsafe.DLL. LOG: Attempting download of new URL file:///C:/Program Files/Microsoft Visual Studio/18/Enterprise/Common7/IDE/PublicAssemblies/System.Runtime.CompilerServices.Unsafe.DLL. WRN: Comparing the assembly name resulted in the mismatch: Build Number ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
I installed Visual Studio 2026 on 2 computers at the same time. They were both using the options from 2022, so they were not identical but very close. But they were the same Enterprise version 18.3.0 February 2026 Feature Update. I inspected both computers
C:\Users\xxx\AppData\Local\Microsoft\VisualStudio\###\devenv.exe.config
The one that worked had:
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.1.0" newVersion="6.0.1.0"/>
<codeBase version="6.0.1.0" href="C:\Program Files\Microsoft Visual Studio\18\Enterprise\SharedAssemblies\System.Runtime.CompilerServices.Unsafe\6.0.1.0\6.1.0\netfx\System.Runtime.CompilerServices.Unsafe.dll"/>
</dependentAssembly>
The one that did not work was:
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.2.0" newVersion="6.0.2.0"/>
<codeBase version="6.0.2.0" href="C:\Program Files\Microsoft Visual Studio\18\Enterprise\SharedAssemblies\System.Runtime.CompilerServices.Unsafe\6.0.2.0\6.2.0\netfx\System.Runtime.CompilerServices.Unsafe.dll"/>
</dependentAssembly>
I made it work by changing the oldVersion maximum:
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.3.0" newVersion="6.0.2.0"/>
<codeBase version="6.0.2.0" href="C:\Program Files\Microsoft Visual Studio\18\Enterprise\SharedAssemblies\System.Runtime.CompilerServices.Unsafe\6.0.2.0\6.2.0\netfx\System.Runtime.CompilerServices.Unsafe.dll"/>
</dependentAssembly>
Please note that this was on top of the page:
<!-- *************************************************************************** -->
<!-- ************** NOTE: This is a generated file. Do not modify.************** -->
<!-- ********* Modifications will be overwritten during regeneration. ********** -->
<!-- *************************************************************************** -->
A.I. wanted me to let it do publish from the command line because the tooling would be different. At least we agree, it is the tooling, nothing to do with project dependencies.