clairernovotny / ReferenceGenerator

MIT License
75 stars 13 forks source link

Support for multiple platform packages #18

Closed ravensorb closed 8 years ago

ravensorb commented 8 years ago

I am one of the maintainers of the XLabs framework. This framework implements a set of nuget packages where each package contains a PCL assembly along with assemblies for each of the target platforms (.NET, WPA8, WPA81, UPA, Xamarin iOS, Xamarin Android, etc). These are all in seperate csproj files that are then combined via a nuspec file into a single package per concept.

It would be great if there was a way to support this scenario -- maybe with a solution level type file that the reference generate users?

<NuSpecPackage IncludeFile="$(SolutionDir)\.nuget\Definition\XLabs.Platform.nuspec">
    <NuSpecProjectFile IncludeFile="$(SolutionDir)\src\Platform\XLabs.Platform\XLabs.Platform.csproj">
    <NuSpecProjectFile IncludeFile="$(SolutionDir)\src\Platform\XLabs.Platform.iOS\XLabs.Platform.iOS.csproj">
    <NuSpecProjectFile IncludeFile="$(SolutionDir)\src\Platform\XLabs.Platform.Droid\XLabs.Platform.Droid.csproj">
    <NuSpecProjectFile IncludeFile="$(SolutionDir)\src\Platform\XLabs.Platform.WP81\XLabs.Platform.WP81.csproj">
    <NuSpecProjectFile IncludeFile="$(SolutionDir)\src\Platform\XLabs.Platform.WinRT\XLabs.Platform.WinRT.csproj">
</NuSpecPackage>

the idea of the above concept would to to analyze all of the csproj files and update a single nuspec file.

Note: As an added bonus it would be awesome if it could also generate not only the dependencies for all of the targetFrameworks supported (5 in the above example) but to aslo create the correct "files" section for each of the outputs (dll, pdb, etc) and the corresponding targets for them as well.

clairernovotny commented 8 years ago

Hi Shawn,

The RefGen tool already supports outputs that consist of multiple files/projects with the NuSpecProjectFile as you saw. There's a test project with an example of this here: https://github.com/onovotny/ReferenceGenerator/blob/master/tests/SampleClassLibrary/SampleClassLibrary.csproj#L37-L50

The scope of this tool though is not to create a NuSpec file, but rather to put the proper dependencies in for dotnet, uap10.0, and netstandard TFM's where all dependencies, including platform ones, must be explicitly specified. That is the hard part today without a tool like this.

If you just want to create packages, have you seen NuProj: http://nuproj.net/

Does that help?

ravensorb commented 8 years ago

Thanks for the quick response -- I did try the suggested method. It seems to only handle a single additional csproj file (I have 4 to 5 for almost every package). I added them to the PCL project. As an added note, if I run the tool manually and add more than 1 single additional reference I get an invalid index error.

clairernovotny commented 8 years ago

If having more than one additional reference is erroring out, then that's definitely a bug. The one main requirement is that there has to be a matching NuSpecLibContent for each NuSpecProjectFile in the same relative order. If you have a repro, I can take a look and see why it'd be throwing.

Better error messages are also on the ToDo list...

ravensorb commented 8 years ago

Hmm, I wonder if that is what I was missing - I thought it was an either/or situation. Either I support the assembly dll path or the csproj file with the idea it could read what it needed based on either of them.

clairernovotny commented 8 years ago

It does need both as it's not fully parsing the csproj file to know the resulting dll name. That'd be a lot of complexity. It reads the dll's and then cross-references the csproj files for packages.config based projects.

It's also possible to use project.json instead of packages.config for ordinary PCL projects, but I'm not sure if the Xamarin tools support that yet. In the case of project.json based projects, the csproj isn't even read.

ravensorb commented 8 years ago

Ok, that makes sense. I'll keep playing around. Thanks.