programing

csproj의 오류-중복 항목

nicescript 2021. 1. 13. 23:34
반응형

csproj의 오류-중복 항목


Visual Studio 2010에서 오류가 발생했습니다.

오류 1 "소스"매개 변수에 "CrossDomainService.svc.cs"항목이 두 번 이상 지정되었습니다. "Sources"매개 변수는 중복 항목을 지원하지 않습니다. WcfServiceDomain

그리고 msbuild에서

C : \ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ Microsoft.CSharp.targets (160,9) : 오류 MSB3105 : "CrossDomainService.svc.cs"항목이 "Sources"매개 변수에 이상 지정되었습니다. . "Sources"매개 변수는 중복 항목을 지원하지 않습니다. [C : \ inetpub \ Wwwroot \ axaptaWcfConnection \ WcfServiceDomain \ WcfSer viceDomain.csproj]

내 파일은 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>

나는 어떤 중복도 보지 않는다 : /이 오류에서 어떤 아이디어 ??


내 솔루션에서 소스 파일 중 하나에 대해 동일한 오류로 동일한 문제에 직면했습니다.

다음과 같이 수정했습니다.

  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.


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.


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


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


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"

Right click


I have the same problem and the solution was to shorten and sanitize the directory name (it was a backup one and has date and time separated by a semicolon).


Open the file WcfServiceDomain.csproj with a text editor and look for CrossDomainService.svc.cs

It'll probably be there twice. Just delete one of the lines and the project will work again.


I had to delete the class from the project and recreating it again to solve this problem.


The way that I fixed this issue was by going to the location where the file was which was included in the error and find that there was two of the same files. Delete one of them and it should work.

I had to undo the pending changes afterwards as the files then went missing, but after a re-build it worked.


What I did was that I renamed the file in question. Then cleaned the solution (by clicking on Build > Clean Solution). Then Built the solution.

Then renamed the file to original filename. Then cleaned the solution and built the solution again.

It worked for me. I dont know if it ll work for u.


For me I unload the project, Edit .csproj file, search for the filename which was showing in error

<ItemGroup>
    <Compile Include="Controllers\BaseUserContext.cs" />
</ItemGroup>

It was not showing multiple time (BaseUserContext.cs), only 1 tag was there, so I removed it and works without an error.


Only solution was recreate project :/

ReferenceURL : https://stackoverflow.com/questions/4539760/error-in-csproj-duplicate-item

반응형