MAUI 7.0.92 requires Microsoft.Extensions.Logging.Abstractions 7.0.0 while .NET 7.0.9 7.0.1
foximoxi opened this issue ยท 34 comments
Description
I'm not able to upgrade project using latest MAUI with .NET 7.0.9 because of Microsoft.Extensions.Logging.Abstractions conflict.
Library with Microsoft Extensions.Localization requires 7.0.1 while net7.0-android and others needs 7.0.0
I've error:
NU1605: Warning As Error: Detected package downgrade: Microsoft.Extensions.Logging.Abstractions from 7.0.1 to 7.0.0. Reference the package directly from the project to select a different version.
Steps to Reproduce
- Create MAUI Hybrid project
- Create Microsoft.NET.Sdk.Razor library with Microsoft.Extensions.Localization
- Add library reference to MAUI project
- Compile
Link to public reproduction project repository
not needed
Version with bug
Unknown/Other
Last version that worked well
7.0.49
Affected platforms
iOS, Android, Windows
Affected platform versions
.NET MAUI 7
Did you find any workaround?
no
Relevant log output
Restoring packages for C:\SCF\SCFLib\SCFLib\SCFLib.csproj...
NU1605: Warning As Error: Detected package downgrade: Microsoft.Extensions.Logging.Abstractions from 7.0.1 to 7.0.0. Reference the package directly from the project to select a different version.
SCFLib -> Microsoft.Extensions.Localization 7.0.9 -> Microsoft.Extensions.Logging.Abstractions (>= 7.0.1)
SCFLib -> Microsoft.Extensions.Logging.Abstractions (>= 7.0.0)
NU1605: Warning As Error: Detected package downgrade: Microsoft.Extensions.Logging.Abstractions from 7.0.1 to 7.0.0. Reference the package directly from the project to select a different version.
SCFLib -> Microsoft.AspNetCore.Components.Web 7.0.9 -> Microsoft.AspNetCore.Components 7.0.9 -> Microsoft.AspNetCore.Authorization 7.0.9 -> Microsoft.Extensions.Logging.Abstractions (>= 7.0.1)
SCFLib -> Microsoft.Extensions.Logging.Abstractions (>= 7.0.0)
Package restore failed. Rolling back package changes for 'SCFLib'.
Time Elapsed: 00:00:00.0982852
In general like the output said do explicit add the version you want to use to the project as dependency. This means select for your project in the nuget manager the version 7.0.1 for Microsoft.Extensions.Logging.Abstractions. It should still work if you would use a newer version.
Sure, but it does not allow to update this library. I was trying do this (by cmd line and nuget manager).
On manager panel there is a label: Blocked by project
On command line:
error: Error while performing Update for package 'Microsoft.Extensions.Logging.Abstractions'. Cannot edit items in imported files -
error: Item 'PackageReference' for 'Microsoft.Extensions.Logging.Abstractions' in Imported file 'C:\Program Files\dotnet\packs\Microsoft.Maui.Sdk\7.0.92\Sdk\BundledVersions.targets'.
error: Item 'PackageReference' for 'Microsoft.Extensions.Logging.Abstractions' in Imported file 'C:\Program Files\dotnet\packs\Microsoft.Maui.Sdk\7.0.92\Sdk\BundledVersions.targets'.
error: Item 'PackageReference' for 'Microsoft.Extensions.Logging.Abstractions' in Imported file 'C:\Program Files\dotnet\packs\Microsoft.Maui.Sdk\7.0.92\Sdk\BundledVersions.targets'.
I was able to manually edit csproj with
and now I get only Warning:
C:\Program Files\dotnet\sdk\7.0.306\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.Shared.targets(152,5): warning NETSDK1023: A PackageReference for 'Microsoft.Extensions.Logging.Abstractions' was included in your project. This package is implicitly referenced by the .NET SDK and you do not typically need to reference it from your project. For more information, see https://aka.ms/sdkimplicitrefs
I had the same problem and I did
dotnet workload update
+ rebuilt the project
and the problem disappeared
EDIT: Ok, it did not
EDIT2: This seems to work. Put this directly into your maui .csproj
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" VersionOverride="7.0.1" />
ๆ้ๅฐไบๅๆ ท็้ฎ้ข๏ผๆๅไบ+้ๅปบไบ้กน็ฎ๏ผ้ฎ้ขๆถๅคฑไบ
dotnet workload update
็ผ่พ๏ผๅฅฝ็๏ผๅฎๆฒกๆ
็ผ่พ2๏ผ่ฟไผผไนๆๆใๆๅฎ็ดๆฅๆพๅฐไฝ ็ๆฏไผๅฒ.csprojไธญ
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" VersionOverride="7.0.1" />
Exception during application startup:
System.TypeLoadException: 'Could not load type of field 'Microsoft.Extensions.Logging.LoggerFactory:_scopeProvider' (6) due to: Could not resolve type with token 01000034 from typeref (expected class 'Microsoft.Extensions.Logging.IExternalScopeProvider' in assembly 'Microsoft.Extensions.Logging.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60') assembly:Microsoft.Extensions.Logging.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 type:Microsoft.Extensions.Logging.IExternalScopeProvider member:(null)'
I have the same issue trying to install SignalR Client, which requires Microsoft.Extensions.Logging.Abstractions > 7.0.1, but Maui project blocks it. Updating the csproj like any other time this happens causes Android issues.
Same problem here when sharing a Razor Class Library between blazor wasm and MAUI.
Any solution? Forcing VersionOverride for package in csproj breaks the app startup
I also have this problem. My project is a MAUI Blazor app that uses both a RCL and SignalR. I included the line:
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" VersionOverride="7.0.1" />
as suggested above and reloaded my project and it crashed on startup. I then used the "Manage Packages for Solution" option in the tools menu to install Microsoft.Extensions.Logging.Abstractions version 7.0.1 and restarted the project. It launched in windows as well as on an android device without crashing. But I have not actually used SignalR, only included it into the project.
I still have a NETSDK1023 warning but at least it is launching now. Thanks very much for the work around.
Same issue. MAUI prevents loading a specific version (7.0.1) to force it to match. So only options appears to be to override it with
in the MAUI csproj file. Project builds with that override in place but produces error at runtime:
System.TypeLoadException: 'Could not load type of field 'Microsoft.Extensions.Logging.LoggerFactory:_scopeProvider' (6) due to: Could not resolve type with token 01000034 from typeref (expected class 'Microsoft.Extensions.Logging.IExternalScopeProvider'
I have same problem. I cannot archive my app. When I remove the package I get errors and when I add I cannot archive my anroid app.
I am having the same problem with a blazor hybrid app referencing a razor class library - adding the package reference manually allows the app to build on Windows and Android but on iOS it fails with:
3>clang: error: linker command failed with exit code 1 (use -v to see invocation) 3>C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.4.7090\targets\Xamarin.Shared.Sdk.targets(1274,3): error : clang++ exited with code 1: 3>C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.4.7090\targets\Xamarin.Shared.Sdk.targets(1274,3): error : ld: framework not found System 3>C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.4.7090\targets\Xamarin.Shared.Sdk.targets(1274,3): error : clang: error: linker command failed with exit code 1 (use -v to see invocation)
Having the same issue with Blazor Hybrid.
I had to put the override in all shared libraries including RCLs. It works on Windows and Android, have not tested macOS/iOS.
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" VersionOverride="7.0.0" />
My project is on github and contains a bare bones example of Blazor Hybrid and Web in one solution.
https://github.com/EdCharbeneau/BlazorHybrid-SingleCodebase/tree/upgrade-dotnet7
Having the same problem when using MAUI Blazor microsoft/fluentui-blazor#654 . Manually upgrade the package by editing the csproj
file works but we are left with multiple duplicated warnings on build.
Btw I am curious how come >= 7.0.0
is not compatible with >= 7.0.1
? Should not both be resolved to 7.0.1
just fine?
I had the same problem and decided to solve it
[NU1605] Warning As Error: Detected package downgrade: Microsoft.Extensions.Logging.Abstractions from 7.0.1 to 7.0.0. Reference the package directly from the project to select a different version.
I was able to solve it.
I included the line (if you already have this line, you need edit version manually)
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" VersionOverride="7.0.1" />
to my maui.csproj
then I did dotnet workload update
+ rebuilt the maui.sln
then I catched new errors and I did dotnet restore maui.sln
+ rebuilt the maui.sln
and the problem disappeared
@olekssokol I tried the same but still having the same problem when trying to archive my Android app
A PackageReference for 'Microsoft.Extensions.Logging.Abstractions' was included in your project. This package is implicitly referenced by the .NET SDK and you do not typically need to reference it from your project. For more information, see https://aka.ms/sdkimplicitrefs
I'm hitting the same issue the referencing a new RazorComponent Library from a BlazorMAUIHydrid App.
Here's my repro sample
https://github.com/BenBtg/BlazorMauiHybridIssue
Although not super an issue, this is just a warning:
A PackageReference for 'Microsoft.Extensions.Logging.Abstractions' was included in your project. This package is implicitly referenced by the .NET SDK and you do not typically need to reference it from your project. For more information, see https://aka.ms/sdkimplicitrefs
A way to work around this is to use an Update
:
<PackageReference Update="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
This will replace the value for the included nugets.
Another option is to use an older Microsoft.Extensions.Localization that only depends on 7.0.0.
This will be improved in #17487
We are removing the explicit Microsoft.Extensions.Logging.Abstractions
package as this is already brought in by Microsoft.Extensions.Logging
.
The Update
pattern will also work if there is ever an update to the base Microsoft.Extensions.Logging
package
I rolled back my Microsoft.AspNetCore.Components.Web nuget package in the RCL to 7.0.5 to make it work for me for now. Better to have a working app with old nuget than a broken app.
Did the update not work?
MAUI is becoming a pain. It feels like Microsoft is breaking themselves because it's all within Microsoft packages. Looks like we know who's is going to retire next after VS for Mac ๐คซ
Fixed in #17487
How is this fixed? I updated to newest .NET 7 (7.0.401) and VS version and default MAUI Blazor project template raises the same error when adding a RCL reference.
In my case, I need external NuGet packages that require Microsoft.Extensions.Logging.Abstractions >= 7.0.1. MAUI includes 7.0.0 by default and having to manually reference a package version does not seem right.
This is also not fixed for me after going through the pain of updating .net 7 to the latest version and following the steps in the video below (which I can confirm works for .net 6).
https://www.youtube.com/watch?v=UpOPtj-qd6A
Just so I'm not being an idiot, can you explain how exactly this was tested to make sure it was fixed? Just so i can follow in those steps?
I guess you have to build the branch https://github.com/dotnet/maui/tree/net7.0 on your own, since no release was made since months.
Was MAUI not updated in .NET 7.0.11 release? (12th of september)
.NET is not bundled with MAUI. MAUI is maybe bound to. NET version.
You're totally right. My mistake.
Any idea when a new release of MAUI including this "fix" will be available in Visual Studio?
- So you need to add
"<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" VersionOverride="7.0.1" />"
to your maui project - Then you need to rebuild the project
- Then you need to restore nuget packages
and then you need to restore the workloads. it must be done in this sequence then the problem is resolved.
You still get some warnings. And the solution is far from ideal.
I am annoyed by the warnings as well so I slapped <NoWarn>NETSDK1023</NoWarn>
into my .csproj
file until they fix it. You can do that to your personal projects but it may cause issues to other genuine package conflicts though.
I confirm this is fixed in version 7.0.96 released yesterday.
Just need to update Visual Studio and remove the override:
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" VersionOverride="7.0.1" />
.
Can also confirm this is fixed. Thanks to all involved.
Latest Visual Studio Version (2022 Enterprise 17.7.5) and Error still exist for me
Severity Code Description Project File Line Suppression State
Error NU1605 Warning As Error: Detected package downgrade: Microsoft.Extensions.Logging.Abstractions from 7.0.1 to 7.0.0. Reference the package directly from the project to select a different version.
Mention.Maui -> Mention.Client -> Microsoft.Extensions.Localization 7.0.12 -> Microsoft.Extensions.Logging.Abstractions (>= 7.0.1)
Mention.Maui -> Microsoft.Extensions.Logging.Abstractions (>= 7.0.0) Mention.Maui C:\Users\Tim.Woerner\source\repos\Mention\Mention.Maui\Mention.Maui.csproj 1
Error NU1605 Warning As Error: Detected package downgrade: Microsoft.Extensions.Logging.Abstractions from 7.0.1 to 7.0.0. Reference the package directly from the project to select a different version.
Mention.Maui -> Mention.Client -> Microsoft.AspNetCore.Components.Authorization 7.0.12 -> Microsoft.AspNetCore.Authorization 7.0.12 -> Microsoft.Extensions.Logging.Abstractions (>= 7.0.1)
Mention.Maui -> Microsoft.Extensions.Logging.Abstractions (>= 7.0.0) Mention.Maui C:\Users\Tim.Woerner\source\repos\Mention\Mention.Maui\Mention.Maui.csproj 1
Error NU1605 Warning As Error: Detected package downgrade: Microsoft.Extensions.Logging.Abstractions from 7.0.1 to 7.0.0. Reference the package directly from the project to select a different version.
Mention.Maui -> Mention.Client -> Microsoft.AspNetCore.SignalR.Client 7.0.12 -> Microsoft.AspNetCore.Http.Connections.Client 7.0.12 -> Microsoft.Extensions.Logging.Abstractions (>= 7.0.1)
Mention.Maui -> Microsoft.Extensions.Logging.Abstractions (>= 7.0.0) Mention.Maui C:\Users\Tim.Woerner\source\repos\Mention\Mention.Maui\Mention.Maui.csproj 1
Error NU1605 Warning As Error: Detected package downgrade: Microsoft.Extensions.Logging.Abstractions from 7.0.1 to 7.0.0. Reference the package directly from the project to select a different version.
Mention.Maui -> Mention.Client -> Microsoft.AspNetCore.Components.WebAssembly 7.0.12 -> Microsoft.AspNetCore.Components.Web 7.0.12 -> Microsoft.AspNetCore.Components 7.0.12 -> Microsoft.AspNetCore.Authorization 7.0.12 -> Microsoft.Extensions.Logging.Abstractions (>= 7.0.1)
Mention.Maui -> Microsoft.Extensions.Logging.Abstractions (>= 7.0.0) Mention.Maui C:\Users\Tim.Woerner\source\repos\Mention\Mention.Maui\Mention.Maui.csproj 1