From bc64ccacb9a6dc79c6e380d2bd3accf310d8cbb7 Mon Sep 17 00:00:00 2001 From: Angela Zhang Date: Thu, 3 Jun 2021 11:45:19 -0700 Subject: [PATCH 1/7] sample updates --- .../ConsoleAppSample/ConsoleAppSample.csproj | 4 ++-- .../SimpleMathComponent/SimpleMathComponent.vcxproj | 3 +++ .../SimpleMathProjection/SimpleMathProjection.csproj | 8 ++------ .../nuget/SimpleMathProjection.nuspec | 10 +++++----- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/Samples/Net5ProjectionSample/ConsoleAppSample/ConsoleAppSample.csproj b/src/Samples/Net5ProjectionSample/ConsoleAppSample/ConsoleAppSample.csproj index f3a294bcc..9a6e45efe 100644 --- a/src/Samples/Net5ProjectionSample/ConsoleAppSample/ConsoleAppSample.csproj +++ b/src/Samples/Net5ProjectionSample/ConsoleAppSample/ConsoleAppSample.csproj @@ -2,7 +2,8 @@ Exe - net5.0-windows10.0.19041.0 + net5.0-windows10.0.19041.0 + 10.0.17763.0 x64 @@ -14,7 +15,6 @@ - diff --git a/src/Samples/Net5ProjectionSample/SimpleMathComponent/SimpleMathComponent.vcxproj b/src/Samples/Net5ProjectionSample/SimpleMathComponent/SimpleMathComponent.vcxproj index 2b123f2b4..4642fea10 100644 --- a/src/Samples/Net5ProjectionSample/SimpleMathComponent/SimpleMathComponent.vcxproj +++ b/src/Samples/Net5ProjectionSample/SimpleMathComponent/SimpleMathComponent.vcxproj @@ -69,6 +69,9 @@ true false + + true + diff --git a/src/Samples/Net5ProjectionSample/SimpleMathProjection/SimpleMathProjection.csproj b/src/Samples/Net5ProjectionSample/SimpleMathProjection/SimpleMathProjection.csproj index 51fb8d95e..e92488e03 100644 --- a/src/Samples/Net5ProjectionSample/SimpleMathProjection/SimpleMathProjection.csproj +++ b/src/Samples/Net5ProjectionSample/SimpleMathProjection/SimpleMathProjection.csproj @@ -2,12 +2,13 @@ net5.0-windows10.0.19041.0 + 10.0.17763.0 x64 - + @@ -24,9 +25,4 @@ true - - - - - diff --git a/src/Samples/Net5ProjectionSample/SimpleMathProjection/nuget/SimpleMathProjection.nuspec b/src/Samples/Net5ProjectionSample/SimpleMathProjection/nuget/SimpleMathProjection.nuspec index f539adc11..5df7dadc6 100644 --- a/src/Samples/Net5ProjectionSample/SimpleMathProjection/nuget/SimpleMathProjection.nuspec +++ b/src/Samples/Net5ProjectionSample/SimpleMathProjection/nuget/SimpleMathProjection.nuspec @@ -9,17 +9,17 @@ - - - + + - - + + + \ No newline at end of file From 7ba26dbdbc1c298ec7a29232df9391a5e3745cab Mon Sep 17 00:00:00 2001 From: Angela Zhang Date: Thu, 24 Jun 2021 17:17:29 -0700 Subject: [PATCH 2/7] updates --- .../ConsoleAppSample/ConsoleAppSample.csproj | 2 +- .../SimpleMathComponent.vcxproj | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Samples/Net5ProjectionSample/ConsoleAppSample/ConsoleAppSample.csproj b/src/Samples/Net5ProjectionSample/ConsoleAppSample/ConsoleAppSample.csproj index 9a6e45efe..dec96f70a 100644 --- a/src/Samples/Net5ProjectionSample/ConsoleAppSample/ConsoleAppSample.csproj +++ b/src/Samples/Net5ProjectionSample/ConsoleAppSample/ConsoleAppSample.csproj @@ -13,7 +13,7 @@ ../SimpleMathProjection/nuget - + diff --git a/src/Samples/Net5ProjectionSample/SimpleMathComponent/SimpleMathComponent.vcxproj b/src/Samples/Net5ProjectionSample/SimpleMathComponent/SimpleMathComponent.vcxproj index 4642fea10..27b075ac5 100644 --- a/src/Samples/Net5ProjectionSample/SimpleMathComponent/SimpleMathComponent.vcxproj +++ b/src/Samples/Net5ProjectionSample/SimpleMathComponent/SimpleMathComponent.vcxproj @@ -72,6 +72,27 @@ true + + true + + + true + + + true + + + true + + + true + + + true + + + true + From 23f633443199e25da03d65e76f9d2c531faa4ec6 Mon Sep 17 00:00:00 2001 From: angelazhangmsft Date: Thu, 24 Jun 2021 18:36:29 -0700 Subject: [PATCH 3/7] Update README.md --- src/Samples/Net5ProjectionSample/README.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Samples/Net5ProjectionSample/README.md b/src/Samples/Net5ProjectionSample/README.md index 9c636fb2a..be8814aed 100644 --- a/src/Samples/Net5ProjectionSample/README.md +++ b/src/Samples/Net5ProjectionSample/README.md @@ -1,20 +1,26 @@ -# C#/WinRT End to End Sample +# C#/WinRT Projection Sample -This sample demonstrates how to invoke C#/WinRT to build a .NET5 projection for a C++/WinRT Runtime Component, create a NuGet package for the component, and reference the NuGet package from a .NET5 console app. +This sample demonstrates how to do the following: + +- Use the C#/WinRT package to generate a C# projection interop assembly from a C++/WinRT component +- Distribute the component along with the interop assembly as a NuGet package +- Consume the component from a .NET 5+ console application ## Requirements - Visual Studio 16.8 - .NET 5.0 SDK -- Nuget.exe 5.8.0-preview.2 (for command line MSBuild) +- nuget.exe 5.8.0-preview.2 (for command line MSBuild) ## Build and run the sample -Using Visual Studio: +For building in Visual Studio 2019: + +1. Build the *CppWinRTComponentProjectionSample* solution first. This builds the WinMD for SimpleMathComponent, generates a projection interop assembly for the component using C#/WinRT, and generates the SimpleMathComponent NuGet package for the component which .NET 5+ apps can reference. -1. Build the *CppWinRTComponentProjectionSample* solution first. This generates the projection and interop assembly using cswinrt, and creates the SimpleMathComponent NuGet package which can be referenced in consuming apps. If you run into errors restoring NuGet packages, look at the docs on [NuGet restore options](https://docs.microsoft.com/nuget/consume-packages/package-restore). You may need to configure your NuGet package manager settings to allow for package restores on build. +2. Build and run the *ConsoleAppSample* solution which references and restores the SimpleMathComponent NuGet package to consume the projection. -2. Build the *ConsoleAppSample* solution which references and restores the SimpleMathComponent NuGet package to consume the projection. + If you run into errors restoring NuGet packages, look at the docs on [NuGet restore options](https://docs.microsoft.com/nuget/consume-packages/package-restore). You may need to configure your NuGet package manager settings to allow for package restores on build. For building with the command line, execute the following: From 0469ec3ee7b7b70ae60590531028634f4cf45024 Mon Sep 17 00:00:00 2001 From: Angela Zhang Date: Fri, 25 Jun 2021 11:51:10 -0700 Subject: [PATCH 4/7] update TFM and TPMV --- .../ConsoleAppSample/ConsoleAppSample.csproj | 30 +++++++++---------- .../SimpleMathComponent.vcxproj | 2 +- .../nuget/SimpleMathProjection.nuspec | 4 +-- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Samples/Net5ProjectionSample/ConsoleAppSample/ConsoleAppSample.csproj b/src/Samples/Net5ProjectionSample/ConsoleAppSample/ConsoleAppSample.csproj index dec96f70a..7050688e8 100644 --- a/src/Samples/Net5ProjectionSample/ConsoleAppSample/ConsoleAppSample.csproj +++ b/src/Samples/Net5ProjectionSample/ConsoleAppSample/ConsoleAppSample.csproj @@ -1,21 +1,21 @@  - - Exe - net5.0-windows10.0.19041.0 - 10.0.17763.0 - x64 - + + Exe + net5.0-windows10.0.19041.0 + 10.0.17763.0 + x64 + - - - https://api.nuget.org/v3/index.json; - ../SimpleMathProjection/nuget - - + + + https://api.nuget.org/v3/index.json; + ../SimpleMathProjection/nuget + + - - - + + + diff --git a/src/Samples/Net5ProjectionSample/SimpleMathComponent/SimpleMathComponent.vcxproj b/src/Samples/Net5ProjectionSample/SimpleMathComponent/SimpleMathComponent.vcxproj index 27b075ac5..1f6d06fe0 100644 --- a/src/Samples/Net5ProjectionSample/SimpleMathComponent/SimpleMathComponent.vcxproj +++ b/src/Samples/Net5ProjectionSample/SimpleMathComponent/SimpleMathComponent.vcxproj @@ -15,7 +15,7 @@ Windows Store 10.0 10.0.19041.0 - 10.0.17134.0 + 10.0.17763.0 diff --git a/src/Samples/Net5ProjectionSample/SimpleMathProjection/nuget/SimpleMathProjection.nuspec b/src/Samples/Net5ProjectionSample/SimpleMathProjection/nuget/SimpleMathProjection.nuspec index 5df7dadc6..e95f6a5c5 100644 --- a/src/Samples/Net5ProjectionSample/SimpleMathProjection/nuget/SimpleMathProjection.nuspec +++ b/src/Samples/Net5ProjectionSample/SimpleMathProjection/nuget/SimpleMathProjection.nuspec @@ -9,7 +9,7 @@ - + @@ -18,7 +18,7 @@ - + From e362f14a76a27c6b0090286ddf1c48f0bf464fe6 Mon Sep 17 00:00:00 2001 From: Angela Zhang Date: Fri, 25 Jun 2021 12:37:23 -0700 Subject: [PATCH 5/7] fix indentation --- .../ConsoleAppSample/ConsoleAppSample.csproj | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Samples/Net5ProjectionSample/ConsoleAppSample/ConsoleAppSample.csproj b/src/Samples/Net5ProjectionSample/ConsoleAppSample/ConsoleAppSample.csproj index 7050688e8..b45996f9b 100644 --- a/src/Samples/Net5ProjectionSample/ConsoleAppSample/ConsoleAppSample.csproj +++ b/src/Samples/Net5ProjectionSample/ConsoleAppSample/ConsoleAppSample.csproj @@ -1,21 +1,21 @@  - - Exe - net5.0-windows10.0.19041.0 - 10.0.17763.0 - x64 - + + Exe + net5.0-windows10.0.19041.0 + 10.0.17763.0 + x64 + - - + + https://api.nuget.org/v3/index.json; ../SimpleMathProjection/nuget - - + + - - - - + + + + From 6e213a554b0eb7ca1244c9adaca5feb79c81a54e Mon Sep 17 00:00:00 2001 From: Angela Zhang Date: Mon, 28 Jun 2021 16:57:04 -0700 Subject: [PATCH 6/7] add platformtarget --- .../SimpleMathProjection/SimpleMathProjection.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Samples/Net5ProjectionSample/SimpleMathProjection/SimpleMathProjection.csproj b/src/Samples/Net5ProjectionSample/SimpleMathProjection/SimpleMathProjection.csproj index e92488e03..401fea9d8 100644 --- a/src/Samples/Net5ProjectionSample/SimpleMathProjection/SimpleMathProjection.csproj +++ b/src/Samples/Net5ProjectionSample/SimpleMathProjection/SimpleMathProjection.csproj @@ -4,6 +4,7 @@ net5.0-windows10.0.19041.0 10.0.17763.0 x64 + AnyCPU From 70217649b1d59e775b2d4681dc6f86397862d253 Mon Sep 17 00:00:00 2001 From: angelazhangmsft Date: Mon, 28 Jun 2021 17:32:09 -0700 Subject: [PATCH 7/7] remove platformtarget it causes processor architecture mismatch warnings --- .../SimpleMathProjection/SimpleMathProjection.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Samples/Net5ProjectionSample/SimpleMathProjection/SimpleMathProjection.csproj b/src/Samples/Net5ProjectionSample/SimpleMathProjection/SimpleMathProjection.csproj index 401fea9d8..e92488e03 100644 --- a/src/Samples/Net5ProjectionSample/SimpleMathProjection/SimpleMathProjection.csproj +++ b/src/Samples/Net5ProjectionSample/SimpleMathProjection/SimpleMathProjection.csproj @@ -4,7 +4,6 @@ net5.0-windows10.0.19041.0 10.0.17763.0 x64 - AnyCPU