4

I'm creating a .NET core API that consumes a web service with the Rider IDE.

I created a new csproj FooBar.Service, and added the web reference. The FooBar.Service.csproj file is as follow:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <WCFMetadata Include="Service References" />
  </ItemGroup>

  <ItemGroup>
    <WCFMetadataStorage Include="Service References\FooBar" />
  </ItemGroup>

  <ItemGroup>
    <None Include="App.config" />
    <None Include="Service References\FooBar\FooBar.svcmap">
      <Generator>WCF Proxy Generator</Generator>
      <LastGenOutput>FooBar.cs</LastGenOutput>
    </None>
    <None Include="Service References\FooBar\FooBar.webref" />
    <None Include="Service References\FooBar\FooBar.wsdl" />
  </ItemGroup>

  <ItemGroup>
    <Compile Include="Service References\FooBar\FooBar.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>FooBar.svcmap</DependentUpon>
    </Compile>
  </ItemGroup>

  <ItemGroup>
    <Reference Include="System.ServiceModel" />
  </ItemGroup>

</Project>

The generated code seems correct, but I have this error:

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. For more information, see https://aka.ms/sdkimplicititems. The duplicate items were: 'Service References\FooBar\FooBar.cs'

I've read the other question about this issue: the answer is that there are 2 compile items with the same name. If I understand the error message, the file is firstly added by default because it is in the folder of the .csproj, and it is added again by the <Compile Include="Service References\FooBar\FooBar.cs"> item.

I guess that this is a bug of the Rider web service code generation, but what could be a workaround without messing up with the automaticaly generated code? I know that I can deactivate the EnableDefaultCompileItems flag, but I'd prefer not to because I prefer this behavior.

I tried to replace the Include with an Update as seen in this answer, but then I have a bunch of compile error that says: The type or namespace name 'ServiceModel' does not exist in the namespace 'System' (are you missing an assembly reference?) although it is included.

Boiethios
  • 38,438
  • 19
  • 134
  • 183
  • Do you have a `Directory.Build.props` file in your solution folder? – Lasse V. Karlsen May 23 '19 at 08:50
  • @LasseVågsætherKarlsen No, there is no such a file. – Boiethios May 23 '19 at 08:51
  • @LasseVågsætherKarlsen Nevermind, the solution was to replace the `Include` by an `Update`. The other error has nothing to do with this issue -_-. Not sure what I should do, as the answer I linked is not marked as *the* answer: is it a duplicate, tho? – Boiethios May 23 '19 at 08:54
  • Sirm did you resolve this problem? I am facing with it right now *( – Andrew Aug 15 '19 at 19:56
  • @Andrew The solution is there: https://stackoverflow.com/questions/44126231/asp-net-core-with-docker-duplicate-content-items-were-included/44126488#44126488 – Boiethios Aug 16 '19 at 07:14

0 Answers0