-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Can no longer compile any project after upgrading from .NET 9.0 Preview 7 to .NET 9.0 RC1 #43339
Comments
We are encountering this in Uno Platform as well once we updated to RC1 |
What I find strange is the version number. Should it really be 8.0.0.4? The latest stable NuGet package version is 8.0.4 |
Only in Uno Platform though? I'm having this issue in every project. I can start a new solution, add a class library with nothing in it, try to compile and I get that error. |
It shouldn't be specific to Uno Platform, just mentioning that we are also unable to upgrade to RC1 due to this issue |
Quite likely, possibly this commit: 337965f In my SDK folder I have 8 files called System.Text.Json.dll Four are file version 9.0.24.43107 None of them are 8.0.0.4 |
https://nuget.info/packages/System.Text.Json/8.0.4 shows https://nuget.info/packages/System.Text.Json/9.0.0-rc.1.24431.7 shows both |
I meet this problem too! |
But then you wouldn't be able to compile .NET 9 projects, no? |
Yes! I think you can down grade it to preview7 first. |
Looks like it's a known issue: https://github.com/dotnet/core/pull/9489/files |
I hoped this App.config would help but it really didn't. Maybe I am missing something. <?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" />
<bindingRedirect oldVersion="8.0.0.4" newVersion="9.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration> |
I confirm that this is a Visual Studio issue. I was able to |
@MarkCiliaVincenti, which App.config file did you modify? It might need to be |
Interesting, but I'm not sure what I'm supposed to do here. I tried this but it didn't work:
to:
|
Moved to #43356 |
This is a known issue with the combination of Visual Studio 17.11 and .NET SDK 9.0.100-rc.1. It will be addressed in a future Visual Studio 17.11.x release. Per the .NET SDK support matrix, you must use Visual Studio 17.12-preview to target .NET 9 from within Visual Studio. That’s the best way to get things working today. To target .NET 8 or lower, there are a couple of workaround options while you wait for the fix (dotnet/msbuild#10650) to be available:
|
@leppie please file a separate issue, that doesn't sound like this one. |
@rainersigwald The problem for us is mostly with CI scenarios where hosted agents don't yet contain 17.12. If there are ugly workarounds to use rc1 with 17.11.2 (e.g, messing up with System.Text.Json in the .NET installation or really anything else), we'd love to hear. |
working on it |
This works around dotnet/sdk#43339 by preloading a copy of the assembly that can't be located with the normal load processes. It should be harmless (other than wasting time) in circumstances where it's not necessary.
WorkaroundThis workaround can be checked into any affected repo, but should be removed as soon as possible. Add the following to a <!-- BEGIN workaround for https://github.com/dotnet/sdk/issues/43339; remove after updated to VS 17.12 or a future 17.11 patch -->
<Target Name="WorkaroundDotnetSdk43339" BeforeTargets="ResolvePackageAssets" Condition=" '$(MSBuildRuntimeType)' == 'Full' and $([MSBuild]::VersionLessThan($(MSBuildVersion), 17.12.0))">
<PrimeSystemTextJson804 />
</Target>
<UsingTask
TaskName="PrimeSystemTextJson804"
TaskFactory="RoslynCodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll" >
<Task>
<Code Type="Fragment" Language="cs">
<![CDATA[
try
{
System.Reflection.Assembly.LoadFrom(@"$(MicrosoftNETBuildTasksDirectoryRoot)\..\..\..\DotnetTools\dotnet-format\BuildHost-net472\System.Text.Json.dll");
}
catch
{
// Best effort: if something moves in the SDK don't break the build.
}
]]>
</Code>
</Task>
</UsingTask>
<!-- END workaround for https://github.com/dotnet/sdk/issues/43339 --> It's working for the MSBuild repo; see dotnet/msbuild#10643. |
@rainersigwald this workaround is working for us as well! Thanks for the help! |
This works around dotnet/sdk#43339 for Arcade projects, unblocking updating to .NET SDK 9.0.100-rc.1, even when official or PR builds use Visual Studio 17.11.
Will address dotnet/sdk#43339 when deployed in VS. --------- Co-authored-by: Rainer Sigwald <[email protected]>
If all goes well, a VS-side fix will be released with release 17.11.4 (we just checked in to VS). |
I don't believe that will work - that directory contains tools like format, watch, etc., not the build logic that is causing the crash. I strongly encourage users to not go spelunking and modifying the SDK's installed layout. |
yeah it won't, I got something wrong |
There are 4 solutions:
|
Can confirm. I was eager to try .NET 9 RC 1 but nothing will build in Visual Studio 2022 Community edition now. |
Since Visual Studio 2022 v17.11.4 is out, this problem is fixed. |
This reverts commit fa5202f.
Still occours on azure using a .net8 web app which used msbuild .net9 for compiling on AZURE SolutionDeleting the dev slot on the azure portal and deploying on a brand new slot solved the issue. For the ones who might end up here having the same issue ^^ |
Unfortunately, we still got the same error on a brand new slot. I'm hoping the Azure/.NET folks eventually get this sorted. We normally stay on LTS versions but wanted to observe the performance improvements of .NET 9 in a test environment. |
The steps I took:
Every project I try compiling I'm getting this error even though it's not referencing System.Text.Json, even transitively.
C:\Program Files\dotnet\sdk\9.0.100-rc.1.24452.12\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(266,5): error NETSDK1060: Error reading assets file: Error loading lock file 'C:[....]\obj\project.assets.json' : Could not load file or assembly 'System.Text.Json, Version=8.0.0.4, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
I tried redownloading and reinstalling, repairing, deleted the NuGet package cache, manually deleted the bin and obj folders, rebooted the PC... basically everything I could think of
The text was updated successfully, but these errors were encountered: