SDK
latest
false
Banner background image
Developer Guide
Last updated Mar 23, 2024

Migrating Activities to .NET 6

This page offers an overview of how to migrate your custom .NET Framework activities to .NET 6 for use in projects with the Windows compatibility available starting with Studio 2021.10.6.

We will use the sample MathSquareOfSum .NET Framework activity documented on the Creating Activities With Code (Legacy) page as an example for a migration to .NET 6 that targets Windows while also maintaining compatibility with .NET Framework for Windows - Legacy projects.

Step 1: Migrate the project to the new SDK-style format and add the net6.0-windows target

A project that is using the .NET Framework project format must be migrated to the new SDK-style format. For more information, see the Microsoft documentation. Package references must be declared in the .csproj file as opposed to packages.config.

  1. In Solution Explorer, right click the project and select Unload Project.
  2. Copy references and clear everything from the .csproj file.
  3. Manually update the .csproj file to the new format.
  4. Add the target framework net6.0-windows.
  5. Mark the original references as net461 only by adding a condition.
  6. Add a new reference section with conditions for net6.0-windows. You must declare the following WWF dependencies for .NET: UiPath.Workflow.Runtime, UiPath.Workflow, System.Activities.Core.Presentation, System.Activities.Metadata. Make sure all your dependencies support .NET. You might need to find newer package versions or replacement packages.
  7. In Solution Explorer, right click the project and select Reload Project.

The file should look as follows.

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop" ToolsVersion="Current">
  <PropertyGroup>
    <TargetFrameworks>net461;net6.0-windows</TargetFrameworks>
    <AssemblyName>MathSquareOfSum</AssemblyName>
    <RootNamespace>MathSquareOfSum</RootNamespace>
    <UseWpf>true</UseWpf>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
  </PropertyGroup>
  <ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
    <Reference Include="PresentationCore" />
    <Reference Include="PresentationFramework" />
    <Reference Include="System" />
    <Reference Include="System.Activities" />
    <Reference Include="System.Activities.Core.Presentation" />
    <Reference Include="System.Activities.Presentation" />
    <Reference Include="System.ComponentModel.Composition" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xaml" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Xml" />
    <Reference Include="WindowsBase" />
  </ItemGroup>
  <ItemGroup Condition=" '$(TargetFramework)' == 'net6.0-windows' ">
    <PackageReference Include="UiPath.Workflow.Runtime" Version="6.0.0-20220401-03" PrivateAssets="All" />
    <PackageReference Include="UiPath.Workflow" Version="6.0.0-20220401-03" PrivateAssets="All" />
    <PackageReference Include="System.Activities.Core.Presentation" Version="6.0.0-20220318.2" PrivateAssets="All" />
    <PackageReference Include="System.Activities.Metadata" Version="6.0.0-20220318.2" PrivateAssets="All" />
  </ItemGroup>
</Project><Project Sdk="Microsoft.NET.Sdk.WindowsDesktop" ToolsVersion="Current">
  <PropertyGroup>
    <TargetFrameworks>net461;net6.0-windows</TargetFrameworks>
    <AssemblyName>MathSquareOfSum</AssemblyName>
    <RootNamespace>MathSquareOfSum</RootNamespace>
    <UseWpf>true</UseWpf>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
  </PropertyGroup>
  <ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
    <Reference Include="PresentationCore" />
    <Reference Include="PresentationFramework" />
    <Reference Include="System" />
    <Reference Include="System.Activities" />
    <Reference Include="System.Activities.Core.Presentation" />
    <Reference Include="System.Activities.Presentation" />
    <Reference Include="System.ComponentModel.Composition" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xaml" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Xml" />
    <Reference Include="WindowsBase" />
  </ItemGroup>
  <ItemGroup Condition=" '$(TargetFramework)' == 'net6.0-windows' ">
    <PackageReference Include="UiPath.Workflow.Runtime" Version="6.0.0-20220401-03" PrivateAssets="All" />
    <PackageReference Include="UiPath.Workflow" Version="6.0.0-20220401-03" PrivateAssets="All" />
    <PackageReference Include="System.Activities.Core.Presentation" Version="6.0.0-20220318.2" PrivateAssets="All" />
    <PackageReference Include="System.Activities.Metadata" Version="6.0.0-20220318.2" PrivateAssets="All" />
  </ItemGroup>
</Project>
Check the code in the .cs file for each target for missing references and update the references in the .csproj file if needed.


Important: Do not include the referenced packages in the NuGet package or add them as dependencies in the package metadata. Including the referenced packages results in a failure to install the package in Studio.

Step 2: Build the solution

Make sure you test the project for errors before attempting to build it.

From the Build menu, select Build Solution. The DLL libraries are built and saved in the following location in separate folders for each target framework: %UserProfile%\source\repos\MathSquareOfSum\MathSquareOfSum\bin\Debug

Step 3: Create a NuGet package

Create a NuGet package using NuGet Package Explorer, as described in Creating Activities With Code (Legacy).

  1. Launch NuGet Package Explorer and click Create a new package (Ctrl + N). A split-window is displayed which shows Package metadata and Package contents. We need to add all dependencies in the latter section.
  2. Right-click inside the Package contents section. A context menu is displayed.
  3. Click Add lib folder. Notice a new lib item is created in the Package contents section.
  4. Right-click lib twice and select as follows:
    • Add .NET Framework folder > v4.6.1
    • Add .NET folder > v6.0-windows
  5. Right-click each of the folders added in the previous step and select Add Existing File to load the external assembly (.dll) files required for each one. The files are located in a subfolder with the framework name located in the \bin\Debug folder:
    • net461 - MathSquareOfSum.dll
    • net6.0-windows - MathSquareOfSum.dll
  6. Rename the folder net6.0-windows to net6.0-windows7.0.
  7. With the file selected, access the Edit menu and select Edit Metadata. The left panel is now fitted with editable metadata fields.
  8. Edit the metadata fields as needed.
  9. Select Edit dependencies, and then add the following target frameworks: net461 and net6.0-windows7.0.


  10. Click the green check mark button in the top-left corner save all changes.
  11. Select File > Save As to save the new file.

Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.