dotnet / dotnet/project-system

contentFiles under "any" folder doesn't work with PackageReference-style with classic csproj

Open
#3,042 10 comments 4 reactions 1 assignee Claimed by @tmeschter View on GitHub
Feature-NuGet Legacy Triage-Investigate
Dominant language
C#
Stars
1k
Forks
415
PR merge metrics
No merged PRs in 30d

Description

Copied from https://github.com/NuGet/Home/issues/6287

## Details about Problem

Using VS UI/nuget.exe pack

NuGet version in VS: 4.5.0

VS version: 15.5.0

OS version: win10 v1709 (16299.98)

## Detailed repro steps so we can see the same problem

1. See the repro below. Basically try using contentFiles to control attributes like copyToOutput and have the target folder use "any" rather than a specific value
2. Pack the nuspec and install the nupkg into a .NET Framework project using PackageReference style.
3. Alternatively, use a CPS-style csproj with TargetFramwork=net471 (or similar)

Expected:
All the files listed appear in the output directory after building.

Actual:
Only the file in contentFiles\cs\net45 appears in the output directory after building.

Note that the bug does not repro when using a .NET Core project.
Note also that the bug is only for target locations such as:
contentFiles\cs\any
contentFiles\any\any

Things work correctly for targets such as:
contentFiles\cs\net45

Apologies if this is a dup, but I couldn't find this specific issue in a quick search.

### Sample Project
[repro.zip](https://github.com/NuGet/Home/files/1543873/repro.zip)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.