0

I have a Windows Phone 8.1 solution with the following projects:

  • MainApplication (for the application itself)
  • Portable Class Library (PCL) (for some useful methods and whatnot)
  • Windows Runtime Component (WinRT) (for Background Tasks)

I'm trying to compile the PCL and WinRT to a .nuget Package, and I know I can do that with the PCL, however, I'm missing something in the WinRT.
To test it manually, I'm removing projects from the solution and adding their build as reference, i.e., the PCL produces a .dll file that I'll add to my MainApplication as a reference. The problem here is that the WinRT does not produce a .dll, but a .winmd file instead. The thing here is that I don't know how to add that file to my PCL as a reference.

To sum it all up, how can I add, as reference, the result of a WinRT project build? Is it the .winmd file or some other?

Schrödinger's Box
  • 3,218
  • 1
  • 30
  • 51
  • 1
    Your **question** is **very** hard to **read**. – Hans Passant Nov 04 '14 at 20:38
  • 1
    You can't add the WinRT reference to your PCL. That's the point of the PCL. WinRT is a platform-specific .NET subset. PCL is a platform-agnostic subset. PCL is, in essence, a subset of WinRT. That means that trying to tell the PCL library about the WinRT DLL means that there will be a bunch of references that the PCL library won't understand. If you need to do communication between the two library, you need to use Dependency Injection to hook the calls into the PCL from the WinRT. The WinRT knows all that the PCL does, so it needs to make the effort to make the PCL understand what it needs. – Nate Diamond Nov 04 '14 at 22:19
  • @NateDiamond Actually you can, i figured out a way to do it. If you're interested check my answer. – Schrödinger's Box Nov 14 '14 at 08:05
  • I believe you misunderstand. You can add the WinRT project to a nuget package, there's no issue there. Your last sentence, however, is "The thing here is that I don't know how to add that file to my PCL as a reference." which is a different request that you can't do (which my comment responded to). – Nate Diamond Nov 14 '14 at 16:39
  • Ok, but in my project, I do have a reference to the WinRT in my PCL, and after the Nuget is created and I have all .dlls in my project, and the WinRT looks like one, I can add it as a reference, so for my case the connection does work. I'm not understanding where it does not. Can you give a specific scenario? – Schrödinger's Box Nov 14 '14 at 19:04

1 Answers1

0

I managed to solve my problem and it was all a question of figuring out which files from the WinRT I should add. So when you're creating a .nuget package and you want to add a WinRT project as if it were a .dll, you need the WindowsRuntimeProject.pri file and the WindowsRuntimeProject.winmd file. When you install the package on your project the WinRT will look like a .dll.
It looks something like this:
enter image description here

More info on how to build that .nuget package can be found here.

Community
  • 1
  • 1
Schrödinger's Box
  • 3,218
  • 1
  • 30
  • 51