How to Migrate .Net Framework to .Net core application

Prabs 1 Reputation point
2021-03-23T11:45:39.21+00:00

Hi,
I have an desktop application with .Net framework 4.5 using Visual Studio 2015.
I want to convert .Net framework 4.5 application(desktop) to .Net Core 3.1 console application in Visual studio 2019
How to approach this?

Please help me on this

.NET CLI
.NET CLI
A cross-platform toolchain for developing, building, running, and publishing .NET applications.
316 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,099 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,109 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Duane Arnold 3,211 Reputation points
    2021-03-23T15:20:12.05+00:00

    The easiest thing you can do IMHO is make the core project and copy the classes from the old project to the core project. Then you'll have to figure out what namespaces a class you copied over to code is not valid in Core and either find the Core equivalent or remove the namespace altogether.

    0 comments No comments

  2. Karen Payne MVP 35,016 Reputation points
    2021-03-23T15:37:15.82+00:00

    Hello,

    To create a .NET Core 3.1 console project you need Visual Studio 2019 as Visual Studio 2015 and Visual Studio 2017 don't support .NET Core 3.1

    Also note that references are done differently in .NET Core than .NET Framework e.g. lets say you need to connect to a database, (not saying you do) in .NET Framework the reference is in the project while in .NET Core you need to add an NuGet package.

    Otherwise if you are not doing much outside normal coding you'll be fine.

    Plain Jane project file

    <Project Sdk="Microsoft.NET.Sdk">
    
      <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>netcoreapp3.1</TargetFramework>
      </PropertyGroup>
    
    </Project>
    

    With a database provider

    <Project Sdk="Microsoft.NET.Sdk">
    
        <PropertyGroup>
            <OutputType>Exe</OutputType>
            <TargetFramework>netcoreapp3.1</TargetFramework>
        </PropertyGroup>
    
        <ItemGroup>
            <PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
        </ItemGroup>
    
    </Project>
    
    0 comments No comments

  3. Ken Tucker 5,846 Reputation points
    2021-03-28T10:23:37.387+00:00

    At the .net conf focus on windows they talked about a tool the upgrade assistant. It helps move .net framework desktop apps to .net 5. Maybe you could move it to .net 5 and then change the target framework to .net core 3.1

    https://dotnet.microsoft.com/platform/upgrade-assistant

    0 comments No comments