Sitelet https://github.com/fsprojects/Paket/issues/3269
Skip to content

Source-Only NuGet packages add <Compile Include="..." /> to csproj, resulting in build errors.  #3269

Description

@btodts

Description

Paket Installing a source-only NuGet package adds a Compile element to the csproj file, which leads to build errors in the new dotnet sdk: Duplicate Compile items were included. The .NET SDK includes Compile items from your project directory by default. You can either remove these items from your project file, or set the 'EnableDefaultCompileItems' property to 'false' if you want to explicitly include them in your project file.

Repro steps

  1. Step A

Add e.g. TinyIoC to your paket.dependencies and paket.references of your dotnet 1.1+ console application.

  1. Step B

Run paket Install.

Expected behavior

The files in the Content folder of the NuGet package (in TinyIoC's case, TinyIoC.cs) are added to the project. Since the dotnet sdk moved the globs to include compile items to the properties of the sdk, it isn't necessary that an element (<Compile Include="TinyIoC.cs" />) is added to the cspoj. Expected behavior is therefore that this doesn't happen. (more info: https://aka.ms/sdkimplicititems)

Actual behavior

It does :) A Compile element is added to the csproj, which causes build errors (see above).

Known workarounds

The error goes away when you remove the element from the csproj, but it is added again after every paket Install, which is unfortunate.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions