Giter Site home page Giter Site logo

66bit / dotnet-csproj-cleaner Goto Github PK

View Code? Open in Web Editor NEW
3.0 4.0 0.0 8 KB

Workaround for .NET Core compilation issue "Duplicate 'Content' items were included"

License: MIT License

C# 100.00%
csproj visual-studio net-core build-pipelines docker

dotnet-csproj-cleaner's Introduction

dotnet-csproj-cleaner

Workaround for .NET Core compilation issue "Duplicate 'Content' items were included"

If you build .NET Core project under Linux you can face the issue:

/usr/share/dotnet/sdk/1.0.4/Sdks/Microsoft.NET.Sdk/build/Microsoft.NET.Sdk.DefaultItems.targets(188,5): error : Duplicate 'Content' items were included. The .NET SDK includes 'Content' items from your project directory by default. You can either remove these items from your project file, or set the 'EnableDefaultContentItems' property to 'false' if you want to explicitly include them in your project file. For more information, see https://aka.ms/sdkimplicititems. The duplicate items were: ........ [your.csproj]

Possible solutions:

  1. Set EnableDefaultCompileItems=false and add every file to solution manually (additional chance to make mistake)
  2. Remove all entries under 'wwwroot' folder manually before build

Main issue what these projects build without any warnings on Windows and fails during build on server with Linux. It's terrible and require additional developers attention.

Some related discussion about reasons for this strange behaviour can be found here

Solution

Our quick and dirty solution for this issue: create simple program what will remove duplicated entries under Linux as first step during our continuous integration build pipeline. Because this simple tool may be useful for other peoples we decide to share it under MIT license.

Usage:

dotnet dotnet-csproj-cleaner.dll path/to/ProjectFile.csproj

This simple tool will remove all content entries with paths starts from 'wwwwroot' folder (beacause these files already included by default configuration). After that build under Linux will be possible without any additional manual changes. We use it in Docker container during our Jenkins build pipeline.

Docker

Few usage examples:

Process single project file

docker run -v ${PWD}:/src -v /var/lib/dotnet-csproj-cleaner:/cleaner -w /src microsoft/dotnet:1.1-runtime \
  dotnet /cleaner/dotnet-csproj-cleaner.dll YourProjectFile.csproj

Process all project files in folder recursively

docker run -v ${PWD}:/src -v /var/lib/dotnet-csproj-cleaner:/cleaner -w /src microsoft/dotnet:1.1-runtime \
  find . -name '*.csproj' -exec dotnet /cleaner/dotnet-csproj-cleaner.dll {} \;

dotnet-csproj-cleaner's People

Contributors

anakod avatar maksimemelyanov avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.