I have just added a SOAP webservice to a new Asp .net core project. When i try to build the project it results int he following error.
Microsoft.NET.Sdk.DefaultItems.targets(295, 5): [NETSDK1022] 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/WebService/WebService.cs'
After a bit of Googleing i have seen similar errors when people rename files. But I haven't renamed anything this is a new project I have only added the web-service.
I checked the .csproj file and i get this
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<EnableDefaultContentItems>false</EnableDefaultContentItems>
</PropertyGroup>
<ItemGroup>
<Reference Include="System.ServiceModel" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Service References" />
</ItemGroup>
<ItemGroup>
<WCFMetadataStorage Include="Service References\testing" />
<WCFMetadataStorage Include="Service References\WebService" />
</ItemGroup>
<ItemGroup>
<None Include="Service References\WebService\WebService.svcmap">
<Generator>WCF Proxy Generator</Generator>
<LastGenOutput>WebService.cs</LastGenOutput>
</None>
<None Include="Service References\WebService\WebService.webref" />
<None Include="Service References\WebService\WebService.wsdl" />
</ItemGroup>
<ItemGroup>
<Compile Include="Service References\WebService\WebService.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>WebService.svcmap</DependentUpon>
</Compile>
</ItemGroup>
</Project>
I am only seeing one Compile so at a lost too understand whats being duplicated. I did try EnableDefaultCompileItems
which has not resolved the issue. But considering what it does im not that happy with having it there, Even if it did work.
Any help in understanding the cause of this problem and fixing it would be appreciated.
Note: I am using Rider not Visual studio
Update
I did find this one link which seams to imply its an issue in rider and how it adds the web services Rider Creates Incorrect Webservice References for ASP .NET Core projects.
Im not sure that this is the same issue though. As i have created a .net core web api not asp .net core project.
Update 2
On the element in your project file, does it fix the issue if you change the "Include" to say "Update"?
The above was a suggestion from twitter. It appears to remove the original error but then results in a large number of name space errors.
WebService.cs(727, 82): [CS0234] The type or namespace name 'IClientChannel' does not exist in the namespace 'System.ServiceModel' (are you missing an assembly reference?)