NuGet / NuGet.Build.Packaging

The NuGetizer-3000 is here!
Other
70 stars 28 forks source link

Fixed targets not imported during multitargeting #154

Closed ChristophLindemann closed 6 years ago

ChristophLindemann commented 6 years ago

The buildMultiTargeting\NuGet.Build.Packaging.MultiTargeting.targets file was not imported into msbuild script during multi-target phase, due to the name not matching the package id.

Related to https://github.com/NuGet/Home/issues/6277

Changed buildMultiTargeting\NuGet.Build.Packaging.MultiTargeting.targets
to
buildMultiTargeting\NuGet.Build.Packaging.targets,
removing the MultiTargeting part from the file name.

The issue is demonstrated and can be tested with the repo https://github.com/ChristophLindemann/NuGet.Build.Packaging.MultiTargeting.Test

This is only a partial fix! The files are now correctly imported, but it fails with error NG0012: Duplicate package source files with distinct content detected. Duplicates are not allowed in the package. Please remove the conflict between these files... due to package content from referenced multitarget projects are imported multiple times. I guess when resolving references, it should take into account the targetframework and only resolve those which are matching.

Maybe @kzu has some input on where/how to solve?

This problem can also be seen with the NuGet.Build.Packaging.MultiTargeting.Test repo after upgrading to a new version of NuGet.Build.Packaging with the fixed buildMultiTargeting stuff.

kzu commented 6 years ago

Thanks for your contribution!

ChristophLindemann commented 6 years ago

@kzu, thank you! for making this package.

If you have any input on how to fix the duplicate problem, when referencing multi target projects, that would be greatly appreciated. Then I could try to fix that also.

Right now I don't have the full understanding of how these package files are resolved, where to filter (targets or task/c#) and how to filter so I select the files with the best matching target framework.

Example, when project.a (netstandard2.0; net471) references project.b (netstandard2.0;net451) then when building proj.a (net471) it should probably reference proj.b (netstandard2.0) as the API surface matches better? Or should it reference proj.b (net451) because they both are framework version?