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

Comment for not-imported package build logic #8445

Open
rainersigwald opened this issue Aug 12, 2019 · 2 comments
Open

Comment for not-imported package build logic #8445

rainersigwald opened this issue Aug 12, 2019 · 2 comments
Labels
Area:Logging Functionality:Restore help wanted Considered good issues for community contributions. Priority:2 Issues for the current backlog. Style:PackageReference Type:DCR Design Change Request
Milestone

Comments

@rainersigwald
Copy link

rainersigwald commented Aug 12, 2019

I just had a bad time trying to figure out why a package I referenced wasn't working for one of the TargetFrameworks in the project. It turned out that this was because we (accidentally) referenced the package only for one of the TFs in the project.

NuGet (correctly!) generated MSBuild logic to import the build/ folder from the package for the affected TF and for the outer build, but not for the other TF in the project.

It would have been nice if there had been a breadcrumb in the generated build logic that said something like

<!-- Package Whatever is not referenced in TargetFramework X -->

Details about Problem

NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe): dotnet CLI primarily

NuGet version (x.x.x.xxx): 5.3.0.0

dotnet.exe --version (if appropriate): 3.0.100-preview9-013744

VS version (if appropriate): 16.3 previews

OS version (i.e. win10 v1607 (14393.321)): all

Worked before? If so, with which NuGet version: no

Detailed repro steps so we can see the same problem

Have a conditional package reference, like

  <ItemGroup Condition="'$(TargetFramework)' == 'net46'">
    <PackageReference Include="MicroBuild.Core" Version="0.3.0" /><!-- can be any package with a build/ folder -->
  </ItemGroup>

Restore. The generated .props file looks like

  <ImportGroup Condition=" '$(TargetFramework)' == '' AND '$(ExcludeRestorePackageImports)' != 'true' ">
    <Import Project="$(NuGetPackageRoot)microbuild.core\0.3.0\buildCrossTargeting\MicroBuild.Core.props" Condition="Exists('$(NuGetPackageRoot)microbuild.core\0.3.0\buildCrossTargeting\MicroBuild.Core.props')" />
  </ImportGroup>
  <ImportGroup Condition=" '$(TargetFramework)' == 'net46' AND '$(ExcludeRestorePackageImports)' != 'true' ">
    <Import Project="$(NuGetPackageRoot)microbuild.core\0.3.0\build\MicroBuild.Core.props" Condition="Exists('$(NuGetPackageRoot)microbuild.core\0.3.0\build\MicroBuild.Core.props')" />
  </ImportGroup>

I'd love to see an additional comment for each import that could have been emitted but wasn't because the reference was not valid for that TF.

Sample Project

8845.zip

@rainersigwald rainersigwald changed the title Comment for framework-specific package import Comment for not-imported package build logic Aug 12, 2019
@rainersigwald
Copy link
Author

Offline @sharwell suggested something like

<!-- 'package' was excluded from target 'netcoreapp2.0' -->
<!-- 'package' does not contain build imports for target 'netcoreapp2.0' -->

@nkolev92 nkolev92 added this to the Backlog milestone Aug 12, 2019
@nkolev92 nkolev92 added Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. help wanted Considered good issues for community contributions. labels Aug 12, 2019
@nkolev92
Copy link
Member

I'm marking this as "logging" for lack of a better way to describe the required change :)

@nkolev92 nkolev92 added Priority:2 Issues for the current backlog. and removed Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. labels Dec 2, 2021
@aortiz-msft aortiz-msft added the Type:DCR Design Change Request label Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:Logging Functionality:Restore help wanted Considered good issues for community contributions. Priority:2 Issues for the current backlog. Style:PackageReference Type:DCR Design Change Request
Projects
None yet
Development

No branches or pull requests

4 participants