From 2ccacd4ae86a11890f6dfe96f472eff57bd96ba3 Mon Sep 17 00:00:00 2001 From: William Cameron Date: Thu, 25 Nov 2021 21:26:08 +1300 Subject: [PATCH 1/3] Migrate C++/CLI library to .NET 6 --- CppCliInterop/CppCliInterop.vcxproj | 20 ++++++++++---------- ManagedLibrary/ManagedLibrary.csproj | 2 +- NativeApp/NativeApp.vcxproj | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/CppCliInterop/CppCliInterop.vcxproj b/CppCliInterop/CppCliInterop.vcxproj index 8841fee..95ef59c 100644 --- a/CppCliInterop/CppCliInterop.vcxproj +++ b/CppCliInterop/CppCliInterop.vcxproj @@ -21,7 +21,7 @@ 16.0 {D72A5A0F-4FB0-4E11-ADE7-40CC377D06E9} - netcoreapp3.1 + net6.0-windows ManagedCProj CppCliInterop 10.0 @@ -30,28 +30,28 @@ DynamicLibrary true - v142 + v143 NetCore Unicode DynamicLibrary false - v142 + v143 NetCore Unicode DynamicLibrary true - v142 + v143 NetCore Unicode DynamicLibrary false - v142 + v143 NetCore Unicode @@ -143,16 +143,16 @@ - - - {14da10c8-ac12-4456-aa41-740a5699ed97} - - true + + + {14da10c8-ac12-4456-aa41-740a5699ed97} + + diff --git a/ManagedLibrary/ManagedLibrary.csproj b/ManagedLibrary/ManagedLibrary.csproj index 46eef71..27f74cd 100644 --- a/ManagedLibrary/ManagedLibrary.csproj +++ b/ManagedLibrary/ManagedLibrary.csproj @@ -2,7 +2,7 @@ Library - net47;netcoreapp3.1 + net6.0-windows true diff --git a/NativeApp/NativeApp.vcxproj b/NativeApp/NativeApp.vcxproj index 95777f2..13a9dcd 100644 --- a/NativeApp/NativeApp.vcxproj +++ b/NativeApp/NativeApp.vcxproj @@ -29,26 +29,26 @@ Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode From 41e83d5601453b724f90d9f862dafe0722214004 Mon Sep 17 00:00:00 2001 From: William Date: Thu, 25 Nov 2021 21:38:12 +1300 Subject: [PATCH 2/3] Update ReadMe.md added steps to migrate the .NET core project to .NET --- ReadMe.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ReadMe.md b/ReadMe.md index 5fca30b..46de24c 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -1,3 +1,9 @@ +# Porting this project to .NET 5/6 +You can check out the dotnet branch for a buildable example. +- Use Visual Studio 2022 and migrage the projects to v143 +- change the targetframework or targetframeworks in the ManagedLibrary to `net6.0-windows`. This is much easier in 2022 as targetframeworks is now listed in the properties rather than having to go hunting through the .csproj file. +- Change the CppCliInterop library's TargetFramework to net6.0-windows either in the vcxproj file or in the properties project under Advanced. + # Porting a C++/CLI Project to .NET Core One of the new features of Visual Studio 2019 version 16.4 and .NET Core 3.1 is the ability to build C++/CLI projects targeting .NET Core. This can be done either directly with *cl.exe* and *link.exe* (using the new `/clr:netcore` option) or via MSBuild (using `NetCore`). In this post, I'll walk through the steps necessary to migrate a simple C++/CLI interop project to .NET Core. More details can be found in [.NET Core documentation](https://docs.microsoft.com/dotnet/core/porting/cpp-cli). @@ -78,4 +84,4 @@ Hopefully this sample shows how to take advantage of the new functionality in Vi * [C++/CLI .NET Core migration docs](https://docs.microsoft.com/dotnet/core/porting/cpp-cli) * [The sample used in this post](https://github.com/mjrousos/CppCliMigrationSample) (the original sample is in the master branch and the .NET Core updates are in the netcore branch) -* [.NET Portability Analyzer](https://github.com/Microsoft/dotnet-apiport) \ No newline at end of file +* [.NET Portability Analyzer](https://github.com/Microsoft/dotnet-apiport) From 7b64b691a20804516e03801ad2978d4b3987f8a4 Mon Sep 17 00:00:00 2001 From: William Date: Thu, 25 Nov 2021 21:41:18 +1300 Subject: [PATCH 3/3] added link to the dotnet branch --- ReadMe.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReadMe.md b/ReadMe.md index 46de24c..8c0e2fd 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -1,5 +1,5 @@ # Porting this project to .NET 5/6 -You can check out the dotnet branch for a buildable example. +You can check out the [dotnet branch](https://github.com/Gnomorian/CppCliMigrationSample/tree/dotnet) for a buildable example. - Use Visual Studio 2022 and migrage the projects to v143 - change the targetframework or targetframeworks in the ManagedLibrary to `net6.0-windows`. This is much easier in 2022 as targetframeworks is now listed in the properties rather than having to go hunting through the .csproj file. - Change the CppCliInterop library's TargetFramework to net6.0-windows either in the vcxproj file or in the properties project under Advanced.