Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed templates so C++ apps can consume C# native modules #5851

Merged
merged 3 commits into from
Aug 27, 2020

Conversation

jonthysell
Copy link
Contributor

@jonthysell jonthysell commented Aug 26, 2020

Right now C++/WinRT apps have a hard time consuming C# WinRT libraries from source. We fixed this in our SampleAppCpp in order to load SampleLibraryCS, but those fixes were not put into the template for the benefit of all apps.

This PR moves the fix into new CppAppConsumeCSharpModule.(props|targets) files. Since the fix involves importing a ton of other props/targets, and we don't want to risk breaking existing C++ apps who have no need of consuming C#-based native modules, the changes are behind a new property ConsumeCSharpModules.

So if you have a C++/WinRT RNW app (the default) and need to consume C# native module, you can set <ConsumeCSharpModules>true</ConsumeCSharpModules> in your app project.

This PR also fixes up the template solution files to include the projects they were missing.

Closes #5825
Closes #4557

Microsoft Reviewers: Open in CodeFlow

Copy link
Collaborator

@NickGerleman NickGerleman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this is great!

@asklar
Copy link
Member

asklar commented Aug 27, 2020

thanks @jonthysell . It looks like we are relying on the dotnet native packages from the SDK instead of nuget, so we just need to make sure that as VS updates itself, that we also keep this updated.
CC @SvetBonev @tommcdon @itodirel @oldnewthing @jlaanstra

@jonthysell jonthysell changed the title Move Cpp apps consuming CSharp module fixes into template Fixed templates so C++ apps can consume C# native modules Aug 27, 2020
@jonthysell jonthysell marked this pull request as ready for review August 27, 2020 18:41
@jonthysell jonthysell requested a review from a team as a code owner August 27, 2020 18:41
Copy link
Member

@dannyvv dannyvv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@dannyvv dannyvv linked an issue Aug 27, 2020 that may be closed by this pull request
@ghost ghost added the Area: Core DLL ABI-safe RNW DLL label Aug 27, 2020
@NickGerleman
Copy link
Collaborator

This one was marked as blocking 0.63 from being released, so I'm going to mark as approved to go into 0.63. @kmelmon @acoates-ms @asklar let me know if you have any thoughts.

@jonthysell jonthysell merged commit db6213f into microsoft:master Aug 27, 2020
@jonthysell jonthysell deleted the csharpmodulefix branch August 27, 2020 20:49
jonthysell added a commit to jonthysell/react-native-windows that referenced this pull request Aug 27, 2020
…5851)

Right now C++/WinRT apps have a hard time consuming C# WinRT libraries from source. We fixed this in our SampleAppCpp in order to load SampleLibraryCS, but those fixes were not put into the template for the benefit of all apps.

This PR moves the fix into new `CppAppConsumeCSharpModule.(props|targets)` files. Since the fix involves importing a ton of other props/targets, and we don't want to risk breaking existing C++ apps who have no need of consuming C#-based native modules, the changes are behind a new property `ConsumeCSharpModules`.

So if you have a C++/WinRT RNW app (the default) and need to consume C# native module, you can set `<ConsumeCSharpModules>true</ConsumeCSharpModules>` in your app project.

This PR also fixes up the template solution files to include the projects they were missing.

Closes microsoft#5825
Closes microsoft#4557
jonthysell added a commit that referenced this pull request Aug 27, 2020
)

This change backports #5851 to 0.63

Original PR: 
Right now C++/WinRT apps have a hard time consuming C# WinRT libraries from source. We fixed this in our SampleAppCpp in order to load SampleLibraryCS, but those fixes were not put into the template for the benefit of all apps.

This PR moves the fix into new `CppAppConsumeCSharpModule.(props|targets)` files. Since the fix involves importing a ton of other props/targets, and we don't want to risk breaking existing C++ apps who have no need of consuming C#-based native modules, the changes are behind a new property `ConsumeCSharpModules`.

So if you have a C++/WinRT RNW app (the default) and need to consume C# native module, you can set `<ConsumeCSharpModules>true</ConsumeCSharpModules>` in your app project.

This PR also fixes up the template solution files to include the projects they were missing.

Closes #5825
Closes #4557
jonthysell added a commit to jonthysell/react-native-windows that referenced this pull request Oct 12, 2020
ghost pushed a commit that referenced this pull request Oct 15, 2020
#6231)

* [0.62] Fixed templates so C++ apps can consume C# native modules #5851

* Change files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Core DLL ABI-safe RNW DLL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't use C# module from C++ on 0.63 Simplify support for .Net Native in C++ projects
5 participants