error in csproj - duplicate item

error msb3105
duplicate items are not supported by the resources'' parameter
error netsdk1022 duplicate content' items were included
duplicate compile items were included .net core
error netsdk1022: duplicate 'compile' items were included
duplicate content' items were included .net core
duplicate 'embeddedresource' items were included
duplicate 'embeddedresource' items were included xamarin

I have error from visual studio 2010:

Error 1 The item "CrossDomainService.svc.cs" was specified more than once in the "Sources" parameter. Duplicate items are not supported by the "Sources" parameter. WcfServiceDomain

and from msbuild

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.CSharp.targets(160,9) : error MSB3105: The item "CrossDomainService.svc.cs" was specified more than o nce in the "Sources" parameter. Duplicate items are not supported by the "Sources" parameter. [C:\inetpub\Wwwroot\axaptaWcfConnection\WcfServiceDomain\WcfSer viceDomain.csproj]

My file is csproj:

    <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>
    </ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{8D40933A-E036-4CD0-9003-314A692724D5}</ProjectGuid>
    <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>WcfServiceDomain</RootNamespace>
    <AssemblyName>WcfServiceDomain</AssemblyName>
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    <TargetFrameworkProfile />
    <FileUpgradeFlags>
    </FileUpgradeFlags>
    <UpgradeBackupLocation>
    </UpgradeBackupLocation>
    <OldToolsVersion>4.0</OldToolsVersion>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <PlatformTarget>x86</PlatformTarget>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System.Web.ApplicationServices" />
    <Reference Include="System.Web.DynamicData" />
    <Reference Include="System.Web.Entity" />
    <Reference Include="System.Configuration" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.EnterpriseServices" />
    <Reference Include="System.Runtime.Serialization" />
    <Reference Include="System.ServiceModel" />
    <Reference Include="System.ServiceModel.Web" />
    <Reference Include="System.Web.Services" />
  </ItemGroup>
  <ItemGroup>
    <Content Include="ClientAccessPolicy.xml" />
    <Content Include="CrossDomainService.svc" />
    <Content Include="Service1.svc" />
    <Content Include="Web.config">
      <SubType>Designer</SubType>
    </Content>
    <Content Include="Web.Debug.config">
      <DependentUpon>Web.config</DependentUpon>
    </Content>
    <Content Include="Web.Release.config">
      <DependentUpon>Web.config</DependentUpon>
    </Content>
  </ItemGroup>
  <ItemGroup>
    <Compile Include="CrossDomainService.svc.cs">
      <DependentUpon>CrossDomainService.svc</DependentUpon>
    </Compile>
    <Compile Include="ICrossDomainService.cs" />
    <Compile Include="Service1.svc.cs">
      <DependentUpon>Service1.svc</DependentUpon>
    </Compile>
    <Compile Include="IService1.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ProjectExtensions>
    <VisualStudio>
      <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
        <WebProjectProperties>
          <UseIIS>False</UseIIS>
          <AutoAssignPort>True</AutoAssignPort>
          <DevelopmentServerPort>51421</DevelopmentServerPort>
          <DevelopmentServerVPath>/</DevelopmentServerVPath>
          <IISUrl>
          </IISUrl>
          <NTLMAuthentication>False</NTLMAuthentication>
          <UseCustomServer>False</UseCustomServer>
          <CustomServerUrl>
          </CustomServerUrl>
          <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
        </WebProjectProperties>
      </FlavorProperties>
    </VisualStudio>
  </ProjectExtensions>
  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
</Project>

I not see any duplicate :/ Any idea from this error ??

I was facing the same problem in my solution with the same error for one of the source file,

I fixed it out as follows,

  1. Check for the file name for which the error is given.

  2. Find out in which project the file is included.

  3. Open the .csproj file for that particular project (This file can be found in the directory where solution is placed).

  4. Search for the file name for which the error is thrown in the .csproj file.

  5. You will find two entries of the line such as

 <Compile Include="duplicate.aspx.cs">
      <SubType>ASPXCodeBehind</SubType>
      <DependentUpon>Duplicate.aspx</DependentUpon>
    </Compile>


 <Compile Include="duplicate.aspx.cs">
      <SubType>ASPXCodeBehind</SubType>
      <DependentUpon>Duplicate.aspx</DependentUpon>
    </Compile>
  1. Delete any one line from one of them.

  2. Save the changes.

  3. Reload the project your error must have gone.

