How do I update other Microsoft libraries after updating to .Net Core 3.1 - asp.net

I have a web app solution that is quite old where the main project is Asp.Net 4.6 and a small companion project is .Net Core 2.
I want to first upgrade them both to .Net Core 3.1, and then upgrade to .Net 7 later this year.
According to the Microsoft documentation I have to update the target framework and associated libraries.
So I updated this part in my project file:
<TargetFramework>netcoreapp3.1</TargetFramework>
However, the other referenced libraries don't seem to have 3.1 updates. How would I upgrade these?
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="2.0.3" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.3" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.ServiceModel.Duplex" Version="4.3.0" />
<PackageReference Include="System.ServiceModel.Security" Version="4.3.0" />
Thanks!

When Microsoft introduced .NET Core 3.0, they stopped producing a large number of NuGet packages (If you're interested, you can see the list here).
Microsoft made them part of the shared framework Microsoft.AspNetCore.App that is implicitly referenced if your .csproj targets Microsoft.NET.Sdk.Web SDK. You can check this in your .csproj project.
<Project Sdk="Microsoft.NET.Sdk.Web">
...
</Project>
If your project targets Microsoft.NET.Sdk, then you might have to add a FrameworkReference, as explained here.
Assuming the latter is not your case, removing the references to those NuGet packages should be fine.

For microsoft .net core packages,I think you could search in the document and found the correspond packages.
https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore?view=aspnetcore-2.2
example1:
example2:

Related

Error scaffolding identity in blazor webassembly app

I am building a webassembly project in Razor using Visual Studio 2019 (version 16.9.4) and whenever I try to scaffold the identity I get an error saying that a package restore did not work, and everything is rolled back.
My question is twofold:
How do I solve this error?
Are there any alternatives to the scaffolding of the identity?
Grtz,
Iede Snoek
There is an offical page about this but I found it a little confusing. The Blazor WebAssembly UI is not supported, that makes sense. But the Hosted variation should be just like a Blazor Server project. I think that is what is being said there and that makes sense.
But whewn I gave it a try I got the same error as you did, with packages getting rolled back. And no info on what packages.
So I gave Blazor Server a go, and I kept a watch on the changes. The scaffolding worked and it downgraded some packages from 5.0.5 to 5.0.4 .
After editing the MyProject.Server.csproj the same way scaffolding worked like a charm. The "Manage Packages" UI did not work and I did have to Clean the solution first.
The altered parts of my csproj file:
<Project Sdk="Microsoft.NET.Sdk.Web">
...
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server"
Version="5.0.4" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design"
Version="5.0.2" />
</ItemGroup>
<ItemGroup>
...
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore"
Version="5.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore"
Version="5.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI"
Version="5.0.4" />
<PackageReference Include="Microsoft.AspNetCore.ApiAuthorization.IdentityServer"
Version="5.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer"
Version="5.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools"
Version="5.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
The small version steps make me think this is a very temporary problem.

Reference XtraReport in Dotnet Core application

I would like to create a dotnet core console application that should create pdf report using DevExpress XtraReport.
How can I reference the devexpress dll in my csproj?
Thanks a lot
EDIT:
the project targets net462
This is my csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Https" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="wwwroot/" />
</ItemGroup>
<ItemGroup>
<Content Include="Properties/**">
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="tempkey.rsa">
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
Refer this - Reporting support for .Net core
It's hard to speak about possible estimates here as NET Core 2.0 does
not support System.Drawing, Sörnt. Right now, everything that is
available in .NET Standard 2.0 is a few drawing primitives, that's all
(see diff). On the other hand, implementing a custom drawing library
that would work for any possible target .NET platform is a very
complex task — I'd say it's just as hard as doing a new reporting
engine from scratch. Yes, there are some alternatives for drawing
(e.g., Mono's gdipluslib), but they have a lot of compatibility issues
we need to deal with, not to mention that some areas (like the actual
printing) are not covered at all. Of course, being compatible with the
.NET Standard is something is that we look forward to, but there are
still missing pieces our engine heavily relies on. Needless to say,
the .NET Core development is moving really fast comparing to the
legacy .NET Framework, so it's highly possible that we'll see more and
more features / APIs provided by the corefx team very soon.
It is not yet supported in .net core apps. There may be some workaround to use in asp.net core applications.. See below reference links.
References:
XtraReports in .NET Core
XtraReports for ASP.NET Core
Reporting support for .Net core
XtraReports does support the dotnet core platform starting with v18.1.
https://community.devexpress.com/blogs/reporting/archive/2018/04/26/reporting-net-core-support-ctp-v18-1.aspx
https://docs.devexpress.com/XtraReports/119717/create-end-user-reporting-applications/web-reporting/aspnet-core-reporting

XUnit tests no longer discovered in .Net Core 2

After moving project from .Net Core 1.1 to .Net Core 2 I just noticed that my xUnit tests are not discovered in VS 2017 anymore...
any ideas how to get them back? :)
UPDATE
After some deeper research I found out that my problem related to this error in my test project: "Could not load file or assembly 'System.Runtime, Version=4.1.1.0"
more details here:
https://developercommunity.visualstudio.com/content/problem/95070/could-not-load-file-or-assembly-systemruntime-vers.html
I ran into the exact same issue and after banging my head for a couple of hours I discovered that xunit in .Net Core 2 requires your Target Framework must be netcoreapp2.0 and not netstandard2.0.
Sample working CS Proj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
</ItemGroup>
</Project>

newtonsoft.json 9.0.1 not compatible with netcoreapp1.1 in newly created Visual Studio Project

I created a new ASP.NET Core Web Application in Visual Studio 2017 and immediately got the following error:
Restoring NuGet packages...
Package Newtonsoft.Json 9.0.1 is not compatible with netcoreapp1.1 (.NETCoreApp,Version=v1.1). Package Newtonsoft.Json 9.0.1 supports:
- net20 (.NETFramework,Version=v2.0)
- net35 (.NETFramework,Version=v3.5)
- net40 (.NETFramework,Version=v4.0)
- net45 (.NETFramework,Version=v4.5)
- netstandard1.0 (.NETStandard,Version=v1.0)
- portable-net40+sl5+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile328)
- portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259)
One or more packages are incompatible with .NETCoreApp,Version=v1.1.
NuGet package restore failed.
It seems that Newtonsoft.Json is not compatible with netcoreapp, but why would VisualStudio include it if that is the case? I'm pretty new to ASP.NET so maybe there is something I am missing? I followed the steps from the ASP.NET Core Docs.
While searching I found some similar issues, but none seem to be compatible with VS 2017.
Also here is my .csproj file if it helps:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
</ItemGroup>
</Project>
Ok, I just reinstalled Visual Studio, repaired it from the installer and cleared the NuGet Cache and now it's working. Seems like something wasn't setup correctly.

