Reputation: 5222
Is the Universal Windows dll actually universal, or is it just for UWP?
I am building a native C++ dll with all the defaults, but when I reference it from a Classic Desktop app (it is a unit test), then I get this exception:
This operation is only valid in the context of an app container.
Of course, the "Universal" in "Universal Windows" may be for the cool guys out there :), but I don't really want to build two separate dlls for Windows 10, just because.
I also noticed this when building NuGets for .NET Core, I stuck my native library in the win10
folder. I also have a special build for Windows 7, so that went into the win7
folder. All looked good, until runtime, not even .NET Core can load this universal dll.
Is the C++ Universal Windows just for UWP? Is there a way to use a single dll for .NET Core, UWP and Classic Desktop? Any special flags to set?
If there is no way to have a true universal dll, how does one distinguish if a Windows 10 dll is for UWP or Classic Desktop?
Upvotes: 1
Views: 1049
Reputation: 5222
I had a discussion with the NuGet team, and they have a solution:
Support for
runtimes/{rid}/nativeassets/{tfm}/{any?}
was added with #2782Set a min client version of 3.5.0 in your nuspec to ensure that consumers have the correct client version to pick up this nupkg path.
https://github.com/NuGet/Home/issues/5042
So in the case of my .nuspec:
<file src="Managed.dll" target="lib\netstandard1.3" />
<file src="Native-Win7.dll" target="runtimes\win7-x64\native" />
<file src="Native-Win10.dll" target="runtimes\win10-x64\native" />
<file src="Native-Uap10.dll" target="runtimes\win10-x64\nativeassets\uap10.0" />
Upvotes: 0