How to Upgrade to ASP.NET Core 2.0 - c#

I have an ASP.NET Core project. It is .NET Framework based. I have been working with .NET Version 4.6, but am happy to upgrade to 4.6.2 or 4.7. I have both installed on my machine. The referenced NuGet packages are numerous and version numbers varied. But, it seems that roughly speaking, I am using version 1.1.3 of ASP.NET Core.
I want to upgrade to the latest version of ASP.NET Core and ASP.NET Core MVC but every time I try, I get this error message:
Could not install package 'Microsoft.AspNetCore.Mvc.Core 2.0.0'. You
are trying to install this package into a project that targets
'.NETFramework,Version=v4.7', but the package does not contain any
assembly references or content files that are compatible with that
framework. For more information, contact the package author.
After Googling for this, I came across this disconcerting Github thread:
https://github.com/aspnet/home/issues/2022
This seems to imply that at some point, V2 was not supported by the .NET Framework. I read through the thread to some extent, but these words from another user basically some up my thoughts on the subject:
I really don't know what is happening. Why do have many dotnet this
and that. This is really crazy. How do we have keep tracks of this?
No proper documentation on migration from one to another.
The OP was edited to say this:
Edit: the "no .NET Framework support for ASP.NET Core 2.0" plan has
been officially cancelled and running ASP.NET Core 2.0 on .NET Desktop
will be supported in the next previews. For more information, read
Announcing ASP.NET Core 2.0.0-Preview1 and Updates for .NET Web
Developers or watch .NET Standard 2.0 and .NET Core 2.0.
I guess that means that Microsoft planned to fix the problem at some point. But, what I can't work out is whether or not Microsoft have actually fixed this problem.
Is anyone running ASP.NET Core on .NET Framework? Which .NET version? How did you get it working?

As per #Melbourne Developer's suggestion:
Make sure you download the latest .Net Core 2.0 installers.
Create new ASP.Net Core Web Application
Choose .NET Framework from dropdownlist in wizard and ASP.Net Core 2.0
Copy content over to new project. Fixing up all namespace issues/compilation errors

Related

Is my .NET Core 3.1 app portable to .NET 5?

I'm currently trying to port an ASP .NET Core 3.1 application to .NET 5.0.
In my app I use some 3rd party NuGet packages, which rely on .NET Core 3.1 and will not be ported to .NET 5.
Though I try to figure out if my application is fully portable to .NET 5.
In my app, I did the following steps:
I updated the target framework in the .csproj file
<TargetFramework>net5.0</TargetFramework>
Then I updated all NuGet packages - it seems to work fine without errors.
Unfortunately I'm not sure, because in Solution Explorer => Project => Dependencies => Frameworks, I see the usage Microsoft.AspNetCore.App and Microsoft.NETCore.App.
My first question is, is it a problem to use Microsoft.AspNetCore.App and Microsoft.NETCore.App in the same .NET 5 app? What is the difference between those Frameworks?
In a next step I run the .NET Portability Analyzer with target framework .NET 5.0 - the report says it is about 97% portable - but the dependent NuGets in .NET Core 3.1 cannot be altered.
My second question is, can I use .NET Core 3.1 NuGet packages in a .NET 5 application? I cannot change these 3rd party NuGet packages. It seems to work, but I thought it's not possible.
How can I verify if I can fully port my app from .NET Core 3.1 to .NET 5?
You can. Just upgrade all your project dependencies via NuGet to latest stable version and it will let you upgrade your .Net Core 3.1 to .Net 5. I have recently done on two projects working on. One of them is on Dev server working fine without any issue.
On hosting server you need to install .net 5 Hosting Bundle and restart the server... that's it

How to migrate from .NET Framework 4.6 to .NET Core 3.1

