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

When referencing dll compiled with .net standard 2, intellisense in vs code stop working. #81

Open
gabomgp opened this issue Nov 10, 2017 · 19 comments

Comments

@gabomgp
Copy link

gabomgp commented Nov 10, 2017

I create a minimal test case.

image

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.

@gabomgp
Copy link
Author

gabomgp commented Nov 10, 2017

I think, this issue is related to OmniSharp/omnisharp-roslyn#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.

@jnm2
Copy link

jnm2 commented Nov 13, 2017

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.

@bjorkstromm
Copy link
Member

@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?

@jnm2
Copy link

jnm2 commented Nov 21, 2017

I ran into the same problem today with #r System.Net.Http.

@bjorkstromm
Copy link
Member

@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.

@bjorkstromm
Copy link
Member

@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.

@jnm2
Copy link

jnm2 commented Nov 29, 2017

@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?

@bjorkstromm
Copy link
Member

@jnm2 oh, totally missed that. No there's no issue for that. Would you mind submitting one.

@jnm2
Copy link

jnm2 commented Nov 29, 2017

Sure. #86

@gabomgp
Copy link
Author

gabomgp commented Nov 30, 2017

@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 :)

@patriksvensson
Copy link
Member

@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?

@bjorkstromm
Copy link
Member

@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.

@gabomgp
Copy link
Author

gabomgp commented Dec 2, 2017

@mholo65 It's a good alternative. Thanks for the suggestion. I'll try it.

@ecampidoglio
Copy link
Member

I'm running into this issue with VS Code on macOS:

Cake Bakery-Intellisense-error-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?

@bjorkstromm
Copy link
Member

@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?

@ecampidoglio
Copy link
Member

ecampidoglio commented May 9, 2019

  • 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.

@ecampidoglio
Copy link
Member

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.

@bjorkstromm
Copy link
Member

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?

@ecampidoglio
Copy link
Member

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.

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

5 participants