Skip to content

msbuild /t:pack does not include conditionally included pack content #6792

Open

Description

@rainersigwald

From @jsmarcus on April 8, 2018 13:43

Steps to reproduce

Packing a multi-targeted library with the conditionally included ItemGroup does not include the specified content files. If the condition is removed it includes the content but for all TFMs.

Project file

<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">

  <PropertyGroup>
    <TargetFrameworks>netstandard1.3;netstandard2.0;Xamarin.iOS10;MonoAndroid80;uap10.0.16299</TargetFrameworks>
  </PropertyGroup>

  <ItemGroup>
    <FontFiles Include="*.otf;*.ttf" />
  </ItemGroup>

  <ItemGroup Condition=" $(TargetFramework.StartsWith('Xamarin.iOS')) ">
    <BundleResource Include="@(FontFiles)" Pack="true" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="MSBuild.Sdk.Extras" Version="1.3.0" PrivateAssets="All" />
  </ItemGroup>

  <Import Project="$(MSBuildSDKExtrasTargets)" Condition="Exists('$(MSBuildSDKExtrasTargets)')" />

</Project>

Directory contents:

/
- font.ttf

Command line

msbuild /t:pack

Expected behavior

font.ttf is included in the content and contentFiles portion of the nuspec/nupkg but only for the conditional target framework (in this case Xamarin.iOS10).

Actual behavior

font.ttf is not included as content at all.

Environment data

msbuild /version output:
Microsoft (R) Build Engine version 15.6.85.37198 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

15.6.85.37198

OS info:
Edition: Windows 10 Pro
Version: 1803
Build: 17133.1

If applicable, version of the tool that invokes MSBuild (Visual Studio, dotnet CLI, etc):
Visual Studio Professional 2017
Version 15.6.5

Copied from original issue: dotnet/msbuild#3173

Activity

  1. rainersigwald commented on Apr 9, 2018

    @rainersigwald
    Author

    Thanks for the report. I'm going to move this to the NuGet repo since that's where these targets come from.

  2. mishra14 commented on Apr 9, 2018

    @mishra14
    Contributor

    @jsmarcus please let us know if you are still blocked on this.

  3. added
    WaitingForCustomer
    on Apr 9, 2018
  4. rohit21agrawal commented on Apr 9, 2018

    @rohit21agrawal
    Contributor

    @mishra14 keep the issue open as we should still fix the case that was reported in the OP. my comment is a workaround so @jsmarcus can get unblocked

  5. mishra14 commented on Apr 9, 2018

    @mishra14
    Contributor

    @rohit21agrawal Thanks for pointing that out.

  6. removed
    WaitingForCustomer
    on Apr 9, 2018
  7. added this to the Backlog milestone on Apr 9, 2018
  8. jsmarcus commented on Apr 9, 2018

    @jsmarcus

    Thank you @rohit21agrawal that has allowed me to create the package. I agree that the issue reported should be fixed as well.

  9. added
    Area:ContentFiles
    Category:Quality Week
    Priority:2
    and removed on Mar 11, 2021
  10. removed this from the Backlog milestone on Mar 11, 2021
  11. nkolev92 commented on Jan 27, 2022

    @nkolev92
    Member

    Related to dotnet/sdk/issues/1479 as well.

    There some stuff about the defaults that makes things challenging.

  12. mhmd-azeez commented on Apr 21, 2022

    @mhmd-azeez

    I have also run into this issue and would love to see it fixed

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area:ContentFilesCategory:Quality WeekFunctionality:PackPriority:2Product:dotnet.exeType:Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions