Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rodrigoramos opened this issue Oct 7, 2021 · 3 comments
Open

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

rodrigoramos opened this issue Oct 7, 2021 · 3 comments

Comments

@rodrigoramos
Copy link

rodrigoramos commented Oct 7, 2021

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:
- Microsoft.NETCore.App 5.0.9
- Microsoft.AspNetCore.App 5.0.9

@AdaskoTheBeAsT
Copy link
Member

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

@AdaskoTheBeAsT
Copy link
Member

AdaskoTheBeAsT commented Oct 13, 2021

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
Copy link

Roemer commented Jan 17, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants