is it possible to create a nuget package containg a .winmd file ?

Topics: General
Feb 14, 2013 at 8:21 AM
i am trying to create a nuget package and i want to use a winmd file. is it possible to do so ?
Feb 14, 2013 at 6:16 PM
Yes, winmd file is supported just like .dll and .exe.
Feb 15, 2013 at 10:20 AM
I am actually trying to create a nuget package for windows store apps. It has platform specific dll which is native and a winmd file. i want to integrate it in my temlate. How can i create the nuget?
Feb 15, 2013 at 1:51 PM
what behavior do you want for the native file and the winmd file when your package is installed?
Feb 18, 2013 at 5:20 AM
Edited Feb 18, 2013 at 5:26 AM
the winmd file has all the metadata and the dll has all the code. when i install the package i want all the references to be added to the code.
Since my native dll has all the code, I have x86, x64 and ARM versions of it. When I refer my nuget package and build the app for x86, x86 version of my dll should be included. Same for ARM and x64 versions. How can I achieve it via Nuget packages?
Feb 18, 2013 at 9:03 AM
Unfortunately, NuGet currently doesn't support targeting different platform architecture, nor does it support native dll. We'll be adding support for native dll in the next version though, but still no platform architecture differentiation.
Feb 18, 2013 at 1:15 PM
Thanks. If there would not be any platform support then how would following scenario work...

1) I add reference to native nuget package (x86?)
2) Build for x86.
3) Change the platform to x64 or ARM.
4) build again.

In the step#4, will it include x86 version of the dll or the appropriate one? if X86, then app would fail to run. Will developer be supposed to update the nuget reference for appropriate platform after changing the platform every time?
Apr 22, 2013 at 1:21 PM
I tried 2.5 RC (2.5.40416.9020) and the native installation didn't work. I guess the interpretation of "native" may differ, depending on which platform someone works on, thus I'd like to hear if my use case is expected to be supported in 2.5.

Here is my use case:
  • I am developing on Windows Phone 8.
  • I have a library that is written in C++ ("Native" in WP8 slang), that has been ported to Windows Phone Runtime.
  • The compiler builds a .dll and a .winmd, both with same filename. Say foo.dll and foo.winmd
  • When adding the library reference to a C# project, only the foo.winmd must be added. The WP8 compiler looks for the foo.dll in the same directory than foo.winmd, and packages it to the final application.
  • Adding reference to foo.dll fails with "Higher or incompatible assembly".
That sets the requirements for NuGet :
  • Both foo.dll and foo.winmd are needed in the lib directory,
  • NuGet only tries to add reference to foo.winmd.
With 2.5 RC, NuGet tries to add reference to both the .winmd and the .dll, and fails.
Apr 22, 2013 at 3:35 PM
To tell NuGet to add reference only to foo.winmd, you need to use the <references> element in the manifest. Read the "Specifying Explicit Assembly References" section on this page:
Apr 22, 2013 at 7:24 PM
Thanks that worked like a charm! I didn't notice the <references> element.
Is there any work ongoing for the different platform architecture? It is a problem in my use case, ideally I'd like to distribute x86 libs for the emulator, and ARM libs for the phone. Would it be useful if I'd create an issue for tracking it up?
Apr 22, 2013 at 8:16 PM
Can you explain a bit more?
Apr 23, 2013 at 8:50 AM
Some basics to help framing the problem:

The development of a windows phone application is done on a Windows machine (Windows 8), an x86 environment. The Windows Phone SDK comes with Visual Studio, compilers and other tools including a Windows Phone emulator.

When developing for windows phone, the developer can test his application on either the emulator or on the phone ( if he has one ). Typically, you'll do most of the development on the emulator, and when the app starts to be ready you deploy on the phone. The emulator is typically faster than the phone, therefore the preference to use the emulator for most of the development phase.

The phones are powered by ARM processors, therefore ARM architecture. The emulator is a x86 architecture.

The only framework allowed in Windows Phone 7 was .NET, in the form of a variant of Silverlight 4. In .NET, the library is compiled as CIL (Common Interface Language) and executed by a virtual machine. The exact same CIL library works on both the emulator (x86) and the phones (ARM).

In Windows Phone 8 (WP8), it is possible to write "native" libraries. These libraries are written in C/C++ and wrapped into Windows Phone Runtime libraries. Since it's native code, there is no virtual machine, no CIL code that works on both architectures. Two versions of the library are needed, one for ARM and the other one for x86.
Jul 22, 2013 at 11:46 AM
We ended up requesting developers to update manually their .csproj file, after the NuGet install.

I wonder if it would be possible to improve this experience using the current NuGet releases. We though of using a script to fool around with the hintpath but that didn't work for update, as no scripts are run on updates.
Sep 12, 2013 at 4:15 PM
I know this thread is a bit old, but I am posting here in case someone else gets here by search engine.

If your users are using C++, you might try using CoApp AutoPackage. We have had good luck using it to make native NuGet packages from headers and dlls . We have been only calling the libs from C++ code. Right now I am trying to figure out how or if we can also make it pull in .winmd files, too so that our users can build managed applications, too.
Sep 13, 2013 at 12:57 PM
The solution we settled for is to add a .targets file in the nuget package, under /build/wp8/ directory.
That file contains following code:

<Project xmlns="">
<Target Name="CheckAnyCPU" Condition="('$(Platform)' != 'x86') AND ('$(Platform)' != 'ARM')" BeforeTargets="BeforeBuild">
<Error Text="Nokia Imaging SDK does not support the $(Platform) target platform. Please consult!nokia-imaging-sdk/adding-libraries-to-the-project.html;#toc_InstallingtheSDKandincludingthelibrariestoaprojectusingNuGet " />
    <Reference Include="Nokia.Graphics.Imaging">
    <Reference Include="Nokia.InteropServices.WindowsRuntime">

Far from optimal, in some case a VS restart is required, but that works for us.