afaik, almost all of Microsofr.AspNetCore.* assemblies will live within
Microsoft.NET.Sdk.Web
, unfortunately theMicrosoft.Extensions.*
packages still live as separate nuget.
that's normal
Msft.Extensions.*
were always separated from Msft.AspNetCore.*
because they are "USED" by AspNetCore but are not part of it :
DependencyInjection / Logging / Configurations / Options are good examples.
See how they are targeting netstandard2.0
you can use it in your old stack like Owin
/ Xamarin
... (kinda great for Logging / Options)
I'm still seeing app the Microsoft.AspNetCore packages on nuget are 2.2
DONT FORGET that the new Microsoft.AspNetCore....
3.0 is a runtime that "inherits" of the netcoreapp3.0
.
This means two things :
- it can't run anymore on
net4xx
(no morenetfx
💛) - you need to actually target
netcoreapp3.0
As @poke explained :
the NuGet packages are on nuget.org
are the packages that target netstandard, and as such they are limited to 2.2 and below.
2.1 is LTS and will be supported longer on .NET Framework, so those packages will continue to be very valuable there.
The thing is that now Microsoft.AspNetCore.App
is a FrameworkReference
and not a PackageReference
anymore
2.2 has this big ambiguity (ended up being an issue) where the Microsoft.AspNetCore.App
package was reference as a PackageReference
but should never had a Version
specified (it was supposed to be pull from the Sdk being used at build time global.json
)
If you messed up dependencies, it could in some scenario, take the resolved weird version from nuget.org
instead of the ones from the sdk
the FrameworkReference
attempt to fix it, IT HAS TO BE installed at build time.
For that to work you just install the Sdk (nothing special in fact ^^). That's how it know what sdk to look for the
<FrameworkRerence Include="Microsoft.AspNetCore.App" />
EDIT : i previously said you had to change the SDK
to the Web
one, pretty sure it's a mistake ... and you should not need that :
- For example, imagine creating a
WPF
application (it uses theDesktop
SDK), if you need someAspNetCore
Assemblies, then you can't have both<Project Sdk="....">
at the same time. - When you create a
dotnet new webapi
, it does have theWeb
SDK, and you see no<FrameworkRerence Include="Microsoft.AspNetCore.App" />
, it will be included by theSDK
itself "for free"
If you are developping a library :
- try to target
netstandard2.0
- if you need special new api from
netstandard2.1
, well just update to<TargetFramwork>netstandard2.1</TargetFramwork>
- if you are doing a lib that depends on aspnetcore3, then target
netcoreapp3.0
(instead ofnetstandard2.x
) and add a<FrameworkReference Include="Microsoft.AspNetCore.App" />
- The same idea applies for Wpf/Winform/Uwp for
FrameworkReference
- The trick is when you are doing a lib that need to support BOTH aspnetcore2.x + 3.x :
<PropertyGroup>
<!-- in order to consume the aspnetcore3 metapackage you need to also target netcoreapp3.0 here -->
<TargetFrameworks>netstandard2.0;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<!-- every single aspnetcore 2.x one by one -->
<!-- don't even try meta package (the .App) in 2.x in lib -->
<!-- you need to align version here -->
<PackageReference Include="Microsoft.AspNetCore.Http.Abstraction" Version="2.2.6" />
<PackageReference Include="Microsoft.AspNetCore.Foo" Version="2.2.6" />
<PackageReference Include="Microsoft.AspNetCore.Bar" Version="2.2.6" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<!-- only one ref / note that it's a meta package -->
<!-- no version -->
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup>
<!-- all dependencies that are not TFM specific -->
</ItemGroup>