I created a new project in VS 2019 in .NET Framework 4.6 and now I want to upgrade it to .NET Core 3.1.
I do not want to do manually because their is ton of code.
How can I do this?
Microsoft published a guide for porting .NET Framework applications to .NET Core:
https://learn.microsoft.com/en-us/dotnet/core/porting/
In a nutshell, it boils down to the following:
Manually convert your dependency and project files.
Ensure that all your dependencies are compatible with .NET Core.
Use the .NET Portability Analyzer to find out if you are using features which are not supported in .NET Core.
Use the .NET API analyzer to find out if you are using features which are not supported on some platforms.
Target .NET Core, fix compile errors and test.
The guide contains detailed descriptions for specific steps (e.g., how to port your WinForms/WPF UI code), which are too long to paraphrase in an SO answer, so be sure to read it carefully.
I do not want to do manually because their is ton of code.
Then you'll have to pay a developer to do that for you. Sorry, but at the time of writing, there is no fully automated .NET Framework -> .NET Core converter available.

What happened to IHtmlContent?

I'm getting ready to update a library to work with ASP.NET Core 3.0. My library provides an implementation of IHtmlContent, which used to live in the Microsoft.AspNetCore.Html.Abstractions package.
That package seems not to have been updated with the release of .NET Core 3.0 — it's still at version 2.2.0 and hasn't been updated in nearly a year. I can't find any documentation for IHtmlContent in the .NET API Browser for version 3.0 either (either by switching the dropdown from the above link to "ASP.NET Core 3.0" or by searching for it).
Where did IHtmlContent move to? Am I meant to continue using the one from the Abstractions package? Where are the docs?

.net core hosting - server has two .net core runtimes installed

Our app was originally built with .net core 1.x. We would like to upgrade to .net core 2.0.
I installed the hosting bundle from here. But now I have the 1.0.0 Runtime and 2.0.5 runtime installed.
Do I need to uninstall the 1.0.0 runtime?
How can I tell which runtime my app will use?
The short answer is that you should read the documentation for .NET Core. As Scott Hanselman (PM of the ASP.NET Core team) has pointed out, multiple versions of the .NET Core runtime can be installed side by side without issue
As user Camilo Terevinto pointed out in their comment, the highest version of the runtime will be used when your app is started.
Microsoft has placed a limited life on the 1.0.0 runtime. Since 2.0.0 introduced major changes, that break applications written in 1.0.0. For a more sustainable environment, you should remove the older runtime, then ensure the latest runtime and hosted core package are installed. Those can be found on the document page.
To determine the runtime your application is utilizing, you can find that information within your project. The assembly will include the information of which framework you're actually targeting against.

Combine ASP.NET and ASP.NET core in the same solution

I am creating a solution using ASP.NET Core 1.1 (SDK 1.0.4) and I require to use System.DirectoryServices namespace.
According to this Github issue
they are porting those APIs from the .Net Framework in the upcoming 1.2 version. However, I have seen that you can create an ASP.NET Core app targeting the full .Net Framework. I have follow some tutorials but all of them seem to be outdated (.Net Core 1.0 using project.json) and I have found no way to make it work.
In the same manner, I have seen some Github projects that seem to run ASP.NET Core and System.DirectoryServices namespace using something called DNX (like this one ). However, this project also fails in Visual Studio 2017.
Is there any real solution to have access to System.DirectoryServices on ASP.NET Core?
There might be a hacky way to go about it, but I haven't explored this enough, yet. I have noticed that when you create an "ASP.NET Core Web Application (.NET Core)" project, it doesn't allow you to change the .NET framework version to anything but available .NET Core versions. You'll need to create an "ASP.NET Core Web Application (.NET Framework)" project in order to use the full framework.
If you've already got an existing project you're working on, the best thing I can recommend is to simply create a new "ASP.NET Core Web Application (.NET Framework)" project and migrate your existing code over to that. For the most part, it should just be copy-and-paste. Like I said, there might be some other way, that I just don't know, but you at least have that method.
FWIW, DNX was .NET Core, before it was ".NET Core". There was a somewhat similar setup where you could run DNX on full .NET or just the "core" .NET functionality. It doesn't really help you here.

Categories

Resources