Search code examples
nugetwindows-10nuget-packagewindows-10-mobilenuget-spec

Nuget package targeting Win10 both Win8 devices


I have a generated nuget package with a library compiled for W8 and WP8.1:

.nuspec:

<references>
    <group targetFramework=".NETCore4.5">
        <reference file="mylib.winmd" />
    </group>
    <group targetFramework="portable-wpa81">
        <reference file="mylib.winmd" />
    </group>
</references>

Since I plan to target also Win10 devices (desktop and phone-arm), I am thinking about adding the libraries to the same package. It's not quite clear if it's possible to generate a package containing these libs for w8, wp8, w10-x86 and w10-arm.

I am thinking about using the runtimes feature added in nuget 3. How to nuspec file should modify in this case? Should a runtimes xml node be added in nuspec file?

Did some of you guys faced/solved a similar problem?


Solution

  • Nuget 3+ specification definetly lacks examples. A good example of nuget package using UWP libs is Win2D.uwp. See also this discussion.

    The package is a simple archive.

    Basically, the winmd file is in uap10.0 folder, the dlls are in runtime/win10-x86 or runtime/win10-x64 or runtime/win10-arm.

    Besides this, a description file is needed in: build/native/.targets

    As a summary the file structure needs to look something like:

    build
      native
        .targets file
    lib
      uap10.0
        .winmd file
    runtimes
      win10-arm
        .dll file
      win10-x86
        .dll file
      win10-x64
        .dll file
      ...
    

    Hope this helps others not to loose precious hours...