I have built a NuGet package containing a single cs content file (see below; should be renamed). When I create a new Windows Forms App (.NET Framework) using Visual C#, use PackageReference as my NuGet package management format and add the package, I get the error "The item "C:\Users\jgrus.nuget\packages\FooBar\1.0.0\contentFiles\cs\any\FooBar.cs" was specified more than once in the "Sources" parameter. Duplicate items are not supported by the 'Sources' parameter" when compiling. The content file is correctly identified as a resource that should be compiled into the application. Also, IntelliType identifies the content of this file.
In my digging it appears as though the problem may relate to the reference to the code file in project.assets.json as well as *.csproj.nuget.g.props. Both items instruct MSBuild to compile the resource. If I manually adjust the properties in project.assets.json to not compile the resource, it builds successfully and functions as desired.
To reproduce:
Create a new Windows Forms App using C# in Visual Studio 2017
Make sure NuGet preferences are to use PackageReference (Tools -> Options -> NuGet Package Manager -> General -> Default package management format: PackageReference
I have built a NuGet package containing a single cs content file (see below; should be renamed). When I create a new Windows Forms App (.NET Framework) using Visual C#, use PackageReference as my NuGet package management format and add the package, I get the error "The item "C:\Users\jgrus.nuget\packages\FooBar\1.0.0\contentFiles\cs\any\FooBar.cs" was specified more than once in the "Sources" parameter. Duplicate items are not supported by the 'Sources' parameter" when compiling. The content file is correctly identified as a resource that should be compiled into the application. Also, IntelliType identifies the content of this file.
In my digging it appears as though the problem may relate to the reference to the code file in project.assets.json as well as *.csproj.nuget.g.props. Both items instruct MSBuild to compile the resource. If I manually adjust the properties in project.assets.json to not compile the resource, it builds successfully and functions as desired.
To reproduce:
FooBar.1.0.0.nupkg.zip