.NET Core support
Scripts that use Cake.SqlServer cannot be run or debugged using CoreCLR.
Can we add a netstandard1.6 build to the package? It's okay if things like DACPAK are missing initially; I don't use them.
Willing to help/PR.
There was an attempt to migrate initially, but got abandoned: https://github.com/AMVSoftware/Cake.SqlServer/pull/19
Feel free to PR if you need it sooner. I tried to get it migrated, but BACPAC/DACPAC dependencies are not yet on Core and I did not want a partial solution. But let's go there without it, as it is causing too much pain already.
I've done Cake.Hosts to work on both full-fat framework and Core - can use it as example for build script as that will have to be updated
Mind if I move you to the modern csproj SDK too, like Cake.Hosts?
@jnm2 go wild!
@jnm2 I mean without breaking compatibility ;-P
Awww...
Do you care if I get rid of the Copy-Files task which stages bin files to an intermediate directory and use MSBuild .WithTarget("Pack") to handle pulling all the files for the nupkg?
This is what I have so far: https://github.com/AMVSoftware/Cake.SqlServer/compare/master...jnm2:dotnet_core_support
The last remaining part of the upgrade is to create a multi-targeting nupkg which can either be done manually (which is brittle to changing target frameworks or changing dependencies) or with MSBuild magic.
@jnm2 Looks a lot cleaner - at least the projects files Copy-Files task is a hack, so if it can be fixed go ahead.
The remaining the the hard part - building for multi-platforms is hard.
Cool. One commit at a time. =) Makes it easier to dissect later if needed.
Right now you have <authors>Max Vasilyev</authors><owners>trailmax, cake-contrib</owners>. Do you want to keep that or are you equally happy with <authors>Max Vasilyev</authors><owners>Max Vasilyev</owners> like Cake.Hosts has?
(The difference is whether to use an external .nuspec or do it all from the .csproj.)
You should add an appveyor.yml to the repo to make it easy for me to set up my own AppVeyor test on my own fork.
Currently blocked at https://gitter.im/cake-build/cake?at=59fe39f74ff065ac18b78e65
@jnm2 re <authors> - keep it simple, if we can have a working solution without extra nuspec file - let's do it.
As for the problem of loading assemblies - I have no clue
Cool, thanks. I think you should erase the API keys in that comment though or a bot will pick them up for sure. I don't think I need them.
These are encrypted by appveyor, so no worries.
Guys, may i ask how this issue is going? We are really waiting to use this library in our build process. Can we expect a pull request or new version soon? Or can we help you somehow to port the library?
@Kemyke as @jnm2 says above - he is blocked by Cake's inability to pull Core dependencies - see the link to exception a few messages above. I've not had a chance to do any of this, so @jnm2 is doing all the work here.
Hey @jnm2 which bootstrapper did you use? Currently i am using cake in a dotnet core environment on Ubutnu so there are dotnet core compatible addins out there. I got the same error as you when i use the full framework cake bootstrapper. Did you use the core compatible bootstrapper? Unfortunatelly on the official site it is not available but you can find one here: https://github.com/devlead/BitbucketPipelinesShield/blob/master/build.ps1
The main point to install the Cake.CoreCLR dll and not the Cake.exe.
Hope this help solving your issue.
@Kemyke Interesting. Unfortunately, publishing an addin that breaks everyone unless they switch their bootstrapper to run their scripts on .NET Core is not something I see as a good thing. What if I'm using an unrelated addin that requires .NET Framework (like this one currently does)?
No it won't be breaking change. You should create a nuget package which contains the full framework and the core packages. You can control the target frameworks in the csproj. (eg: net46;netstandard16)
Check this addin for example: Cake.FileHelpers You can download the nupkg (https://www.nuget.org/packages/Cake.FileHelpers/) and check the nuspec file, you can find the multiple targetFramework in it.
@Kemyke That's exactly what we're doing; unfortunately, the approach you suggest is currently blocked. See https://gitter.im/cake-build/cake?at=59fe39f74ff065ac18b78e65.
@jnm2 probably worth copying the exception you get into this thread
Relevant log output:
The addin Cake.SqlServer will reference Cake.SqlServer.dll.
The addin Cake.SqlServer will reference System.Data.Common.dll.
The addin Cake.SqlServer will reference System.Data.SqlClient.dll.
Loaded 'c:/Users/Joseph/Desktop/test/tools/Addins/cake.sqlserver/Cake.SqlServer/lib/netstandard1.6/Cake.SqlServer.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Verifying assembly 'Cake.SqlServer, Version=1.8.5.0, Culture=neutral, PublicKeyToken=null'.
Loaded 'c:/Users/Joseph/Desktop/test/tools/Addins/cake.sqlserver/Cake.SqlServer/lib/netstandard1.6/System.Data.Common.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Verifying assembly 'System.Data.Common, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Loaded 'c:/Users/Joseph/Desktop/test/tools/Addins/cake.sqlserver/Cake.SqlServer/lib/netstandard1.6/System.Data.SqlClient.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Verifying assembly 'System.Data.SqlClient, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Could not load c:/Users/Joseph/Desktop/test/tools/Addins/cake.sqlserver/Cake.SqlServer/lib/netstandard1.6/Cake.SqlServer.dll (missing System.Data.SqlClient, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a))
Could not load file or assembly 'System.Data.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Data.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Data.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Data.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Data.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Data.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Data.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Data.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Data.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load c:/Users/Joseph/Desktop/test/tools/Addins/cake.sqlserver/Cake.SqlServer/lib/netstandard1.6/System.Data.SqlClient.dll (missing System.Data.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
Adding assembly reference to Cake.SqlServer.dll...
Adding assembly reference to System.Data.Common.dll...
Adding assembly reference to System.Data.SqlClient.dll...
Error: Cake.Core.CakeException: Error occurred when compiling build script: c:/Users/Joseph/Desktop/test/build.cake(3,1): error CS0103: The name 'OpenSqlConnection' does not exist in the current context
(2483,5): warning CS1702: Assuming assembly reference 'System.Data.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' used by 'System.Data.SqlClient' matches identity 'System.Data.Common, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' of 'System.Data.Common', you may need to supply runtime policy
at Cake.Scripting.Roslyn.RoslynScriptSession.Execute(Script script)
at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary`2 arguments)
at Cake.Commands.DebugCommand.Execute(CakeOptions options)
at Cake.CakeApplication.Run(CakeOptions options)
at Cake.Program.Main()
The program '[12692] Cake.dll' has exited with code 1 (0x1).
The net46 target works fine, but there's no point in going ahead and adding the netstandard1.6 target until it works on Cake with the default bootstrapper and default configuration.
What makes this addin unique from FileHelpers and others I've looked at is that this one has a package dependency beyond just NETStandard.Library.
Ok, i can reproduce your error from your branch. Taking a look at it...
@Kemyke If you see a way through that I didn't, or you feel like 'being the change we want to see' 😬 in Cake, please take the lead. I've been so busy!
This must be a Cake bug, i have to investigate it further. What i have done for now:
-
Created a nuget from your branch
-
Uploaded it to our own nuget server
-
If i referenced it from a dotnet core project it was working as expected. (e.g. i could drop my test db)
-
If i referenced from a cake script. First i got the same exception as you. So Cake couldn't find the referenced assemblies.
-
Then i published the project which copies all the references in one place and created a nuget package from that.
-
In this case the Cake could find the assembly but i also got error, like the Cake was loading a wrong assembly:
Could not load C:/mypath/Cake.SqlServer.0.0.2/lib/netstandard1.6/Cake.SqlServer.dll (missing System.Data.SqlClient, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a))
Could not load C:/mypath/Cake.SqlServer.0.0.2/lib/netstandard1.6/System.Data.SqlClient.dll (missing System.Data.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
Could not load C:/mypath/Cake.SqlServer.0.0.2/lib/netstandard1.6/runtimes/unix/lib/netstandard1.3/System.Data.SqlClient.dll (missing System.Data.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
Could not load C:/mypath/Cake.SqlServer.0.0.2/lib/netstandard1.6/runtimes/win/lib/netstandard1.3/System.Data.SqlClient.dll (missing System.Data.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
========================================
DropDb
========================================
An error occurred when executing task 'DropDb'.
Unhandled Exception: System.PlatformNotSupportedException: System.Data.SqlClient is not supported on this platform.
at System.Data.SqlClient.SqlConnection.Dispose(Boolean disposing)
at System.Data.Common.DbConnection.Finalize()
Error: One or more errors occurred. (System.Data.SqlClient is not supported on this platform.)
System.Data.SqlClient is not supported on this platform.
Now i am trying to dig deeper.
Since Cake now supports .Net Core, can you guys try this again please?
Another request for .Net Core support please.