bakery
bakery copied to clipboard
When referencing dll compiled with .net standard 2, intellisense in vs code stop working.
I create a minimal test case.

The problem is in intellisense is not working when i reference a dll copiled with .net standard 2.0
The code is avalaible in https://github.com/gabomgp/test-case-bug-bakery
In the code linked, the build.cake is inside a folder with a project in .net standard 2.0. But, the problem is showed too when the build.cake is outside that folder, and inside the solution's folder, where there are other projects, some projects compiled with .net standard 2.0 and others with .net 4.6.
I think, this issue is related to https://github.com/OmniSharp/omnisharp-roslyn/issues/996
But the solution in that issue dosn't works in .cake files. The solution is:
#! "netcoreapp2.0" directive at the top of your script to force the assembly resolution to assume .NET Core 2.0 mode.
I'm getting the same thing, but with a normal .NET Framework assembly. Nothing .NET Core in the picture.
Just add #r System.IO.Compression.FileSystem and OmniSharp fails. @mholo65 should I start a new issue for this or is it connected? In addition, OmniSharp is incorrectly marking ZipFile as not found without that #r line even though Cake runs it fine without any #r.
@jnm2 ah, I see.. Don't think we actually handle #r directives correctly in Bakery. In Cake itself it's easier, since we use reflection and that will automatically load assemblies from GAC based on only assemblyname. With this bakery/omnisharp-thingy we expect paths to DLLs.... @patriksvensson any ideas?
I ran into the same problem today with #r System.Net.Http.
@jnm2 I created a separate issue for GAC loading here #85
@gabomgp about netstandard2.0, that's not even supported in Cake itself. Why would like it to be supported via intellisense? netstandard2.0 will work eventually, but that will take a little more effort.
@gabomgp said:
But the solution in that issue dosn't works in .cake files. The solution is:
#! "netcoreapp2.0" directive at the top of your script to force the assembly resolution to assume .NET Core 2.0 mode.
Yes, we don't currently support that directive in Cake.
@mholo65 The bigger issue is that I didn't need the #r line for Cake's sake, only OmniSharp's sake. Is there an issue tracking keeping OmniSharp in sync with Cake's default assembly references?
@jnm2 oh, totally missed that. No there's no issue for that. Would you mind submitting one.
Sure. https://github.com/cake-build/bakery/issues/86
@mholo65 The reason is that i want to regenerate the whole database and populate that using entity framework core and cake as the task runner. But, the models and the context are projects compiled with .net standard 2. I must use the context and models to use code first migrations with entity framework core, to create the empty database and populate it easily in developer's machines. I can't do it from cake because the code is in a .net standard 2 library. So, that's the reason :)
@gabomgp I'm sorry but I don't understand this. Cake does not support netstandard2.0 in any way, so why would it help to have support for it in Bakery? You simply can't reference a netstandard2.0 assembly in a cake script until we've merged the work done in Cake for supporting it.
Would you mind elaborating on why you would need Bakery support for this when it's not supported by the Cake script runner?
@gabomgp wouldn’t it make more sense to use the .NET Core EF Command Line Tools for dropping and creating your database? You can still use Cake as task runner and no need to reference DBContext in your Cake script.
@mholo65 It's a good alternative. Thanks for the suggestion. I'll try it.
I'm running into this issue with VS Code on macOS:

Oddly enough, the Intellisense itself is working. Also, there are no errors in the Omnisharp log and the only symbol where I'm getting this error on is the Task alias.
@mholo65 Do you have any suggestions on how to resolve this?
@ecampidoglio hmm, seems like some reference is not passed correctly to Roslyn. What version of Cake are you using? Are you using Cake, Cake.CoreCLR or Cake.Tool? What version of Cake.Bakery are you using? What version of C# for VS Code are you using? Do you use the default OmniSharp version shipped with the VS Code extension, or do specify another version? Do you have a minimal script where this can be reproduced?
- Cake.CoreCLR:
0.33.0 - Cake.Bakery:
0.4.1 - C# for VS Code:
1.19.1 - OmniSharp:
1.32.19 - Mono: ~~
5.4.1.6~~5.20.1.19
I'll see if I can reproduce this in a minimal script.
Btw, everything works as expected with the exact same repo on Windows.
This happens every time with the simplest of scripts:
Task("Hello")
.Does(() =>
{
Information("World");
})
Error message:
The type 'Action' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. (CS0012) [build.cake]
Here's the OmniSharp log:
OmniSharp server started. Path: /Users/Enrico/.vscode/extensions/ms-vscode.csharp-1.19.1/.omnisharp/1.32.19/run PID: 36994
Starting OmniSharp on MacOS 10.13.6 (x64) info: OmniSharp.Services.DotNetCliService DotNetPath set to dotnet info: OmniSharp.MSBuild.Discovery.MSBuildLocator Located 1 MSBuild instance(s) 1: StandAlone 15.0 - "/Users/Enrico/.vscode/extensions/ms-vscode.csharp-1.19.1/.omnisharp/1.32.19/omnisharp/.msbuild/Current/Bin" info: OmniSharp.MSBuild.Discovery.MSBuildLocator MSBUILD_EXE_PATH environment variable set to '/Users/Enrico/.vscode/extensions/ms-vscode.csharp-1.19.1/.omnisharp/1.32.19/omnisharp/.msbuild/Current/Bin/MSBuild.dll' info: OmniSharp.MSBuild.Discovery.MSBuildLocator Registered MSBuild instance: StandAlone 15.0 - "/Users/Enrico/.vscode/extensions/ms-vscode.csharp-1.19.1/.omnisharp/1.32.19/omnisharp/.msbuild/Current/Bin" MSBuildExtensionsPath = /usr/local/Cellar/mono/5.20.1.19/lib/mono/xbuild BypassFrameworkInstallChecks = true CscToolPath = /Users/Enrico/.vscode/extensions/ms-vscode.csharp-1.19.1/.omnisharp/1.32.19/omnisharp/.msbuild/Current/Bin/Roslyn CscToolExe = csc.exe MSBuildToolsPath = /Users/Enrico/.vscode/extensions/ms-vscode.csharp-1.19.1/.omnisharp/1.32.19/omnisharp/.msbuild/Current/Bin TargetFrameworkRootPath = /usr/local/Cellar/mono/5.20.1.19/lib/mono/xbuild-frameworks info: OmniSharp.Cake.CakeProjectSystem Detecting Cake files in '/Users/Enrico/Sources/Cake.Bakery.Issue81'. info: OmniSharp.Cake.CakeProjectSystem Found 1 Cake files. info: OmniSharp.Cake.CakeProjectSystem Added Cake project '/Users/Enrico/Sources/Cake.Bakery.Issue81/build.cake' to the workspace. info: OmniSharp.WorkspaceInitializer Project system 'OmniSharp.DotNet.DotNetProjectSystem' is disabled in the configuration.
Hmm, might be something with the Mono version on your system (or with the one shipped with OmniSharp). Could you try playing with the omnisharp.useGlobalMono in VS Code and see if it helps?
Also, can you reproduce using Cake or Cake.Tool?
@gep13 @devlead are you able to reproduce on Mac?
Setting the useGlobalMono option to always resulted in the same error.
Here's the log:
OmniSharp server started with Mono 5.20.1. Path: /Users/Enrico/.vscode/extensions/ms-vscode.csharp-1.19.1/.omnisharp/1.32.19/omnisharp/OmniSharp.exe PID: 1379
Starting OmniSharp on MacOS 10.13.6 (x64) info: OmniSharp.Services.DotNetCliService DotNetPath set to dotnet info: OmniSharp.MSBuild.Discovery.MSBuildLocator Located 2 MSBuild instance(s) 1: Mono 15.0 - "/usr/local/Cellar/mono/5.20.1.19/lib/mono/msbuild/15.0/bin" 2: StandAlone 15.0 - "/Users/Enrico/.vscode/extensions/ms-vscode.csharp-1.19.1/.omnisharp/1.32.19/omnisharp/.msbuild/Current/Bin" info: OmniSharp.MSBuild.Discovery.MSBuildLocator Registered MSBuild instance: Mono 15.0 - "/usr/local/Cellar/mono/5.20.1.19/lib/mono/msbuild/15.0/bin" CscToolExe = csc.exe CscToolPath = /Users/Enrico/.vscode/extensions/ms-vscode.csharp-1.19.1/.omnisharp/1.32.19/omnisharp/.msbuild/Current/Bin/Roslyn info: OmniSharp.Cake.CakeProjectSystem Detecting Cake files in '/Users/Enrico/Sources/Cake.Bakery.Issue81'. info: OmniSharp.Cake.CakeProjectSystem Found 1 Cake files. info: OmniSharp.Cake.CakeProjectSystem Added Cake project '/Users/Enrico/Sources/Cake.Bakery.Issue81/build.cake' to the workspace. info: OmniSharp.WorkspaceInitializer Project system 'OmniSharp.DotNet.DotNetProjectSystem' is disabled in the configuration.