LinnSystems / LinnworksNetSDK

Linnworks.net Developers
26 stars 41 forks source link

Move to dotnet core 3.1 (from 2.1) fails to build with System.Data.SqlClient does not exist #41

Closed neekfenwick closed 1 year ago

neekfenwick commented 1 year ago

I'm working on a Fedora Linux system with dotnet 3.1 SDK installed as per instructions at https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#manual-install and this environment has more or less worked well for me for years.

I cloned the LinnworksNetSDK project today for the first time in over a year, and I see it has moved to dotnet 3.1, see commit c6b81a6 for the readme update, and the following commit aeadfbd updates lots of files. One of them is the new file Linnworks/src/netcore/LinnworksAPI/ClassBase/SqlMetaData.cs which has the lines:

using System.Data.SqlClient;

and

public SortOrder SortOrder { get; set; }

Both of these generate compile errors for me using the Linux dotnet 3.1 SDK:

*  Executing task: /home/neek/dotnet/dotnet build /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnMacroCustomer/LinnMacroCustomer.csproj /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary 

Microsoft (R) Build Engine version 16.2.37902+b5aaefc9f for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 141.02 ms for /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksMacro/LinnworksMacro.csproj.
  Restore completed in 141.03 ms for /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksMacroHelpers/LinnworksMacroHelpers.csproj.
  Restore completed in 141.02 ms for /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnMacroCustomer/LinnMacroCustomer.csproj.
  Restore completed in 141.03 ms for /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksAPI/LinnworksAPI.csproj.
/home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksAPI/ClassBase/SqlMetaData.cs(6,19): error CS0234: The type or namespace name 'SqlClient' does not exist in the namespace 'System.Data' (are you missing an assembly reference?) [/home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksAPI/LinnworksAPI.csproj]
/home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksAPI/ClassBase/SqlMetaData.cs(30,10): error CS0246: The type or namespace name 'SortOrder' could not be found (are you missing a using directive or an assembly reference?) [/home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksAPI/LinnworksAPI.csproj]

 *  The terminal process "/home/neek/dotnet/dotnet 'build', '/home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnMacroCustomer/LinnMacroCustomer.csproj', '/property:GenerateFullPaths=true', '/consoleloggerparameters:NoSummary'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task: /home/neek/dotnet/dotnet build /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnMacroCustomer/LinnMacroCustomer.csproj /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary 

Microsoft (R) Build Engine version 16.2.37902+b5aaefc9f for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 25.07 ms for /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksMacroHelpers/LinnworksMacroHelpers.csproj.
  Restore completed in 25.06 ms for /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnMacroCustomer/LinnMacroCustomer.csproj.
  Restore completed in 25.07 ms for /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksMacro/LinnworksMacro.csproj.
  Restore completed in 25.08 ms for /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksAPI/LinnworksAPI.csproj.
  LinnworksAPI -> /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksAPI/bin/Debug/netstandard2.0/LinnworksAPI.dll
  LinnworksMacroHelpers -> /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksMacroHelpers/bin/Debug/netstandard2.0/LinnworksMacroHelpers.dll
  LinnworksMacro -> /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksMacro/bin/Debug/netstandard2.0/LinnworksMacro.dll
  LinnMacroCustomer -> /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnMacroCustomer/bin/Debug/netcoreapp2.1/LinnMacroCustomer.dll
 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task: /home/neek/dotnet/dotnet build /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnMacroCustomer/LinnMacroCustomer.csproj /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary 

Welcome to .NET Core 3.1!
---------------------
SDK Version: 3.1.426

Telemetry
---------
The .NET Core tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET Core CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry

----------------
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Find out what's new: https://aka.ms/dotnet-whats-new
Learn about the installed HTTPS developer cert: https://aka.ms/aspnet-core-https
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs
Write your first app: https://aka.ms/first-net-core-app
--------------------------------------------------------------------------------------
Microsoft (R) Build Engine version 16.7.3+2f374e28e for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Restored /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksMacro/LinnworksMacro.csproj (in 8.96 sec).
  Restored /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksMacroHelpers/LinnworksMacroHelpers.csproj (in 8.96 sec).
  Restored /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksAPI/LinnworksAPI.csproj (in 8.96 sec).
  Restored /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnMacroCustomer/LinnMacroCustomer.csproj (in 12.19 sec).
/home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksAPI/ClassBase/SqlMetaData.cs(6,19): error CS0234: The type or namespace name 'SqlClient' does not exist in the namespace 'System.Data' (are you missing an assembly reference?) [/home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksAPI/LinnworksAPI.csproj]
/home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksAPI/ClassBase/SqlMetaData.cs(30,10): error CS0246: The type or namespace name 'SortOrder' could not be found (are you missing a using directive or an assembly reference?) [/home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksAPI/LinnworksAPI.csproj]

I'm not very familiar with dotnet SDK versions but it does look like System.Data.SqlClient does not exist in 3.1, see https://learn.microsoft.com/en-us/dotnet/api/system.data.sqlclient?view=dotnet-plat-ext-7.0&viewFallbackFrom=netcore-3.1 .. it seems to say they are in .NET Platform Extensions 7. Reading about this leads me to think this is a nuget package that ships independently to the .NET SDK (re: https://stackoverflow.com/questions/53097067/what-are-net-platform-extensions-on-docs-microsoft-com).

Do you think a dependency is missing somehow on the LinnworksNetSDK project that would automatically install these .NET Platform Extensions, or is this a manual step I must take? I'm not working in the full Visual Studio where I last used nuget, I have Visual Studio Code on Linux and apparently the dotnet SDK does not ship with nuget. I can install a nuget package from my package manager but it's one that depends on mono packages so I don't think it will play nice with the dotnet 3.1 SDK I've installed.