ASP.NET Core WebApp(.NET Core) missing DataAnnotations

Following situation:
I have a .sln with multiple projects (data-access, business-objects, business-logic, web-server).
The Web-Project is an ASP.NET Core Web Application using .Net-Core 1.1 with the individual user account authorization (Identity) and the "WebApplication"-Template.
The rest of the projects is using the .Net-Framework 4.6.2.
Now I am about to remove the DBContext from the web-server and instead use the same as in the data-access-project.
I set up my ApplicationDBContext accordingly and my User entity extends the IdentityUser. I also changed everything in the web-server-project to use the ApplicationDBContext (in my case called WTHListModell).
I also has the references to the projects WTHList.GO (business-objects) and WTHList.DZ (data-access).
Now here comes the problem:
Doing this using the full .NET-Framework for the Web-Server (creating a ".NET-Core Web-Application (.Net-Framework)" ) is successful and works just fine.
With .Net-Core 1.1 I am getting a FileNotFound-Exception regarding "System.ComponentModel.DataAnnotations" whenever I try to either log-in or register a user.
Now I have read, that DataAnnotations isn't compatible with .Net-Core and I also tried to add other NuGet-Packages and Assemblies to the Web-Project.
I don't know what else I can do about that, because I am supposed to use the .NET-Core Framework 1.1 for the Web-Projekt and it keeps on giving me this particular error.
Has anybody got a clue on how to solve this issue?
I have searched for a while now and I haven't found a solution for this yet...
And if it has any relevance: I am using the VS2017 Enterprise RC.
Thanks in advance.
UPDATE
This is the content of the csproj file:
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup Label="Globals">
<SccProjectName>SAK</SccProjectName>
<SccProvider>SAK</SccProvider>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>
<PropertyGroup>
<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
</PropertyGroup>
<PropertyGroup>
<UserSecretsId>aspnet-WTHList.Web2-ab5b6dbd-698d-4877-a2b3-6dd9b7a37960</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.0" />
<PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink.Loader" Version="14.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0-preview4-final" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.0.0-msbuild2-final" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0-msbuild2-final" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0-msbuild2-final" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0-msbuild2-final" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WTHList.DZ\WTHList.DZ.csproj" />
<ProjectReference Include="..\WTHList.GL\WTHList.GL.csproj" />
<ProjectReference Include="..\WTHList.GO\WTHList.GO.csproj" />
</ItemGroup>
</Project>
Don't be confused with different "Core" terms: .NET Core is new "base" framework, which "looks like" .NET Framework 4.5 (4.6, etc), but this is other framework. You can compile multiple versions of same project (for different frameworks) at once.
ASP.NET Core is like old ASP.NET, but a new one. It is compiled twice - once for .NET Framework 4.5.1 (and "compatible" 4.5.2, 4.6, 4.6.1) and once for .NET Core (actually, for netstandart1.6 which is some kind of "specification", which is implemented by NET Core).
So, you can create web apps using ASP.NET Core which can build/run on .NET Framework 4.5.1 and/or on .NET Core. But you need all dependencies to be also build on (compatible with) .NET Framework 4.5.1 and/or on .NET Core.
So, if your app require some libraries (e.g. System.ComponentModel.DataAnnotations) which is not available for NET Core - you can't build/run app on .NET Core. You can only build ASP.NET Core app on top of .NET Framework 4.5.1+.

Resources