fsprojects / Paket

A dependency manager for .NET with support for NuGet packages and Git repositories.
https://fsprojects.github.io/Paket/
MIT License
2.02k stars 520 forks source link

Potential for improvement after #2234 (simplify .targets/.props) #2238

Open 0x53A opened 7 years ago

0x53A commented 7 years ago

ref https://github.com/fsprojects/Paket/pull/2234

Description

This is not a bug, just a potential for further simplification.

Repro steps

With

framework: net35, net45, net461
nuget Fody 1.29.4 content:once

paket now generates the following import:

  <Choose>
    <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v3.5' Or $(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.6.1')">
      <PropertyGroup>
        <__paket__Fody_targets>portable-net+sl+win+wpa+wp\Fody</__paket__Fody_targets>
      </PropertyGroup>
    </When>
  </Choose>
 <Import Project="..\packages\Fody\build\$(__paket__Fody_targets).targets" Condition="Exists('..\packages\Fody\build\$(__paket__Fody_targets).targets')" Label="Paket" />

Expected behavior

It should detect that the condition applies to all target frameworks, and just directly import the targets file without this property redirection.

<Import Project="..\packages\Fody\buildportable-net+sl+win+wpa+wp\Fody.targets" Condition="Exists('..\packages\Fody\build\portable-net+sl+win+wpa+wp\Fody.targets')" Label="Paket" />

Known workarounds

Not neccessary, it does work, it could just be nicer.

0x53A commented 7 years ago

I think I need a nuget expert here (HELP @enricosada pretty please?):

Are runtimes (e.g. debian/linux/osx/win) ever relevant w.r.t. importing of targets / props files?

My understanding would be no.

Here I calculate all relevant profiles with regard to the current framework restrictions (e.g. autodetect, or manual):

image

Then I partition the targets files by whether their supported targets list is set equal to the one above:

image

Now in this case, the Fody.targets file supports only the DotNetFrameworks(3.5/4.5/4.6.1), not the runtimes, and so the sets are inequal.

But I think the runtimes are irrelevant to this, and should be ignored in this comparison.

Then it would also generate a nice import for this file.