wcfasp.net-core-webapiasp.net-core-2.2

Adding WCF Reference in .Net Core 2.2 Web API failed


I am using VS 2017, .Net Core 2.2 API project, with some WCF references to other services. All was working fine till I installed VS 2019 on the same machine.

Now on trying to Add Connected Service, it stuck for some time on the step:

Restoring NuGet packages for bootstrapper...

enter image description here

Then failed with following error message .

Importing web service metadata ...
Number of service endpoints found: 1
Scaffolding service reference code ...
Restoring NuGet packages for bootstrapper ...
Warning:Warning: Determining projects to restore...
C:\Users\midrees\AppData\Local\Temp\WCFConnectedService\2021_Feb_23_10_27_37\svcutil_bootstrap\SvcutilBootstrapper.csproj : error NU1605: Detected package downgrade: Microsoft.Extensions.DependencyInjection from 3.1.2 to 2.2.0. Reference the package directly from the project to select a different version. 
C:\Users\midrees\AppData\Local\Temp\WCFConnectedService\2021_Feb_23_10_27_37\svcutil_bootstrap\SvcutilBootstrapper.csproj : error NU1605:  SvcutilBootstrapper -> Serilog.AspNetCore 3.4.0 -> Microsoft.Extensions.DependencyInjection (>= 3.1.2) 
C:\Users\midrees\AppData\Local\Temp\WCFConnectedService\2021_Feb_23_10_27_37\svcutil_bootstrap\SvcutilBootstrapper.csproj : error NU1605:  SvcutilBootstrapper -> Microsoft.Extensions.DependencyInjection (>= 2.2.0)
C:\Users\midrees\AppData\Local\Temp\WCFConnectedService\2021_Feb_23_10_27_37\svcutil_bootstrap\SvcutilBootstrapper.csproj : error NU1605: Detected package downgrade: Microsoft.Extensions.Logging from 3.1.2 to 2.2.0. Reference the package directly from the project to select a different version. 
C:\Users\midrees\AppData\Local\Temp\WCFConnectedService\2021_Feb_23_10_27_37\svcutil_bootstrap\SvcutilBootstrapper.csproj : error NU1605:  SvcutilBootstrapper -> Serilog.AspNetCore 3.4.0 -> Microsoft.Extensions.Logging (>= 3.1.2) 
C:\Users\midrees\AppData\Local\Temp\WCFConnectedService\2021_Feb_23_10_27_37\svcutil_bootstrap\SvcutilBootstrapper.csproj : error NU1605:  SvcutilBootstrapper -> Microsoft.Extensions.Logging (>= 2.2.0)
  Failed to restore C:\Users\midrees\AppData\Local\Temp\WCFConnectedService\2021_Feb_23_10_27_37\svcutil_bootstrap\SvcutilBootstrapper.csproj (in 8.33 sec).
Building bootstrapper project ...
Error:Error: Microsoft (R) Build Engine version 16.8.3+39993bd9d for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Users\midrees\AppData\Local\Temp\WCFConnectedService\2021_Feb_23_10_27_37\svcutil_bootstrap\SvcutilBootstrapper.csproj : error NU1605: Detected package downgrade: Microsoft.Extensions.DependencyInjection from 3.1.2 to 2.2.0. Reference the package directly from the project to select a different version. 
C:\Users\midrees\AppData\Local\Temp\WCFConnectedService\2021_Feb_23_10_27_37\svcutil_bootstrap\SvcutilBootstrapper.csproj : error NU1605:  SvcutilBootstrapper -> Serilog.AspNetCore 3.4.0 -> Microsoft.Extensions.DependencyInjection (>= 3.1.2) 
C:\Users\midrees\AppData\Local\Temp\WCFConnectedService\2021_Feb_23_10_27_37\svcutil_bootstrap\SvcutilBootstrapper.csproj : error NU1605:  SvcutilBootstrapper -> Microsoft.Extensions.DependencyInjection (>= 2.2.0)
C:\Users\midrees\AppData\Local\Temp\WCFConnectedService\2021_Feb_23_10_27_37\svcutil_bootstrap\SvcutilBootstrapper.csproj : error NU1605: Detected package downgrade: Microsoft.Extensions.Logging from 3.1.2 to 2.2.0. Reference the package directly from the project to select a different version. 
C:\Users\midrees\AppData\Local\Temp\WCFConnectedService\2021_Feb_23_10_27_37\svcutil_bootstrap\SvcutilBootstrapper.csproj : error NU1605:  SvcutilBootstrapper -> Serilog.AspNetCore 3.4.0 -> Microsoft.Extensions.Logging (>= 3.1.2) 
C:\Users\midrees\AppData\Local\Temp\WCFConnectedService\2021_Feb_23_10_27_37\svcutil_bootstrap\SvcutilBootstrapper.csproj : error NU1605:  SvcutilBootstrapper -> Microsoft.Extensions.Logging (>= 2.2.0)

