csproj中的错误 - 重复项目

net*_*jor 56 msbuild projects-and-solutions visual-studio-2010

我有Visual Studio 2010的错误:

错误1在"Sources"参数中多次指定"CrossDomainService.svc.cs"项."Sources"参数不支持重复项.WcfServiceDomain

并从msbuild

C:\ Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.CSharp.targets(160,9):错误MSB3105:"Sources"参数中指定的项目"CrossDomainService.svc.cs"超过了oce ."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>
Run Code Online (Sandbox Code Playgroud)

我没有看到任何重复:/这个错误的任何想法?

Net*_*ter 98

我在我的解决方案中面临同样的问题,其中一个源文件存在相同的错误,

我修好了如下,

  1. 检查给出错误的文件名.

  2. 找出包含文件的项目.

  3. 打开该特定项目的.csproj文件(该文件可以在放置解决方案的目录中找到).

  4. 搜索.csproj文件中引发错误的文件名.

  5. 你会发现该行的两个条目,如

 <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>
Run Code Online (Sandbox Code Playgroud)
  1. 从其中一行中删除任意一行.

  2. 保存更改.

  3. 重新加载项目,你的错误肯定已经消失.

  • 就我而言,NetStarter的诀窍对我有用.我想将其标记为答案.你可以在这里看到详细的帖子[链接](http://social.msdn.microsoft.com/Forums/en-US/e6bcf8e8-8773-4b39-8a07-9e346679ffdf/compile-error-in-test-project-specified-更比一次在所述来源参数) (2认同)
  • 这里没有黑魔法.其他答案是错误的.这是处理此问题的唯一正确方法. (2认同)

小智 5

对于遇到相同问题的人,没有任何帮助他们,他们不想重新创建项目:尝试删除YourPojectName.csproj.user文件.它帮助了我.我之前手动修改了.csproj,并且引入了修改(不知何故)可能与这两个文件存在一些差异.


net*_*jor -2

唯一的解决方案是重新创建项目:/