Skip to content

Commit 7cdc2af

Browse files
authored
Update porting overview and dependencies section (#14621)
* Update porting overview and dependencies section * Apply suggestions from code review Co-Authored-By: Maira Wenzel <mairaw@microsoft.com> * Changes based on feedback * More rewording in overview to make some items clearer * Update suggested tool to convert * Apply suggestions from code review Co-Authored-By: Maira Wenzel <mairaw@microsoft.com> * Updates based on feedback
1 parent a70b898 commit 7cdc2af

File tree

2 files changed

+44
-66
lines changed

2 files changed

+44
-66
lines changed

docs/core/porting/index.md

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,46 @@
11
---
2-
title: Port code from .NET Framework to .NET Core
2+
title: Port from .NET Framework to .NET Core
33
description: Understand the porting process and discover tools you may find helpful when porting a .NET Framework project to .NET Core.
44
author: cartermp
5-
ms.date: 09/13/2019
5+
ms.date: 10/22/2019
66
ms.custom: seodec18
77
---
8-
# Port your code from .NET Framework to .NET Core
8+
# Overview of the porting process from .NET Framework to .NET Core
99

10-
If you've got code that runs on the .NET Framework, you may be interested in running your code on .NET Core, too. Here's an overview of the porting process and a list of the tools you may find helpful when porting your code to .NET Core.
10+
You might have code that currently runs on the .NET Framework that you're interested in porting to .NET Core. This article provides:
1111

12-
## Overview of the porting process
13-
14-
This is the process we recommend you take when porting your project to .NET Core. Each step of the process is covered in more detail in further articles.
12+
* An overview of the porting process.
13+
* A list of the tools you may find helpful when you're porting your code to .NET Core.
1514

16-
1. Identify and account for your third-party dependencies.
15+
## Overview of the porting process
1716

18-
This step involves understanding what your third-party dependencies are, how you depend on them, how to check if they also run on .NET Core, and steps you can take if they don't. It also covers how you can migrate your dependencies over to the [PackageReference](/nuget/consume-packages/package-references-in-project-files) format that is used in .NET Core.
17+
We recommend you to use the following process when porting your project to .NET Core:
1918

20-
2. Retarget all projects you wish to port to target the .NET Framework 4.7.2 or higher.
19+
1. Retarget all projects you wish to port to target the .NET Framework 4.7.2 or higher.
2120

2221
This step ensures that you can use API alternatives for .NET Framework-specific targets when .NET Core doesn't support a particular API.
2322

24-
3. Use the [.NET Portability Analyzer](../../standard/analyzers/portability-analyzer.md) to analyze your assemblies and develop a plan to port based on its results.
23+
2. Use the [.NET Portability Analyzer](../../standard/analyzers/portability-analyzer.md) to analyze your assemblies and see if they're portable to .NET Core.
24+
25+
The API Portability Analyzer tool analyzes your compiled assemblies and generates a report. This report shows a high-level portability summary and a breakdown of each API you're using that isn't available on NET Core.
2526

26-
The API Portability Analyzer tool analyzes your compiled assemblies and generates a report that shows a high-level portability summary and a breakdown of each API you're using that isn't available on targeted .NET Core platform public surface. You can use this report alongside an analysis of your codebase to develop a plan for how you'll port your code over.
27+
3. Install the [.NET API analyzer](../../standard/analyzers/api-analyzer.md) into your projects to identify APIs throwing <xref:System.PlatformNotSupportedException> on some platforms and some other potential compatibility issues.
2728

28-
4. Once you have your project file converted to your targeted .NET Core version, you can use Roslyn based [.NET API analyzer](../../standard/analyzers/api-analyzer.md) to identify APIs throwing <xref:System.PlatformNotSupportedException> on some platforms and some other potential compatibility issues.
29+
This tool is similar to the portability analyzer, but instead of analyzing if things can build on .NET Core, it will analyze if you're using an API in a way that will throw the <xref:System.PlatformNotSupportedException> at runtime. Although this isn't common if you're moving from .NET Framework 4.7.2 or higher, it's good to check.
2930

30-
5. Port your tests code.
31+
4. Convert all of your `packages.config` dependencies to the [PackageReference](/nuget/consume-packages/package-references-in-project-files) format with the [conversion tool in Visual Studio](/nuget/consume-packages/migrate-packages-config-to-package-reference).
3132

32-
Because porting to .NET Core is such a significant change to your codebase, it's highly recommended to get your tests ported, so that you can run tests as you port your code over. MSTest, xUnit, and NUnit all support .NET Core.
33+
This step involves converting your dependencies from the legacy `packages.config` format. `packages.config` doesn't work on .NET Core, so this conversion is required if you have package dependencies.
3334

34-
6. Execute your plan for porting!
35+
5. Create new projects for .NET Core and copy over source files, or attempt to convert your existing project file with a tool.
3536

36-
The following list shows tools you might find helpful to use during the porting process:
37+
.NET Core uses a simplified (and different) [project file format](../tools/csproj.md) than .NET Framework. You'll need to convert your project files into this format to continue.
3738

38-
- .NET Portability Analyzer - [command-line tool](https://github.com/Microsoft/dotnet-apiport/releases) or [Visual Studio Extension](https://marketplace.visualstudio.com/items?itemName=ConnieYau.NETPortabilityAnalyzer), a tool that can generate a report of how portable your code is between .NET Framework and your target .NET Core platform. The report contains an assembly-by-assembly breakdown of the Type and APIs missing on the target .NET Core platform. For more information, see [.NET Portability Analyzer](../../standard/analyzers/portability-analyzer.md). It is recommended to run the .NET Portability Analyzer tool before you start porting, as it will help you identify any gaps in missing APIs in specific targeted .NET platform public surface.
39-
- .NET API Analyzer - A Roslyn analyzer that discovers .NET Standard API that throws <xref:System.PlatformNotSupportedException> on some platforms, detects calls to deprecated APIs, and discovers some other potential compatibility risks for C# APIs on different platforms. For more information, see [.NET API analyzer](../../standard/analyzers/api-analyzer.md). This analyzer is helpful after you already created your .NET Core project to identify runtime behavior differences on different platforms.
40-
- Reverse Package Search - A [useful web service](https://packagesearch.azurewebsites.net) that allows you to search for a type and find packages containing that type.
39+
6. Port your test code.
4140

42-
Additionally, you can attempt to port smaller solutions or individual projects to the .NET Core project file format with the [CsprojToVs2017](https://github.com/hvanbakel/CsprojToVs2017) tool.
41+
Because porting to .NET Core is such a significant change to your codebase, it's highly recommended to get your tests ported, so that you can run tests as you port your code over. MSTest, xUnit, and NUnit all work on .NET Core.
4342

44-
> [!WARNING]
45-
> CsprojToVs2017 is a third-party tool. There is no guarantee that it will work for all of your projects, and it may cause subtle changes in behavior that you depend on. CsprojToVs2017 should be used as a _starting point_ that automates the basic things that can be automated. It is not a guaranteed solution to migrating project file formats.
43+
Additionally, you can attempt to port smaller solutions or individual projects to the .NET Core project file format with the [dotnet try-convert](https://github.com/dotnet/try-convert) tool in one operation. `dotnet try-convert` is not guaranteedto work for all your projects, and it may cause subtle changes in behavior that you may find that you depended on. It should be used as a _starting point_ that automates the basic things that can be automated. It isn't a guaranteed solution to migrating a project.
4644

4745
>[!div class="step-by-step"]
4846
>[Next](net-framework-tech-unavailable.md)

docs/core/porting/third-party-deps.md

Lines changed: 23 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,34 @@
22
title: Analyze dependencies to port code to .NET Core
33
description: Learn how to analyze external dependencies in order to port your project from .NET Framework to .NET Core.
44
author: cartermp
5-
ms.date: 12/07/2018
5+
ms.date: 10/22/2019
66
ms.custom: seodec18
77
---
88
# Analyze your dependencies to port code to .NET Core
99

10-
To port your code to .NET Core or .NET Standard, you must understand your dependencies. External dependencies are the [NuGet packages](#analyze-referenced-nuget-packages-in-your-projects) or [DLLs](#analyze-dependencies-that-arent-nuget-packages) you reference in your project, but that you don't build. Evaluate each dependency and develop a contingency plan for the ones that aren't compatible with .NET Core. Here's how to determine if a dependency is compatible with .NET Core.
10+
To port your code to .NET Core or .NET Standard, you must understand your dependencies. External dependencies are the NuGet packages or `.dll`s you reference in your project, but that you don't build yourself.
1111

12-
## Analyze referenced NuGet packages in your projects
12+
## Migrate your NuGet packages to `PackageReference`
1313

14-
If you reference NuGet packages in your project, you need to verify if they're compatible with .NET Core.
15-
There are two ways to accomplish that:
14+
.NET Core uses [PackageReference](/nuget/consume-packages/package-references-in-project-files) to specify package dependencies. If you're using [packages.config](/nuget/reference/packages-config) to specify your packages in your project, you need to convert it to the `PackageReference` format because `packages.config` isn't supported in .NET Core.
1615

17-
- [Using the NuGet Package Explorer app](#analyze-nuget-packages-using-nuget-package-explorer)
18-
- [Using the nuget.org site](#analyze-nuget-packages-using-nugetorg)
16+
To learn how to migrate, see the [Migrate from packages.config to PackageReference](/nuget/reference/migrate-packages-config-to-package-reference) article.
1917

20-
After analyzing the packages, if they're not compatible with .NET Core and only target .NET Framework, you can check if the [.NET Framework compatibility mode](#net-framework-compatibility-mode) can help with your porting process.
18+
## Upgrade your NuGet packages
19+
20+
After your migrating your project to the `PackageReference` format, you need to verify if your packages are compatible with .NET Core.
21+
22+
First, upgrade your packages to the latest version that you can. This can be done with the NuGet Package Manager UI in Visual Studio. It's likely that newer versions of your package dependencies are already compatible with .NET Core.
23+
24+
## Analyze your package dependencies
25+
26+
If you haven't already verified that your converted and upgraded package dependencies work on .NET Core, there are a few ways that you can achieve that:
27+
28+
### Analyze NuGet packages using nuget.org
29+
30+
You can see the Target Framework Monikers (TFMs) that each package supports on [nuget.org](https://www.nuget.org/) under the **Dependencies** section of the package page.
31+
32+
Although using the site is an easier method to verify the compatibility, **Dependencies** information isn't available on the site for all packages.
2133

2234
### Analyze NuGet packages using NuGet Package Explorer
2335

@@ -31,43 +43,17 @@ The easiest way to inspect NuGet Package folders is to use the [NuGet Package Ex
3143
4. Select the package name from the search results and click **open**.
3244
5. Expand the *lib* folder on the right-hand side and look at folder names.
3345

34-
Look for a folder with any of the following names:
35-
36-
```
37-
netstandard1.0
38-
netstandard1.1
39-
netstandard1.2
40-
netstandard1.3
41-
netstandard1.4
42-
netstandard1.5
43-
netstandard1.6
44-
netstandard2.0
45-
netcoreapp1.0
46-
netcoreapp1.1
47-
netcoreapp2.0
48-
netcoreapp2.1
49-
netcoreapp2.2
50-
portable-net45-win8
51-
portable-win8-wpa8
52-
portable-net451-win81
53-
portable-net45-win8-wpa8-wpa81
54-
```
46+
Look for a folder with names using one the following patterns: `netstandardX.Y` or `netcoreappX.Y`.
5547

5648
These values are the [Target Framework Monikers (TFMs)](../../standard/frameworks.md) that map to versions of the [.NET Standard](../../standard/net-standard.md), .NET Core, and traditional Portable Class Library (PCL) profiles that are compatible with .NET Core.
5749

5850
> [!IMPORTANT]
5951
> When looking at the TFMs that a package supports, note that `netcoreapp*`, while compatible, is for .NET Core projects only and not for .NET Standard projects.
6052
> A library that only targets `netcoreapp*` and not `netstandard*` can only be consumed by other .NET Core apps.
6153
62-
### Analyze NuGet packages using nuget.org
63-
64-
Alternatively, you can see the TFMs that each package supports on [nuget.org](https://www.nuget.org/) under the **Dependencies** section of the package page.
65-
66-
Although using the site is an easier method to verify the compatibility, **Dependencies** information is not available on the site for all packages.
54+
## .NET Framework compatibility mode
6755

68-
### .NET Framework compatibility mode
69-
70-
After analyzing the NuGet packages, you might find that they only target the .NET Framework, as most NuGet packages do.
56+
After analyzing the NuGet packages, you might find that they only target the .NET Framework.
7157

7258
Starting with .NET Standard 2.0, the .NET Framework compatibility mode was introduced. This compatibility mode allows .NET Standard and .NET Core projects to reference .NET Framework libraries. Referencing .NET Framework libraries doesn't work for all projects, such as if the library uses Windows Presentation Foundation (WPF) APIs, but it does unblock many porting scenarios.
7359

@@ -87,12 +73,6 @@ To suppress the warning by editing the project file, find the `PackageReference`
8773

8874
For more information on how to suppress compiler warnings in Visual Studio, see [Suppressing warnings for NuGet packages](/visualstudio/ide/how-to-suppress-compiler-warnings#suppress-warnings-for-nuget-packages).
8975

90-
## Port your packages to `PackageReference`
91-
92-
.NET Core uses [PackageReference](/nuget/consume-packages/package-references-in-project-files) to specify package dependencies. If you are using [packages.config](/nuget/reference/packages-config) to specify your packages, you will need to convert over to `PackageReference`.
93-
94-
You can learn more at [Migrate from packages.config to PackageReference](/nuget/reference/migrate-packages-config-to-package-reference).
95-
9676
## What to do when your NuGet package dependency doesn't run on .NET Core
9777

9878
There are a few things you can do if a NuGet package you depend on doesn't run on .NET Core:

0 commit comments

Comments
 (0)