I'm trying to update my projects to .NET Core 3.0 and .NET Standard 2.1 (including .NET Core Identity)
I have 2 projects. First my Web API:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0" />
</ItemGroup>
...
And in this project code related with Identity works fine.
As I see here I need to remove package Microsoft.AspNetCore.Identity
https://learn.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.0&tabs=visual-studio
2-nd project:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<!--<FrameworkReference Include="Microsoft.AspNetCore.App" />-->
<!--<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />-->
</ItemGroup>
...
So, if I remove Microsoft.AspNetCore.Identity from my second project I see error:
The type or namespace name 'SignInManager<>' could not be found (are you missing a using directive or an assembly reference?)
If I add this line:
<FrameworkReference Include="Microsoft.AspNetCore.App" />
I see this error:
Error NETSDK1073 The FrameworkReference 'Microsoft.AspNetCore.App' was not recognized
How can I resolve my issue?
See this Github Issue which explains a lot of the changes. As said in one of the comments.
Correct. We are removing the netstandard2.0 from most Microsoft.AspNetCore.* assemblies. See #3754
So in order to use the <FrameworkReference Include="Microsoft.AspNetCore.App" /> in your .csproj you will need to target netcoreapp3.0 or higher.
I started getting this issue after downgrading visual studio enterprise 2019 to professional 2019.
.Net core framework netcoreapp3.1
I fixed it by updating the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation from 3.1.3 to 3.1.4.
Related
I had EF Core set up and working with .Net Core 2 & EF Core 2. I upgraded to .Net Core & EF Core to v3 but I never tested my migrations.
Now I have upgraded to .NetCore 3.1 & EF Core 3.1 and when I try to create a migration or run database update I get the following error.
It was not possible to find any compatible framework version
The framework 'Microsoft.AspNetCore.App', version '2.2.0' was not found.
- The following frameworks were found:
3.0.1 at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
3.1.3 at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
You can resolve the problem by installing the specified framework and/or SDK.
I have checked the version of dotnet
dotnet --version
3.1.201
dotnet ef --version
Entity Framework Core .NET Command-line Tools 3.1.3
My Class library where EF Core is installed and the startup project both target
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
And I have upgraded all my NuGet packages to the latest version.
Class Library
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="Migrations" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Event.Models\Event.Models.csproj" />
</ItemGroup>
</Project>
And my Startup Project
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<DockerComposeProjectPath>../docker-compose.dcproj</DockerComposeProjectPath>
<UserSecretsId>some-secret-guid</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MassTransit" Version="6.2.3" />
<PackageReference Include="MassTransit.AspNetCore" Version="6.2.3" />
<PackageReference Include="MassTransit.Autofac" Version="6.2.3" />
<PackageReference Include="Autofac" Version="5.1.2" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="MassTransit.Extensions.DependencyInjection" Version="6.2.3" />
<PackageReference Include="MassTransit.RabbitMQ" Version="6.2.3" />
<PackageReference Include="Serilog" Version="2.9.0" />
<PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
<PackageReference Include="Serilog.Sinks.MongoDB" Version="4.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Event.DataAccess\Event.DataAccess.csproj" />
<ProjectReference Include="..\Event.Domain\Event.Domain.csproj" />
<ProjectReference Include="..\Event.Models\Event.Models.csproj" />
</ItemGroup>
</Project>
I have no idea where the reference to Microsoft.AspNetCore.App, version '2.2.0' is coming from. I have Googled this and I haven't come across any related issues.
Thanks in advance for any help.
hi many time this problem happened to me, so first uninstall all of the NuGet packages from the all of your project and class library ( remember the name of packages you have been uninstalled)
then install them again with the last version you want (be careful many packages in asp core 3 joined to gather or removed)
i recently had this issue after migrating from .net core 2.2 to 5.0.
after struggling for hours there's a hidden folder inside the root folder named ".config" , you'll find "dotnet-tools.json" , modify the version and it should work.
How do I fix the nasty warning I'm getting when running .NET Core tests from a command line via dotnet test?
The dotnet --version returns back 3.1.101.
$ dotnet test
watch : Started
C:\Program Files\dotnet\sdk\3.1.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.targets(151,5):
warning NETSDK1080: A PackageReference to Microsoft.AspNetCore.App is not necessary when targeting
.NET Core 3.0 or higher. If Microsoft.NET.Sdk.Web is used, the shared framework will be referenced automatically.
Otherwise, the PackageReference should be replaced with a FrameworkReference.
[C:\github\demo\Demo\SmartHome.API\SmartHome.API.csproj]
C:\Program Files\dotnet\sdk\3.1.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.targets(151,5):
warning NETSDK1080: A PackageReference to Microsoft.AspNetCore.App is not necessary when targeting
.NET Core 3.0 or higher. If Microsoft.NET.Sdk.Web is used, the shared framework will be referenced automatically.
Otherwise, the PackageReference should be replaced with a FrameworkReference.
[C:\github\demo\Demo\SmartHome.API\SmartHome.API.csproj]
Test run for C:\github\demo\Demo\SmartHome.API.Test\bin\Debug\netcoreapp3.1\SmartHome.API.Test.dll(.NETCoreApp,Version=v3.1)
Microsoft (R) Test Execution Command Line Tool Version 16.3.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Here's what my SmartHome.API.Test.csproj looks like.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="MongoDB.Driver" Version="2.10.1" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="1.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SmartHome.API\SmartHome.API.csproj" />
<ProjectReference Include="..\SmartHome.Models\SmartHome.API.Models.csproj" />
</ItemGroup>
</Project>
And this is the SmartHome.API.csproj which seems to be the source of the issue.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentValidation" Version="8.6.1" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.8" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.1" />
<PackageReference Include="MongoDB.Driver" Version="2.10.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SmartHome.Models\SmartHome.API.Models.csproj" />
</ItemGroup>
</Project>
Changing a package dependency from Microsoft.AspNetCore.App (2.2.8) into a FrameworkReference in the SmartHome.API.csproj solved the problem for me at the cost of introducing a new one.
Initial fix
+ <ItemGroup>
+ <FrameworkReference Include="Microsoft.AspNetCore.App" />
+ </ItemGroup>
+
<ItemGroup>
<PackageReference Include="FluentValidation" Version="8.6.1" />
- <PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.8" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.1" />
<PackageReference Include="MongoDB.Driver" Version="2.10.1" />
</ItemGroup>
New warning
I started seeing a new warning:
C:\Program Files\dotnet\sdk\3.1.101\Sdks\Microsoft.NET.Sdk\targets\
Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(39,5):
warning NETSDK1086: A FrameworkReference for 'Microsoft.AspNetCore.App' was
included in the project. This 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
Final fix
...so I ended up removing the "Microsoft.AspNetCore.App" reference altogether. Now the build is warning-free!
i.e. the file looks like this:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentValidation" Version="8.6.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.1" />
<PackageReference Include="MongoDB.Driver" Version="2.10.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SmartHome.Models\SmartHome.API.Models.csproj" />
</ItemGroup>
</Project>
Thanks a lot for the provided fix.
I deleted the reference <PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.8" /> and my build is now warning-free too!! :)
Br,
harald
I get a missing reference error when I try to inherit from the class DynamicRouteValueTransformer in a class library but when I do it from my MVC app it works fine.
public class ProductRouteTransformer : Microsoft.AspNetCore.Mvc.Routing.DynamicRouteValueTransformer
DynamicRouteValueTransformer is in namespace Microsoft.AspNetCore.Mvc.Routing which is part of Microsoft.AspNetCore.Mvc.Core.dll. I've added the DLL to the class library using Nuget and can see that it is installed but I still get a missing reference error. The class is just missing from the namespace.
I'm using .NET Core 3.1.
The csproj is below:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoMapper" Version="9.0.0" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Http.Extensions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="2.2.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.0" />
<PackageReference Include="NLog" Version="4.6.8" />
</ItemGroup>
<ItemGroup>
<Folder Include="Database\EntityUtils\" />
</ItemGroup>
</Project>
There's a topic in the docs that was introduced recently, which covers this in great detail:
With the release of .NET Core 3.0, many ASP.NET Core assemblies are no longer published to NuGet as packages.
If you take a look at the contents of your .csproj, you'll see that you've added references to 2.2.x versions of a few Microsoft.AspNetCore.* packages. I'm sure you intended to reference 3.1.x versions of these, but, as the docs quote above shows, these packages are no longer produced for 3.0+.
The next few lines from the docs explain what's happened here:
Instead, the assemblies are included in the Microsoft.AspNetCore.App shared framework, which is installed with the .NET Core SDK and runtime installers.
As of .NET Core 3.0, projects using the Microsoft.NET.Sdk.Web MSBuild SDK implicitly reference the shared framework. Projects using the Microsoft.NET.Sdk or Microsoft.NET.Sdk.Razor SDK must reference ASP.NET Core to use ASP.NET Core APIs in the shared framework.
As your project is referencing Microsoft.NET.Sdk, you'll need to add a FrameworkReference, as described above, and remove those old PackageReferences:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AutoMapper" Version="9.0.0" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.0" />
<PackageReference Include="NLog" Version="4.6.8" />
</ItemGroup>
<ItemGroup>
<Folder Include="Database\EntityUtils\" />
</ItemGroup>
</Project>
Note that not all of the packages have been folded into the shared framework. For example, Microsoft.EntityFrameworkCore.SqlServer is still provided as a NuGet package.
I just started learning how to create asp.netcore web applications using mvc 2.0 pattern...i encountered;Problem adding migration...and most of the configuration and services in my startup.cs don't have any reference hence they dont change color.I was told I have to install one nuget package but I already installed some...it is still not working. Hence I can't add initial migration. In the picture above I have included an evidence of the Nuget packages I installed on my system
Try to add Microsoft.EntityFrameworkCore.Design in your project.
If you are using asp.net core 2.2(2.1+), you do not need to add additional EF core packages which are included in the Microsoft.AspNetCore.App metapackage. The default .csproj file is:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<UserSecretsId>aspnet-{Project Name}-{GUID}</UserSecretsId>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.0" />
</ItemGroup>
</Project>
For asp.net core 2.0,
<Project Sdk = "Microsoft.NET.Sdk.Web" >
< PropertyGroup >
< TargetFramework > netcoreapp2.0</TargetFramework>
<UserSecretsId>aspnet-{Project Name}-{GUID}</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include = "Microsoft.AspNetCore.All" Version="2.0.9" />
<PackageReference Include = "Microsoft.EntityFrameworkCore.Tools" Version="2.0.3" PrivateAssets="All" />
<PackageReference Include = "Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.4" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include = "Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.3" />
<DotNetCliToolReference Include = "Microsoft.Extensions.SecretManager.Tools" Version="2.0.2" />
<DotNetCliToolReference Include = "Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />
</ItemGroup>
</Project>
You could show your .csproj file(Right-click project -> Edit csproj) and check the missing packages.
I upgraded my .netcore SDK software to 2.2 so I could run asp.netcore MVC 2.2 since all my nuget packages are versions 2.2.n....it is working well and I've been able to add migration ....thanks to you all for your help
I'm trying to run an ASP.NET Core project referencing .NET framework in 64-bit mode, but it seems to be running in 32-bit mode.
What I've tried is creating two simple default ASP.NET Core 2.0 projects. One referencing .NET Framework, and one referencing .NET Core. Like this:
Project 1:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="2.0.4" PrivateAssets="All" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.3" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.0.3" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />
</ItemGroup>
</Project>
Project 2:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.8" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />
</ItemGroup>
</Project>
Then, in Startup.cs i use the following code to check if I'm in 32- or 64-bit mode:
var size = IntPtr.Size;
For Project 1 size is 4. For Project 2 size is 8.
Isn't it possible to run .NET Framework applications in 64-bit mode?
I'm on 64-bit Windows 10, debugging the project in Visual Studio 15.7.3 (with IIS Express 10)
Edit:
The projects are configured to run using AnyCPU.