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

    Spread Windows Forms supports .NET 6 platform. If you want to migrate a .NET Framework project to .NET 6 platform, go through the detailed steps mentioned in this topic.

    The following steps consider 'GrapeCity.AgingReport' as a sample .NET Framework project which needs to be migrated to .NET 6 platform. You can also locate this project on your system at C:\Program Files (x86)\Mescius\Spread.NET [version]\Windows Forms\[version]\Samples\C#\Spread.Examples\ after you install SpreadWin successfully.

    Step 1: Analyze Portability

    (This section helps you to check if the code in your project is portable and supported on .NET 6 platform. You can ignore this section if you are already clear about the project portability.)

    1. Open the GrapeCity.AgingReport.sln file in Visual Studio 2019 v16.8+.
    2. Click on Extensions > Manage Extensions in Visual Studio 2019 v16.8+ tabs. In Manage Extensions dialog, search for '.NET Portability Analyzer' and download it.
      Manage Extensions dialog

    3. Right click on the GrapeCity.AgingReport solution and click 'Analyze Assembly Portability'.
      Selecting 'Analyze Assembly Portability' from the context menu

    4. Save the Analysis report on your system and open it to analyze the portability details of your project.
      Portability Analysis Results window

    Note: In this example, the Analysis report shows that the Spread.Common.DataStore project is not 100% supported on .NET Core. You can click on the 'Details' tab of report to see that the issues are related to assemblies (Newtonsoft.Json, System.Data.OleDB). Hence, their latest packages will be installed from NuGet in next section.

    Step 2: Migrate Projects to .NET 6 Platform

    (In this example, there are 3 projects in the solution where GrapeCity.AgingReport project refers to Spread.Common.DataStore and Spread.Common.Feature project. Hence GrapeCity.AgingReport project will be migrated after migrating the other two projects.)

    Migrate Spread.Common.DataStore Project

    1. Right click packages.config in Spread.Common.DataStore project and click 'Migrate packages.config to PackageReference..'.
      Context menu for packages.config

    2. Click Ok in 'Migrate NuGet format to PackageReference - Spread.Common.DataStore' dialog box.
    3. Right click Spread.Common.DataStore project and click 'Unload Project'. Double click Spread.Common.DataStore in Solution Explorer to view Spread.Common.DataStore.csproj file.
      Editor window displaying Spread.Common.DataStore.csproj file

    4. Remove the content of Spread.Common.DataStore.csproj file and copy it in a text file so that Spread.Common.DataStore.csproj file appears blank and you have its backup in a text file.
    5. Add the following code to blank Spread.Common.DataStore.csproj file to change it to project SDK type. Note that the OutputType is "Library" because DataStore project is class library project.
      Spread.Common.DataStore.csproj
      Copy Code
      <Project Sdk="Microsoft.NET.Sdk">
        <PropertyGroup>
          <OutputType>library</OutputType>
          <TargetFramework>net6.0-windows</TargetFramework>
        </PropertyGroup>
      </Project>
      

    6. Find the text "PackageReference" in the backup text file and copy the whole ItemGroup to Spread.Common.DataStore.csproj file.
      Spread.Common.DataStore.csproj
      Copy Code
      <ItemGroup>
        <PackageReference Include="Newtonsoft.Json">
          <Version>11.0.2</Version>
        </PackageReference>
      </ItemGroup>
      

    7. Turn off 'auto generate assembly info' by adding below code to Spread.Common.DataStore.csproj file.
      Spread.Common.DataStore.csproj
      Copy Code
      <PropertyGroup>
          <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
      </PropertyGroup>
      

    8. Install the latest versions of Newtonsoft.Json and System.Data.OleDB from NuGet to make sure that they support .NET 6.
    9. Right click Spread.Common.DataStore in Solution Explorer and click on Reload project. The final content of Spread.Common.DataStore.csproj file will look like below:
      Spread.Common.DataStore.csproj
      Copy Code
      <Project Sdk="Microsoft.NET.Sdk">
       
        <PropertyGroup>
          <OutputType>library</OutputType>
          <TargetFramework>net6.0-windows</TargetFramework>
        </PropertyGroup>
       
        <ItemGroup>
          <PackageReference Include="Newtonsoft.Json">
            <Version>12.0.3</Version>
          </PackageReference>
          <PackageReference Include="System.Data.OleDb" Version="4.7.1" />
        </ItemGroup>
          <PropertyGroup>
              <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
          </PropertyGroup>
      </Project>
      

    10. Rebuild Spread.Common.DataStore project to observe that the build is successful and the project has been successfully migrated to .NET 6 platform.

    Migrate Spread.Common.Features Project

    You can migrate Spread.Common.Features project to .NET 6 platform in the same way as Spread.Common.DataStore project in above section (except the installation of System.Data.OleDB Nuget package in step 8). The final code of Spread.Common.Features.csproj will look like below:

    Spread.Common.Features.csproj
    Copy Code
    <Project Sdk="Microsoft.NET.Sdk">
     
        <PropertyGroup>
            <OutputType>library</OutputType>
            <TargetFramework>net6.0-windows</TargetFramework>
        </PropertyGroup>
     
        <ItemGroup>
            <PackageReference Include="Newtonsoft.Json">
                <Version>12.0.3</Version>
            </PackageReference>     
        </ItemGroup>
        <PropertyGroup>
            <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
        </PropertyGroup>
    </Project>
    

    Rebuild Spread.Common.Features project to observe that the build is successful and the project has been successfully migrated to .NET 6 platform.

    Migrate GrapeCity.AgingReport Project

    You can migrate GrapeCity.AgingReport project to .NET 6 platform in the same way as Spread.Common.DataStore project in above section except the following:

    The final code of  GrapeCity.AgingReport.csproj will look like below:

    GrapeCity.AgingReport.csproj
    Copy Code
    <Project Sdk="Microsoft.NET.Sdk">
     
        <PropertyGroup>
            <OutputType>WinExe</OutputType>
            <TargetFramework>net6.0-windows</TargetFramework>
        </PropertyGroup>
     
        <ItemGroup>
            <ProjectReference Include="..\..\Common\Spread.Common.DataStore\Spread.Common.DataStore.csproj">
                <Project>{6e4896e5-e77c-4276-93d3-f52cc1d3c4a5}</Project>
                <Name>Spread.Common.DataStore</Name>
            </ProjectReference>
            <ProjectReference Include="..\..\Common\Spread.Common.Features\Spread.Common.Features.csproj">
                <Project>{08b57d63-d0ad-431a-819a-c3a00f479feb}</Project>
                <Name>Spread.Common.Features</Name>
            </ProjectReference>
        </ItemGroup>
        
        <PropertyGroup>
            <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
        </PropertyGroup>
    </Project>
    

    Rebuild GrapeCity.AgingReport project to observe that the build is successful and the project has been successfully migrated to .NET 6 platform.

    Step 3: Install SpreadWin NuGet Package

    1. Select NuGet Package Manager > Manage NuGet Packages for Solution from the Visual Studio 2019 v16.8+Tools tab.
      Selecting Nuget Package Manager rom the Tools menu in Visual Studio
    2. Search 'Grapecity.Spread' and install GrapeCity.Spread.WinForms NuGet package in your solution.
      Nuget Package Manager Window
    3. Rebuild the solution to observe that the build is successful. The Grapecity.AgingReport solution is successfully migrated to .NET 6 platform.