Hi, I'm trying to write a DNX-based library that will compile on both WPF and Windows 10. This is what my project.json looks like:
"frameworks": {
"net46": {
"frameworkAssemblies": {
"WindowsBase": "4.0.0.0"
}
},
"netcore50": {
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0"
}
}
}
And this is what my C# code looks like:
#if NET46
using System.Windows;
#elif NETCORE50
using Windows.UI.Xaml;
#endif
public class Dependency
{
public static DependencyProperty Register<T, TOwner>(/*...*/)
where TOwner : DependencyObject
{
// ...
}
}
While I have no trouble compiling the code for WPF, the compiler isn't recognizing types like DependencyProperty for UWP. I eventually narrowed it down to the fact that it was missing the reference to Windows.winmd (or the universal API contract for Windows 10) that contained the types.
So suddenly I remembered you guys had WinRT-specific libraries, and I looked into your project.json to see how you do it. I eventually figured out you're doing this using some kind of 'targeting pack' package, hosted privately on MyGet.
Would it be possible for you guys to upload the package officially to NuGet, so others could use WinRT-specific types in .NET Core libraries? I'm assuming it shouldn't be too much of a trouble, since it only contains the .winmd file, right?
@weshaggard Do we have any plans for this?
We created a private package to contain windows.winmd for our build system but I was not currently planning to add that for public consumption as that isn't something we own in general. However I agree it is something we should try to figure out a solution to.
@richlander @cartermp do you guys know if there are any thoughts on officially supporting the Windows SDK as a nuget package?
@weshaggard I hadn't considered this as a part of dotnet/runtime#15477, but I see the value add. We'll have to chat with folks who own the SDK.
@cartermp did you ever get to chat with the windows folks about this? My suspicion is that we will not have support for this and if you agree feel free to close this issue.
I think this will be addressed by implementing https://github.com/dotnet/sdk/issues/491. The fix there is to聽import the specific LanguageTargets used聽by the聽UWP targets, namely the WindowsXaml targets. With that imported, UWP builds will work correctly.
This won't enable a聽x-plat build, but I think that's ok.
@weshaggard No, I haven't. Honestly I haven't touched this in a long time, since much of what we had initially planned was dependent on project.json. The general idea of packaging up TPs as NuGet packages is still something I think would be great, but at this point I'm not sure what the priority is on that.
OK I don't think there is anything we can really do on this front from corefx side so I'm closing this issue. If folks still feel this is important then the SDK repo is likely the better choice to get some traction on this.