wcf icon indicating copy to clipboard operation
wcf copied to clipboard

dotnet-svcutil.xmlserializer doesn't seem to work with latest patch release of System.ServiceModel.Http

Open hughesjon opened this issue 8 years ago • 2 comments

I've recently upgraded my project from .NET Core 2.0 to .NET Core 2.1 and am trying to use dotnet-svcutil.xmlserializer to improve startup performance. I've followed the instructions but it doesn't seem to work using the latest version of System.ServiceModel.Http (4.5.3)

Here is my csproj file:

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

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="dotnet-svcutil.xmlserializer" Version="1.0.0-preview1" />
    <PackageReference Include="Microsoft.Extensions.Options" Version="2.1.1" />
    <PackageReference Include="System.ServiceModel.Http" Version="4.5.3" />
    <PackageReference Include="System.ServiceModel.NetTcp" Version="4.5.3" />
    <PackageReference Include="WindowsAzure.Storage" Version="9.3.1" />
  </ItemGroup>

  <ItemGroup>
    <DotNetCliToolReference Include="dotnet-svcutil.xmlserializer" Version="1.0.0-preview1" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\MyProject.Dependency1\MyProject.Dependency1.csproj" />
    <ProjectReference Include="..\MyProject.Dependency2\MyProject.Dependency2.csproj" />
  </ItemGroup>

  <ItemGroup>
    <WCFMetadata Include="Connected Services" />
  </ItemGroup>

</Project>

When I try to run the build, I get the following output, and no XmlSerializers.dll file is produced

C:\Code\MyProject\MyProject.ServiceClient> dotnet build
Microsoft (R) Build Engine version 15.8.166+gd4e8d81a88 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 41.32 ms for C:\Code\MyProject\MyProject.ServiceClient\MyProject.ServiceClient.csproj.
  Restore completed in 22.26 ms for C:\Code\MyProject\MyProject.Dependency1\MyProject.Dependency1.csproj.
  Restore completed in 23.27 ms for C:\Code\MyProject\MyProject.Dependency2\MyProject.Dependency2.csproj.
  Restore completed in 23.29 ms for C:\Code\MyProject\MyProject.ServiceClient\MyProject.ServiceClient.csproj.
  MyProject.Dependency1 -> C:\Code\MyProject\MyProject.Dependency1\bin\Debug\netstandard2.0\MyProject.Dependency1.dll
  MyProject.Dependency2 -> C:\Code\MyProject\MyProject.Dependency2\bin\Debug\netcoreapp2.1\MyProject.Dependency2.dll
  MyProject.ServiceClient -> C:\Code\MyProject\MyProject.ServiceClient\bin\Debug\netcoreapp2.1\MyProject.ServiceClient.dll
  Microsoft (R) Service Model Metadata Tool\r\n[Microsoft (R) Windows (R) Communication Foundation, Version 1.0.0-preview1]\r\nCopyright (c) Microsoft Corporation.  All rights reserved.\r\n
  Generating XML serializers...
EXEC : warning : There were errors loading types in an assembly loaded from 'C:\Code\MyProject\MyProject.ServiceClient\obj\Debug\netcoreapp2.1\MyProject.ServiceClient.dll' some types in the assembly could not be loaded and will not be available to the tool. [C:\Code\MyProject\MyProject.ServiceClient\MyProject.ServiceClient.csproj]

    Could not load file or assembly 'MyProject.Dependency2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
    Could not load file or assembly 'MyProject.Dependency2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
    Could not load file or assembly 'System.ServiceModel.Primitives, Version=4.5.0.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
    Could not load file or assembly 'System.ServiceModel.Primitives, Version=4.5.0.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
    Could not load file or assembly 'MyProject.Dependency1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
EXEC : warning : An error occurred in the tool. [C:\Code\MyProject\MyProject.ServiceClient\MyProject.ServiceClient.csproj]

EXEC : warning : Could not load file or assembly 'System.ServiceModel.Primitives, Version=4.5.0.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. [C:\Code\MyProject\MyProject.ServiceClient\MyProject.ServiceClient.csproj]

