You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is hard to pack a C# Windows Runtime Component that has dependencies to other CLR nuget packages so that it can be consumed from a C++/Cx Universal Windows App.
Notice that this is not the typical "consume native from managed" problem but the opposite direction: an existing C++ app that needs to consume XAML controls and libraries written in C#.
The question is how to do this properly, a minimal working solution is attached. However, my approach does not feel quite right.
Details about Problem
Setup:
A C# Universal Windows Runtime Component project with a XAML control that has dependencies to other managed nugets. In this example, to Newtonsoft.Json.
A C++/Cx Universal Windows App that needs to consume the C# XAML control. The C++ project is packages.config based.
In a perfect world, declaring dependencies in the RuntimeComponent's nuspec file would lead to restoring these packages. However, nuget restore fails because it cannot install C# packages into a C++ project.
Workaround:
To make this work, I included all dependencies directly. This is tricky because it includes transitive dependencies, such as a package C in a dependency chain A -> B -> C.
After lots of reading and experimenting I added <CopyNugetImplementations>true</CopyNugetImplementations> to my RuntimeComponent's csproj which will copy all assemblies that the project depends on to the build output folder. Then in my manually crafted nuspec, I copied these additional DLLs to my package with the <file> attribute. In the targets file these dependencies are then added to the consuming project with
What is the recommended approach to redistribute CLR nuget dependencies and their transitive dependencies with a Windows Runtime Component, so that it can be consumed from a C++ UWP project?
NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe): NuGet.exe
The issue tracking support for C++ apps consuming managed assemblies is here: #5292 Please up vote and comment there.
I appreciate the detailed the write up of the issue, but at this time UWP is only using packages.config, which does not support the ref/ folder. We would like to tackle this problem directly instead of providing workarounds for the currently broken scenario.
I'm running into similar problems when trying to consume WinRT components in UWP JavaScript apps. (where WinRT component is written in C# but has non-WinRT C# internal dependencies like Json.NET). A solution to this would be great!
Problem statement
It is hard to pack a C# Windows Runtime Component that has dependencies to other CLR nuget packages so that it can be consumed from a C++/Cx Universal Windows App.
Notice that this is not the typical "consume native from managed" problem but the opposite direction: an existing C++ app that needs to consume XAML controls and libraries written in C#.
The question is how to do this properly, a minimal working solution is attached. However, my approach does not feel quite right.
Details about Problem
Setup:
A C# Universal Windows Runtime Component project with a XAML control that has dependencies to other managed nugets. In this example, to Newtonsoft.Json.
A C++/Cx Universal Windows App that needs to consume the C# XAML control. The C++ project is packages.config based.
In a perfect world, declaring dependencies in the RuntimeComponent's nuspec file would lead to restoring these packages. However, nuget restore fails because it cannot install C# packages into a C++ project.
Workaround:
To make this work, I included all dependencies directly. This is tricky because it includes transitive dependencies, such as a package C in a dependency chain A -> B -> C.
After lots of reading and experimenting I added
<CopyNugetImplementations>true</CopyNugetImplementations>
to my RuntimeComponent's csproj which will copy all assemblies that the project depends on to the build output folder. Then in my manually crafted nuspec, I copied these additional DLLs to my package with the<file>
attribute. In the targets file these dependencies are then added to the consuming project withProblems with the workaround:
This solution works but has inherent issues.
Finding which DLLs need to be copied is very tedious:
In the attached minimal example, I ended up having to include Newtonsoft.Json and also even System DLLs.
What is the recommended approach to redistribute CLR nuget dependencies and their transitive dependencies with a Windows Runtime Component, so that it can be consumed from a C++ UWP project?
NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe): NuGet.exe
NuGet version (x.x.x.xxx): 4.3.0.4406
VS version (if appropriate): 15.4.2
OS version: win10 v1703 15063.674
Sample Project
UwpInteropPackaging_Example.zip
The text was updated successfully, but these errors were encountered: