[]
        
(Showing Draft Content)

Migrate .NET Framework Project to .NET 8 Platform

Spread for WinForms supports the .NET 8 or later platform. If you want to migrate your .NET Framework projects/solutions to the .NET 8+ platform, follow the step-by-step instructions provided in this topic.

Note: The steps outlined below are based on an example of migrating a.NET 4.8 Framework project to the.NET 8 platform.

Step 1: Analyze portability and start upgrade process.

The portability analyzer is not yet available in Visual Studio 2022. Therefore, you can update your application using the steps given below.

  1. Open the solution in Visual Studio 2022.

  2. Select Tools > Command Line > Developer Command Prompt.

    Spread.NET developers select Tools, Command Line, and Developer Command Prompt in Visual Studio before running Upgrade Assistant.

  3. Run the following command to install upgrade-assistant.

    dotnet tool install -g upgrade-assistant
  4. Run the following command to upgrade your solution.

    upgrade-assistant upgrade <solution file path>

    For example: upgrade-assistant upgrade C:\Users\project\solution_file.sln

    Depending on the project type you are upgrading, you may also be given the option to specify different styles of upgrade before proceeding, such as:

    • In-place project upgrade: This option upgrades the project without creating a copy.

    • Side-by-side project upgrade: This option is available only for .NET Framework projects. It copies the project, upgrades the copy, and leaves the original project alone.

    Spread.NET developers choose an in-place or side-by-side project upgrade option in Upgrade Assistant when migrating the Windows Forms project.

    Additionally, if you have multiple target frameworks available for upgrade, you need to select the desired target framework.

    Spread.NET developers select .NET 8.0 as the preferred target framework in Upgrade Assistant for the Windows Forms migration.

    When you select the target framework, press Y to confirm and to start the upgrade.

    Spread.NET developers confirm the Upgrade Assistant prompt with Y after reviewing all required migration options for the project.

  5. If any errors or warnings occur, review and fix them to continue.

For more information on .NET upgrade assistance, refer to Overview of the.NET Upgrade Assistant.

Step 2: Port your project to the .NET 8 platform.

Note that if your project's packages.config file does not have NuGet references, you can skip the first two steps of migrating the NuGet format to PackageReference and proceed directly to step 3 of this section.

  1. In the Solution Explorer, right-click on packages.config in your project and select Migrate Packages.config to PackageReference...

    Spread.NET developers right-click packages.config in Solution Explorer and select Migrate packages.config to PackageReference before upgrading the project.

  2. Select OK in the Migrate NuGet formats to PackageReference dialog.

  3. In the Solution Explorer, right-click on your Winforms project and click Unload Project.

    Spread.NET developers select Unload Project from the Visual Studio Solution Explorer context menu before editing the project file.

  4. Double-click on the project file to view the .csproj file of the project.

  5. Delete the content of the .csproj file and make it blank.

    Note: Make sure that you copy the content to a text file for backup before deleting.

  6. Add the following code to the blank .csproj file and change it to project SDK type.

    Here, the project is a Windows Forms Application project, so the is "WinExe".

    <Project Sdk="Microsoft.NET.Sdk">
            <PropertyGroup>
                    <OutputType>WinExe</OutputType>
                    <TargetFramework>net8.0-windows</TargetFramework>
                    <UseWindowsForms>true</UseWindowsForms>
            </PropertyGroup>
    </Project>
  7. Find the text "PackageReference" in the backup text file, copy the entire , and paste it inside the section of the .csproj file.

    <ItemGroup>
        <PackageReference Include="GrapeCity.Spread.WinForms">
          <Version>x.x.x.x</Version>
        </PackageReference>
    </ItemGroup>
  8. Add the following code to your .csproj file to turn off "Auto-generate assembly information".

    <PropertyGroup>
        <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
    </PropertyGroup>
  9. Right-click on the project and select Reload Project.

    Spread.NET developers select Reload Project in Solution Explorer after updating the Windows Forms project file for .NET 8.


    The final content of the .csproj file will look like below:

    <Project Sdk="Microsoft.NET.Sdk">
    
     <PropertyGroup>
      <OutputType>WinExe</OutputType>
      <TargetFramework>net8.0-windows</TargetFramework>
      <UseWindowsForms>true</UseWindowsForms>
     </PropertyGroup>
    
     <ItemGroup>
      <PackageReference Include="GrapeCity.Spread.WinForms">
       <Version>x.x.x.x</Version>
      </PackageReference>
     </ItemGroup>
    
     <PropertyGroup>
      <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
     </PropertyGroup>
    
    </Project>

Step 3: Install the SpreadWin Nuget package

  1. From the Tools tab in Visual Studio 2022 or higher versions, select NuGet Package Manager > Manage NuGet Packages for Solution.

    Spread.NET developers open Tools, NuGet Package Manager, and Manage NuGet Packages for Solution in Visual Studio after migration.

  2. Search for "Grapecity.Spread" and install the GrapeCity.Spread.WinForms NuGet package into your solution.

    Spread.NET developers find GrapeCity.Spread.WinForms in NuGet Package Manager and install the package into the migrated .NET 8 project.

  3. Once installed, rebuild the solution, and verify that the project is successfully migrated to the .NET 8 platform.