C:\Users\Me\.nuget\packages\dotnet-svcutil.xmlserializer\1.0.0-preview1\build\dotnet-svcutil.xmlserializer.targets(17,5): warning MSB3073: The command "dotnet svcutil.xmlserializer obj\Debug\netcoreapp2.1\MyProject.ServiceClient.dll /out:obj\Debug\netcoreapp2.1\MyProject.ServiceClient.XmlSerializers" exited with code 9. [C:\Code\MyProject\MyProject.ServiceClient\MyProject.ServiceClient.csproj]
C:\Users\Me\.nuget\packages\dotnet-svcutil.xmlserializer\1.0.0-preview1\build\dotnet-svcutil.xmlserializer.targets(18,5): warning : Warning : Fail to generate the serializer for MyProject.ServiceClient.dll. [C:\Code\MyProject\MyProject.ServiceClient\MyProject.ServiceClient.csproj]

Build succeeded.

EXEC : warning : There were errors loading types in an assembly loaded from 'C:\Code\MyProject\MyProject.ServiceClient\obj\Debug\netcoreapp2.1\MyProject.ServiceClient.dll' some types in the assembly could not be loaded and will not be available to the tool. [C:\Code\MyProject\MyProject.ServiceClient\MyProject.ServiceClient.csproj]
EXEC : warning : An error occurred in the tool. [C:\Code\MyProject\MyProject.ServiceClient\MyProject.ServiceClient.csproj]
EXEC : warning : Could not load file or assembly 'System.ServiceModel.Primitives, Version=4.5.0.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. [C:\Code\MyProject\MyProject.ServiceClient\MyProject.ServiceClient.csproj]
C:\Users\Me\.nuget\packages\dotnet-svcutil.xmlserializer\1.0.0-preview1\build\dotnet-svcutil.xmlserializer.targets(17,5): warning MSB3073: The command "dotnet svcutil.xmlserializer obj\Debug\netcoreapp2.1\MyProject.ServiceClient.dll /out:obj\Debug\netcoreapp2.1\MyProject.ServiceClient.XmlSerializers" exited with code 9. [C:\Code\MyProject\MyProject.ServiceClient\MyProject.ServiceClient.csproj]
C:\Users\Me\.nuget\packages\dotnet-svcutil.xmlserializer\1.0.0-preview1\build\dotnet-svcutil.xmlserializer.targets(18,5): warning : Warning : Fail to generate the serializer for MyProject.ServiceClient.dll. [C:\Code\MyProject\MyProject.ServiceClient\MyProject.ServiceClient.csproj]
    5 Warning(s)
    0 Error(s)

Time Elapsed 00:00:04.99

