Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated restore props and targets need cross-targeting participation support #3496

Closed
nguerrera opened this issue Sep 22, 2016 · 2 comments

Comments

@nguerrera
Copy link

nguerrera commented Sep 22, 2016

Quoting @srivatsn:

Currently the way Microsoft.Common.CrossTargeting.targets finds the target to implement is through a property (CoreCrossTargetingTargetsPath) which is set in the SDK.props file to point to a file which contains the Build target that loops over TFMs. However, restore3 now generates a TFM specific props file. That is, the generated Consoleapp.nuget.g.props file looks like this:

  <ImportGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
    <Import Project="$(NuGetPackageRoot)microsoft.netcore.sdk\1.0.0-alpha-00000001-01\build\netstandard1.0\Microsoft.NETCore.Sdk.props"
                  Condition="Exists('$(NuGetPackageRoot)microsoft.netcore.sdk\1.0.0-alpha-00000001-01\build\netstandard1.0\Microsoft.NETCore.Sdk.props')" />
  </ImportGroup>

When this is imported in the outer build, TargetFramework is not set and so the props don’t get imported which means CoreCrossTargetingTargetsPath is not set. So in Microsoft.Common.CrossTargeting.targets, nothing gets imported. @nick and I’ve discussed an approach before which, if present, could solve this problem. Essentially, if we have a convention for a place for cross-targeting props & targets similar to the current convention for TFMs (say a folder called build\cross) then restore could generate a section in the props\targets specific to the outer build.

So for example if a package had

Build
        | cross | foo.props, 
        | netstandard1.0 | foo.props

Then the consoleapp.nuget.g.props (and similarly targets) would look like

  <ImportGroup Condition=" '$(IsCrossTargetingBuild)' == 'true' ">
    <Import Project="…..\build\cross\foo.props" />
  </ImportGroup>

  <ImportGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
    <Import Project="…..\build\netstandard10\foo.props " />
  </ImportGroup>
@rrelyea
Copy link
Contributor

rrelyea commented Sep 22, 2016

Our plan:
Nupkg needs to support \buildCrossTargeting\ folder - and import .targets/.props for "crosstargeting" msbuild scope

@rrelyea rrelyea modified the milestones: 3.6 Beta2, 3.6 Beta1 Sep 22, 2016
emgarten added a commit to NuGet/NuGet.Client that referenced this issue Sep 23, 2016
Targets and prop files named with the package id and put into nupkg/buildCrossTargeting will be imported into the cross targeting area above target framework specific targets.

Fixes NuGet/Home#3496
@emgarten
Copy link
Member

NuGet/NuGet.Client@9b3a460

Use buildCrossTargeting/{packageId}.targets and buildCrossTargeting/{packageId}.props

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants