Spread Windows Forms 17
Spread Windows Forms 17.0 Product Documentation / Developer's Guide / Working with the Component / Migrate .NET Framework Project to .NET 8 Platform
In This Topic
    Migrate .NET Framework Project to .NET 8 Platform
    In This Topic

    Spread for WinForms supports the .NET 8 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.

    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.


    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.

       

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

       

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


    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..


    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.


    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.
      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 <OutputType> is "WinExe".
      .csproj file
      Copy Code
      <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 <ItemGroup>, and paste it inside the <Project> section of the .csproj file.
      .csproj file
      Copy Code
      <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".
      .csproj file
      Copy Code
      <PropertyGroup>
          <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
      </PropertyGroup>
      
         
    9. Right-click on the project and select Reload Project.



      The final content of the .csproj file will look like below:
      .csproj file
      Copy Code
      <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.


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

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