If I downgrade System.ServiceModel.Http to 4.5.0, then it does work (despite still getting warnings about missing DLLs that I don't think should be there):

C:\Code\MyProject\MyProject.ServiceClient> dotnet add package System.ServiceModel.Http -v 4.5.0
  Writing C:\Users\Me\AppData\Local\Temp\tmp4E4D.tmp
info : Adding PackageReference for package 'System.ServiceModel.Http' into project 'C:\Code\MyProject\MyProject.ServiceClient\MyProject.ServiceClient.csproj'.
log  : Restoring packages for C:\Code\MyProject\MyProject.ServiceClient\MyProject.ServiceClient.csproj...
info : Package 'System.ServiceModel.Http' is compatible with all the specified frameworks in project 'C:\Code\MyProject\MyProject.ServiceClient\MyProject.ServiceClient.csproj'.
info : PackageReference for package 'System.ServiceModel.Http' version '4.5.0' updated in file 'C:\Code\MyProject\MyProject.ServiceClient\MyProject.ServiceClient.csproj'.
C:\Code\MyProject\MyProject.ServiceClient> dotnet add package System.ServiceModel.NetTcp -v 4.5.0
  Writing C:\Users\Me\AppData\Local\Temp\tmp89CF.tmp
info : Adding PackageReference for package 'System.ServiceModel.NetTcp' into project 'C:\Code\MyProject\MyProject.ServiceClient\MyProject.ServiceClient.csproj'.
log  : Restoring packages for C:\Code\MyProject\MyProject.ServiceClient\MyProject.ServiceClient.csproj...
info : Package 'System.ServiceModel.NetTcp' is compatible with all the specified frameworks in project 'C:\Code\MyProject\MyProject.ServiceClient\MyProject.ServiceClient.csproj'.
info : PackageReference for package 'System.ServiceModel.NetTcp' version '4.5.0' updated in file 'C:\Code\MyProject\MyProject.ServiceClient\MyProject.ServiceClient.csproj'.
C:\Code\MyProject\MyProject.ServiceClient> cd ..\MyProject.Dependency2
C:\Code\MyProject\MyProject.Dependency2> dotnet add package System.ServiceModel.Http -v 4.5.0
  Writing C:\Users\Me\AppData\Local\Temp\tmpC8EC.tmp
info : Adding PackageReference for package 'System.ServiceModel.Http' into project 'C:\Code\MyProject\MyProject.Dependency2\MyProject.Dependency2.csproj'.
log  : Restoring packages for C:\Code\MyProject\MyProject.Dependency2\MyProject.Dependency2.csproj...
info : Package 'System.ServiceModel.Http' is compatible with all the specified frameworks in project 'C:\Code\MyProject\MyProject.Dependency2\MyProject.Dependency2.csproj'.
info : PackageReference for package 'System.ServiceModel.Http' version '4.5.0' updated in file 'C:\Code\MyProject\MyProject.Dependency2\MyProject.Dependency2.csproj'.
C:\Code\MyProject\MyProject.Dependency2> cd ..\MyProject.ServiceClient\
C:\Code\MyProject\MyProject.ServiceClient> dotnet build
Microsoft (R) Build Engine version 15.8.166+gd4e8d81a88 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restoring packages for C:\Code\MyProject\MyProject.ServiceClient\MyProject.ServiceClient.csproj...
  Restore completed in 23.07 ms for C:\Code\MyProject\MyProject.Dependency1\MyProject.Dependency1.csproj.
  Restore completed in 24.48 ms for C:\Code\MyProject\MyProject.Dependency2\MyProject.Dependency2.csproj.
  Restore completed in 41.11 ms for C:\Code\MyProject\MyProject.ServiceClient\MyProject.ServiceClient.csproj.
  Restore completed in 334.17 ms for C:\Code\MyProject\MyProject.ServiceClient\MyProject.ServiceClient.csproj.
  MyProject.Dependency1 -> C:\Code\MyProject\MyProject.Dependency1\bin\Debug\netstandard2.0\MyProject.Dependency1.dll
  MyProject.Dependency2 -> C:\Code\MyProject\MyProject.Dependency2\bin\Debug\netcoreapp2.1\MyProject.Dependency2.dll
  MyProject.ServiceClient -> C:\Code\MyProject\MyProject.ServiceClient\bin\Debug\netcoreapp2.1\MyProject.ServiceClient.dll
  Microsoft (R) Service Model Metadata Tool\r\n[Microsoft (R) Windows (R) Communication Foundation, Version 1.0.0-preview1]\r\nCopyright (c) Microsoft Corporation.  All rights reserved.\r\n
  Generating XML serializers...
EXEC : warning : There were errors loading types in an assembly loaded from 'C:\Code\MyProject\MyProject.ServiceClient\obj\Debug\netcoreapp2.1\MyProject.ServiceClient.dll' some types in the assembly could not be loaded and will not be available to the tool. [C:\Code\MyProject\MyProject.ServiceClient\MyProject.ServiceClient.csproj]

    Could not load file or assembly 'MyProject.Dependency2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
    Could not load file or assembly 'MyProject.Dependency2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
    Could not load file or assembly 'MyProject.Dependency1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
  C:\Code\MyProject\MyProject.ServiceClient\obj\Debug\netcoreapp2.1\MyProject.ServiceClient.XmlSerializers.cs

Build succeeded.

EXEC : warning : There were errors loading types in an assembly loaded from 'C:\Code\MyProject\MyProject.ServiceClient\obj\Debug\netcoreapp2.1\MyProject.ServiceClient.dll' some types in the assembly could not be loaded and will not be available to the tool. [C:\Code\MyProject\MyProject.ServiceClient\MyProject.ServiceClient.csproj]
    1 Warning(s)
    0 Error(s)

Time Elapsed 00:00:12.10

However, I don't want to do this because version 4.5.0 is the subject of a security advisory.

Am I doing something wrong, or is it possible to get an updated version of the tool that supports the latest versions?

hughesjon avatar Aug 27 '18 06:08 hughesjon

@hughesjon Thank you for reporting the problem. Looks like it is the same issue as #3004 . Can you try the same work around suggested in #3004 ? We area working on a fix in an official release.

Lxiamail avatar Aug 29 '18 21:08 Lxiamail

Close this issue. Trace the same issue with #3004 .

Lxiamail avatar Sep 12 '18 19:09 Lxiamail