Nuget Resolve dependencies from local files

I have a solution with four projects, three PCL and one WinRT. I've managed to create a nuget package for each one, individually, however, I want to do a single package for all of them, but there are external dependencies and also dependencies between them and I do not know how to resolve them. What I found for external dependencies is something of the like:

<?xml version="1.0"?>
(...)
    <dependencies>
      <dependency id="SampleDependency" version="1.0" />
    </dependencies>
(...)
</package>

But how can I specify local dependencies?
You can see a diagram of the strucure here: https://i.sstatic.net/3y7ga.png

Upvotes: 0

Views: 505

Answers (1)

I found a way of doing this with the Visual Studio Extension project, however since the question is for Nuget I'll post how I solved this in Nuget.
Since I had views in one of my PCL, things were getting a little complicated, but when I found what files I needed and file structure it was easy. Here's the structure:

Nuget Package structure

So the idea is pretty simple actually, in this case I wanted to put everything in .dlls, so you need to add a lib section and then the platform specific folder (in my case wpa81) and then every .dll file you need.

In the case of the WindowsRuntinme project you need two files, a WindowsRuntinmeProject.pri and WindowsRuntimeProject.winmd.
In the case of the PCL file with views, extra files and logic is needed, so you need yo add the ClassLibraryWithViews.dll in the platform folder, then you need to create a folder with the same name as the PCL project, and inside put the ClassLibraryWithViews.xr.xml (that has some xaml tags and info) and then you create the folder structure of the views in your project, if you happen to have one. On my example I have a Generic.xaml inside a Themes folder and PageView.xaml inside my View folder, so I replicate that structure here. You can notice that the files are not .xaml, they're actually .xbf, that's what you get after you build the project, so those are the ones you need to use. I should also point that my Generic.xbf is a ResourceDictionary (no code-behind) and my PageView.xbf is in fact a Page, so it has code-behind, but when you're building the package, that's transparent, which is nice.

Then after you install it on your project you'll have every .dll you see in the platform folder, and you'll also see the WinRT project as if it were a .dll.
It's good to point out that every file in here is generated by building the projects in the solution, so there is no need to create any of it.

Another point to mention, you can see that I added the MvvmLight .dlls directly to my project, although if you want you can add them as dependencies in the nuget package metadata, so they will be fetched and installed when you're installing you're nuget package. The section can be seen here:

Nuget metada dependencies

Upvotes: 1

Related Questions