LinnSystems commented 1 year ago

Thank you for contacting us. This element is used in an underlying class for response for the OpenOrders/GetIdentifiersByOrderIds request. Installing the nuget package System.Data.SqlClient version 4.8.5 resolves this and we will add this package to the dependencies of this project shortly. Whilst writing, we are working toward .net6 version of the SDK which will be released shortly.

neekfenwick commented 1 year ago

Thank you for contacting us.

Thank you very much for replying :) It's great to hear a fix is coming. Interesting to hear that apparently we don't have to install an extensions package, only a single dependency. Since no solution was posted, I googled a little and found that hopefully the following command would add the required package:

$ dotnet add package System.Data.SqlClient --version 4.8.5 (from https://www.nuget.org/packages/System.Data.SqlClient)

I guess that's the syntax to use where one would use the nuget command on Windows machines.

From the build error message it seems the dependency was missing in the LinnworksAPI project, so I found this does solve the problem. i.e.:

(base) [neek@uberneek CheckIncompleteZenMacro (master)]$ cd Linnworks/src/netcore/LinnworksAPI
(base) [neek@uberneek LinnworksAPI (master)]$ dotnet add package System.Data.SqlClient --version 4.8.5
  Writing /tmp/tmpKXvOLN.tmp
info : Adding PackageReference for package 'System.Data.SqlClient' into project '/home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksAPI/LinnworksAPI.csproj'.
info : Restoring packages for /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksAPI/LinnworksAPI.csproj...
info :   GET https://api.nuget.org/v3-flatcontainer/system.buffers/index.json
info :   GET https://api.nuget.org/v3-flatcontainer/system.memory/index.json
info :   OK https://api.nuget.org/v3-flatcontainer/system.memory/index.json 296ms
info :   GET https://api.nuget.org/v3-flatcontainer/system.memory/4.5.4/system.memory.4.5.4.nupkg
info :   OK https://api.nuget.org/v3-flatcontainer/system.memory/4.5.4/system.memory.4.5.4.nupkg 11ms
info :   GET https://api.nuget.org/v3-flatcontainer/system.numerics.vectors/index.json
info :   GET https://api.nuget.org/v3-flatcontainer/system.runtime.compilerservices.unsafe/index.json
info :   OK https://api.nuget.org/v3-flatcontainer/system.buffers/index.json 1008ms
info :   GET https://api.nuget.org/v3-flatcontainer/system.buffers/4.5.1/system.buffers.4.5.1.nupkg
info :   OK https://api.nuget.org/v3-flatcontainer/system.buffers/4.5.1/system.buffers.4.5.1.nupkg 8ms
info :   OK https://api.nuget.org/v3-flatcontainer/system.numerics.vectors/index.json 1005ms
info :   GET https://api.nuget.org/v3-flatcontainer/system.numerics.vectors/4.4.0/system.numerics.vectors.4.4.0.nupkg
info :   OK https://api.nuget.org/v3-flatcontainer/system.runtime.compilerservices.unsafe/index.json 1007ms
info :   GET https://api.nuget.org/v3-flatcontainer/system.runtime.compilerservices.unsafe/4.5.3/system.runtime.compilerservices.unsafe.4.5.3.nupkg
info :   OK https://api.nuget.org/v3-flatcontainer/system.numerics.vectors/4.4.0/system.numerics.vectors.4.4.0.nupkg 15ms
info :   OK https://api.nuget.org/v3-flatcontainer/system.runtime.compilerservices.unsafe/4.5.3/system.runtime.compilerservices.unsafe.4.5.3.nupkg 99ms
info : Installing System.Runtime.CompilerServices.Unsafe 4.5.3.
info : Installing System.Numerics.Vectors 4.4.0.
info : Installing System.Memory 4.5.4.
info : Installing System.Buffers 4.5.1.
info : Package 'System.Data.SqlClient' is compatible with all the specified frameworks in project '/home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksAPI/LinnworksAPI.csproj'.
info : PackageReference for package 'System.Data.SqlClient' version '4.8.5' added to file '/home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksAPI/LinnworksAPI.csproj'.
info : Committing restore...
info : Generating MSBuild file /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksAPI/obj/LinnworksAPI.csproj.nuget.g.props.
info : Writing assets file to disk. Path: /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksAPI/obj/project.assets.json
log  : Restore completed in 2.85 sec for /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksAPI/LinnworksAPI.csproj.

and then..

(base) [neek@uberneek netcore (master)]$ dotnet build
Microsoft (R) Build Engine version 16.2.37902+b5aaefc9f for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 51.5 ms for /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksAPI/LinnworksAPI.csproj.
  Restore completed in 151.7 ms for /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnMacroCustomer/LinnMacroCustomer.csproj.
  Restore completed in 151.7 ms for /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksMacroHelpers/LinnworksMacroHelpers.csproj.
  Restore completed in 151.71 ms for /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksMacro/LinnworksMacro.csproj.
  LinnworksAPI -> /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksAPI/bin/Debug/netstandard2.0/LinnworksAPI.dll
  LinnworksMacroHelpers -> /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksMacroHelpers/bin/Debug/netstandard2.0/LinnworksMacroHelpers.dll
  LinnworksMacro -> /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnworksMacro/bin/Debug/netstandard2.0/LinnworksMacro.dll
  LinnMacroCustomer -> /home/neek/workspace/LinnworksNetSDKProjects/CheckIncompleteZenMacro/Linnworks/src/netcore/LinnMacroCustomer/bin/Debug/netcoreapp2.1/LinnMacroCustomer.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:02.29

I see you've linked a Pull request so I'll Close this issue, hopefully the above commands will help others in future on related issues. Thanks again!