project-system icon indicating copy to clipboard operation
project-system copied to clipboard

ItemDefinition is not used for Content node

Open uladz-zubrycki opened this issue 4 years ago • 6 comments

Visual Studio Version:

Microsoft Visual Studio Community 2019 Version 16.8.3 VisualStudio.16.Release/16.8.3+30804.86 Microsoft .NET Framework Version 4.8.03752

Installed Version: Community C# Tools 3.8.0-5.20604.10+9ed4b774d20940880de8df1ca8b07508aa01c8cd C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

NuGet Package Manager 5.8.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Other tools are most likely irrelevant and removed for the sake of brevity.

Summary: If project file contains ItemDefinition for Content node, it will be used as expected by msbuild, but won't be respected by Visual Studio.

<ItemDefinitionGroup>
    <Content>
        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
</ItemDefinitionGroup>

Steps to Reproduce:

  1. Create project with ItemDefinitionGroup mentioned above
  2. Add any Content node without explicitly setting CopyToOutput directory to it
  3. Check out items properties in Solution Explorer – CopyToOutputDirectory is None. Build project – item won't be copied.

Expected Behavior: Item has CopyToOutputDirectory equal to PreserveNewest and is copied to output directory on build.

Actual Behavior: Item is not copied.

Sample solution ContentItemDefinition.zip

User Impact: Users are forced to explicitly specify <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> on every Content item they add to the project.

uladz-zubrycki avatar Feb 05 '21 09:02 uladz-zubrycki

This is now tracked by https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1281042

jjmew avatar Feb 19 '21 23:02 jjmew

Could somebody look into this? It is not fixed.

olgolo avatar Feb 26 '22 06:02 olgolo

Sending back to triage as internal ticket was closed without a fix.

drewnoakes avatar Feb 28 '22 03:02 drewnoakes

It is actually causing discrepancy between builds in msbuild and from VisualStudio. It took me a lot of time to debug this problem in our solution.

Is there any parity between build from VisualStudio and MsBuild? If VisualStudio fail to keep parity with MsBuild, why it doesn't use msbuild directly until all such issues are fixed and build result parity is established?

olgolo avatar Feb 28 '22 18:02 olgolo

Next step is to investigate and determine if we, CPS, or the SDK should own this.

tmeschter avatar Mar 11 '22 00:03 tmeschter

Any progress on this?

benjamin-hodgson avatar Aug 16 '22 19:08 benjamin-hodgson