Build FAILED.

C:\Users\midrees\AppData\Local\Temp\WCFConnectedService\2021_Feb_23_10_27_37\svcutil_bootstrap\SvcutilBootstrapper.csproj : error NU1605: Detected package downgrade: Microsoft.Extensions.DependencyInjection from 3.1.2 to 2.2.0. Reference the package directly from the project to select a different version. 
C:\Users\midrees\AppData\Local\Temp\WCFConnectedService\2021_Feb_23_10_27_37\svcutil_bootstrap\SvcutilBootstrapper.csproj : error NU1605:  SvcutilBootstrapper -> Serilog.AspNetCore 3.4.0 -> Microsoft.Extensions.DependencyInjection (>= 3.1.2) 
C:\Users\midrees\AppData\Local\Temp\WCFConnectedService\2021_Feb_23_10_27_37\svcutil_bootstrap\SvcutilBootstrapper.csproj : error NU1605:  SvcutilBootstrapper -> Microsoft.Extensions.DependencyInjection (>= 2.2.0)
C:\Users\midrees\AppData\Local\Temp\WCFConnectedService\2021_Feb_23_10_27_37\svcutil_bootstrap\SvcutilBootstrapper.csproj : error NU1605: Detected package downgrade: Microsoft.Extensions.Logging from 3.1.2 to 2.2.0. Reference the package directly from the project to select a different version. 
C:\Users\midrees\AppData\Local\Temp\WCFConnectedService\2021_Feb_23_10_27_37\svcutil_bootstrap\SvcutilBootstrapper.csproj : error NU1605:  SvcutilBootstrapper -> Serilog.AspNetCore 3.4.0 -> Microsoft.Extensions.Logging (>= 3.1.2) 
C:\Users\midrees\AppData\Local\Temp\WCFConnectedService\2021_Feb_23_10_27_37\svcutil_bootstrap\SvcutilBootstrapper.csproj : error NU1605:  SvcutilBootstrapper -> Microsoft.Extensions.Logging (>= 2.2.0)
    0 Warning(s)
    2 Error(s)

Time Elapsed 00:00:02.97

An error occurred while bootstrapping svcutil. This usually happens when processing references.  You might be able to work around this problem by not providing reference parameters, and manually removing any types redefined in the generated proxy code.
Done.

enter image description here


Solution

  • This is a Visual Studio issue, there is the same issue on github, you can refer to it.

    In addition to using Add Connected Service to generate proxy classes, we can also use dotnet-svcutil command to generate proxy classes.

    The Windows Communication Foundation (WCF) dotnet-svcutil tool is a .NET tool that retrieves metadata from a web service on a network location or from a WSDL file, and generates a WCF class containing client proxy methods that access the web service operations.

    Similar to the Service Model Metadata - svcutil tool for .NET Framework projects, the dotnet-svcutil is a command-line tool for generating a web service reference compatible with .NET Core and .NET Standard projects.

    I suggest you use dotnet-svcutil to generate proxy classes, for more information about dotnet-svcutil, you can refer to this link.