cake-contrib / Cake.SqlServer

Cake Build aliases for working with SQL Server
https://cakebuild.net/extensions/cake-sqlserver/
MIT License
30 stars 17 forks source link

Cake.SqlServer doesn't work right out of the box #76

Open rodrigoramos opened 3 years ago

rodrigoramos commented 3 years ago

Description

Creating a new cake script using dotnet tool and try to use any alias from Cake.SqlServer, we get the following error:

(3292,5): error CS0012: The type 'SqlConnection' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.Data.SqlClient, Version=2.0.20168.4, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5'.

Steps to Reproduce

Steps

  1. In a new folder, create dotnet tool manifest:
    dotnet new tool-manifest
  2. Install cake tool
    dotnet tool install Cake.Tool --version 1.2.0
  3. Create a build.cake script with the following contents:

    #addin "Cake.SqlServer&version=3.0.0"
    
    var target = Argument("target", "Test");
    
    Task("Test")
      .Does(() =>
       {
           const string connStr = "<your connection string>";
           CreateDatabaseIfNotExists(connStr, "EXAMPLE_DATABASE");
       });
    
    RunTarget(target);
  4. Run cake script:
    dotnet cake

    Expected Result

    The script should run without issues and create the database "EXAMPLE_DATABASE"

Actual Result

The following output (with errors) is presented:

Could not load /tmp/fk/tools/Addins/Cake.SqlServer.3.0.0/lib/net5.0/Cake.SqlServer.dll (missing Microsoft.Data.SqlClient, Version=2.0.20168.4, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5))
(3292,5): error CS0012: The type 'SqlConnection' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.Data.SqlClient, Version=2.0.20168.4, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5'.
Error: Error(s) occurred when compiling build script:
(3292,5): error CS0012: The type 'SqlConnection' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.Data.SqlClient, Version=2.0.20168.4, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5'.

Environment

SO: Linux Manjaro Dotnet SDK: 5.0.400 Dotnet Runtime:

AdaskoTheBeAsT commented 3 years ago

Hi, thanks for reporting - I will take a look at this

AdaskoTheBeAsT commented 3 years ago

For now I have only workaround please add in the top of the script

addin "Cake.SqlServer&version=3.0.0&loaddependencies=true"

or add this - but when using this other references can be needed

addin "Microsoft.Data.SqlClient&version=3.0.0"

addin "System.Configuration.ConfigurationManager&version=4.7.0"

addin "Microsoft.Identity.Client&version=4.22.0"

addin "Azure.Identity&version=1.3.0"

addin "Azure.Core&version=1.6.0"

addin "Microsoft.Identity.Client.Extensions.Msal&version=2.16.5"

addin "Microsoft.Bcl.AsyncInterfaces&version=1.0.0"

Roemer commented 2 years ago

Unfortunately that does not work for us. The only workaround that worked for us is by adding: #addin nuget:?package=System.Data.SqlClient&version=4.8.3