question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
forkicommented, Jul 4, 2018

ok fixed in latest alpha

0reactions
CumpsDcommented, Jul 30, 2018

PR coming… Verified the proposal, fixes the issue and solves the regression

Read more comments on GitHub >

github_iconTop Results From Across the Web

Source-Only NuGet packages add <Compile Include="..." / ...
A Compile element is added to the csproj file: , leading to a build error: Duplicate Compile items were included. The .NET SDK...
Read more >
Build error, This project references NuGet
First I would check if your MusicKarma project has Microsoft.Net.Compilers in its packages.config file. If not then you could remove everything ...
Read more >
Failed to Build Csproj using NuGet Package Microsoft.Build
Hi, I tried to used the NuGet Package Microsoft.Build and Microsoft.Build.Framework to build some csproj with another Application.
Read more >
Source Code Only NuGet Packages
We can put source files — which are behind the Compile item in the MSBuild or resource (resx) files into NuGet Packages. This...
Read more >
nuget does not remove old import from cs project files after ...
I get the following output when I try to publish a project: 1>------ Build started: Project: Fizzler, Configuration: Debug Any CPU ------
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found