Skip to main content

Using the .NET Upgrade Assistant to upgrade a Windows Forms App–Part I

About 10 years ago I was part of a team that created a rather big Windows Forms application. It took us over 2 years to build the application and at that time it was the largest application I had ever built(to give you an idea, the requirements document was over 1000 pages). Today, 10 years later, this application is still in use and recently I was requested to help introduce a new module in this application.

As Windows Forms got ported to .NET Core, I thought it would be a good idea to to see if I could easily port this application to .NET Core. Microsoft created the .NET Upgrade Assistant exactly for use cases like this.

Install the .NET Upgrade Assistant

The .NET Upgrade assistant is available as a global tool and can be installed with the following command:

dotnet tool install -g upgrade-assistant

Analyze your app before upgrading

As the real migration process can take up a lot of time, the .NET Upgrade Assistant tool includes an analyze mode that performs a simplified dry run of upgrading your app. This already gives you a good idea on what changes may be required before the upgrade is started and what could be possible show-stoppers.

We open up a terminal and browse to the solution folder of our application. There we execute the following command:

upgrade-assistant analyze <solutionname>.sln

Here is the output for our application:

C:\projects\DOG\Main\Source\VLM.DOG>upgrade-assistant analyze


Microsoft .NET Upgrade Assistant v0.3.310801+057ffba0656270dc5d83c015748ac56daed55886

We are interested in your feedback! Please use the following link to open a survey:


[20:46:23 INF] Loaded 6 extensions



The .NET tools collect usage data in order to help us improve your experience. The data is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_UPGRADEASSISTANT_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about Upgrade Assistant telemetry:

Read more about .NET CLI Tools telemetry:

[20:46:25 INF] Using MSBuild from C:\Program Files\dotnet\sdk\6.0.300\

[20:46:25 INF] Using Visual Studio install from C:\Program Files\Microsoft Visual Studio\2022\Professional [v17]

[20:46:32 INF] Writing output to C:\projects\DOG\Main\Source\VLM.DOG\AnalysisReport.sarif

[20:46:32 INF] Marking assembly reference System.ServiceModel for removal based on package mapping configuration System.ServiceModel

[20:46:32 INF] Adding package System.ServiceModel.Primitives based on package mapping configuration System.ServiceModel

[20:46:32 INF] Adding package System.ServiceModel.Http based on package mapping configuration System.ServiceModel

[20:46:32 INF] Adding package System.ServiceModel.Duplex based on package mapping configuration System.ServiceModel

[20:46:32 INF] Adding package System.ServiceModel.NetTcp based on package mapping configuration System.ServiceModel

Remark: I have only pasted a small subset of the output. If you are interested in the full log file, have a look here.

Some interesting things to notice in the logs:

  • The upgrade-assistant installs Roslyn Analyzer packages in your projects. These packages do the real work of analyzing your application.
  • The Microsoft.Windows.Compability nuget is added as well to extend the API surface of .NET Standard 2.0 and introduce a set of missing API’s and functionality.
  • The upgrade analyzer recommends to use the net6.0-windows target framework moniker (TFM). This is because the projects referenced by the solution are Windows Forms projects, a Windows-only technology.
  • I got some ‘Diagnostic UA0002 with the message This type is not supported on .NET Core/.NET 5+ and should be replaced with a modern equivalent’ messages with no clear indication on the type the message was refering to.
  • I got some ‘Diagnostic UA0013_I with the message Windows Forms Deprecated controls : Microsoft.Reporting.WinForms.ReportViewer is no longer supported’ messages indicating that I could no longer use the ReportViewer control.

I also got 2 types of warnings:

  • One type of warnings was related to a Detected package downgrade:
[WRN] [NuGet] Detected package downgrade: System.ServiceModel.Security from 4.9.0 to 4.8.1. Reference the package directly from the project to select a different version. project -> Microsoft.Windows.Compatibility 6.0.0 -> System.ServiceModel.Security (>= 4.9.0) project -> System.ServiceModel.Security (>= 4.8.1)
  • The other one was related to the HighDPI mode in WinForms:

[WRN] HighDpiMode needs to set in Main() instead of app.config or app.manifest - Application.SetHighDpiMode(HighDpiMode.<setting>). It is recommended to use SystemAware as the HighDpiMode option for better results.

We'll have a look on how to get rid of these messages before we start the upgrade. But I'll leave that for another post.

Popular posts from this blog

XUnit - Assert.Collection

A colleague asked me to take a look at the following code inside a test project: My first guess would be that this code checks that the specified condition(the contains) is true for every element in the list.  This turns out not to be the case. The Assert.Collection expects a list of element inspectors, one for every item in the list. The first inspector is used to check the first item, the second inspector the second item and so on. The number of inspectors should match the number of elements in the list. An example: The behavior I expected could be achieved using the Assert.All method:

Angular --deploy-url and --base-href

As long you are running your Angular application at a root URL (e.g. ) you don’t need to worry that much about either the ‘--deploy-url’ and ‘--base-href’ parameters. But once you want to serve your Angular application from a server sub folder(e.g. ) these parameters become important. --base-href If you deploy your Angular app to a subfolder, the ‘--base-href’ is important to generate the correct routes. This parameter will update the <base href> tag inside the index.html. For example, if the index.html is on the server at /angularapp/index.html , the base href should be set to <base href="/angularapp/"> . More information: --deploy-url A second parameter that is important is ‘--deploy-url’. This parameter will update the generated url’s for our assets(scripts, css) inside the index.html. To make your assets available at /angularapp/, the deploy url should

Azure DevOps/ GitHub emoji

I’m really bad at remembering emoji’s. So here is cheat sheet with all emoji’s that can be used in tools that support the github emoji markdown markup: All credits go to rcaviers who created this list.