Fixing the Duplicate Content Error after Upgrading Visual Studio 2017, If you get a duplicate content compile error after upgrading to Visual Studio 2017 v15. 3 on your ASP.NET Core projects. Right click on the project in solution explorer, select Edit [YourProjectName]. csproj, then remove the lines that include content, such as those including content in wwwroot. Unfortunately, I was greeted by this 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 those who encountered the same problem, nothing helped them and they do not want to recreate the project: Try to delete YourPojectName.csproj.user file. It helped me. I modified the .csproj manually before and the modification introduced (somehow) probably some discrepancy to the two files.

Duplicate 'Compile' Items Included Error in Visual Studio, csproj from the context menu. The full text of the error message will tell you the file name that is problematic, and it will be in a section that looks  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.

You could just open the solution in a regular text editor and remove the dups by hand

Error "The following two items have duplicate item metadata" when , From command-line, build the solution: msbuild /p:DeployOnBuild=true /p:​EnablePackageProcessLoggingAndAssert=true. The following error is  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.

Easy! Just right clic in your project and select "Unload Project"

Right clic one again and edir your_project.csproj

Search a duplicate tag for the file mentioned in the error message.

Save and right clic to choose "Reload Project"

The item "Class1.cs" was specified more than once in the "Sources , Core.targets(71,5): error MSB3105: The item "Class1.cs" was specified more than once in the "Sources" parameter. Duplicate items are not  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.

I think I encountered the same problem not too long ago. The solution was to remove the subtype from the web.config, i.e:

<Content Include="Web.config">
  <SubType>Designer</SubType>
</Content>

To:

<Content Include="Web.config">
</Content>

Now, those have been added again, I'm not sure why. Searching for more information hasn't cleared it up yet. See: <Subtype>Designer</Subtype> Added then removed by Visual Studio on load/unload

Duplicate items are not supported by the "Sources" parameter , Duplicate items are not supported by the "Sources" parameter NetTiers, when I tried to compile the project in VS2005 IDE it started showing this error: Entities.​csproj via Notepad I found the following nodes defined twice  Please see the Output Window for details. root element missing' I realized .csproj.user was .csproj.user.bak so I removed the .bak (something like that) then the project opened but I got the 'specified more than once in the "Sources" parameter' until I removed the 'Compile' references from .csproj.user

Error "duplicate compile items included" on renaming files and , Build the project - now the error shows up: "Duplicate 'Compile' items The csproj file now contains an explicit Compile Include to Foo2.cs: With the move to the csproj format in the latest SDK versions, we've moved the default includes and excludes for compile items and embedded resources to the SDK properties files. This means that you no longer need to specify these items in your project file. The main reason for doing this is to reduce the clutter in your project file.

Cannot load project with duplicated project items, The VS 15.5 Solution Explorer doesn't display these projects correctly, but we hardly notice since it doesn't error out like 15.6 does. In any version, msbuild has​  This worked, but I wonder why. How can the project find the items when they are not listed in the project file at all? – Martin Braun Nov 1 '17 at 22:55

Article: Unable to build the project with error, Unable to build the project in Visual Studio with the following error : Duplicate items are not supported by the "Sources" parameter. There is a misconfiguration in .csproj file, the build targets are being imported twice. 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. Solution : Delete the line <Compile Include="**\*.cs" /> in all the csproj files of my project.

Comments
  • In my case NetStarter's trick worked for me. I would like to mark it as an answer for sure. You can see detailed thread Here link
  • @NareshRavlani nice it worked for you just because of a reputation seeking appetite if you can not mark this as an answer please upvote it :p...
  • There is no dark magic here. The other answers are WAY wrong. This is the only proper way to handle this issue.
  • Thank you very much for your solution :)
  • I couldn't find a file that is referenced twice and removing the user file did the job, thanks!
  • Yes. It really sucks to have to do this. Hopefully fixed in VS11?
  • I agree. It will really suck if you have a very huge project and you need to recreate your the entire solution! :'(
  • I agree with You, it's realy weak solution. i hope that Jindra solution could help...
  • Not a practical solution