project-system
project-system copied to clipboard
ItemDefinition is not used for Content node
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:
- Create project with
ItemDefinitionGroupmentioned above - Add any
Contentnode without explicitly settingCopyToOutputdirectory to it - Check out items properties in Solution Explorer –
CopyToOutputDirectoryisNone. 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.
This is now tracked by https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1281042
Could somebody look into this? It is not fixed.
Sending back to triage as internal ticket was closed without a fix.
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?
Next step is to investigate and determine if we, CPS, or the SDK should own this.
Any progress on this?