Omnisharp-vscode: Errors when building solution which contains both C# .csproj and F# .fsproj projects.

Created on 24 May 2016  Â·  27Comments  Â·  Source: OmniSharp/omnisharp-vscode

I see the following error for each .fsproj project referenced by another C# .csproj project.

Unable to resolve project reference

Bug Resolved-Fixed

Most helpful comment

I just wanted to let everyone here know that I just released on a new beta of C# for VS Code that should fix this issue: 1.3.0-beta5. You can following these instructions if you're interested in trying it out.

All 27 comments

Hi @jpierson, how are you building the project within VS Code?

Default msbuild task. I'll try to post the content when I have a chance.

On Wed, May 25, 2016, 11:49 AM Dustin Campbell [email protected]
wrote:

Hi @jpierson https://github.com/jpierson, how are you building the
project within VS Code?

—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/OmniSharp/omnisharp-vscode/issues/371#issuecomment-221615900

Sorry, I'm not sure I understand. Do you have a tasks.json set up to build your project within VS Code? Could I see the content of that?

I'm not sure if this is the same problem that the original author describes, but I'm seeing that intellisense/omnisharp within VS Code doesn't know how to handle a referenced F# project.

Please see my sample project here: https://github.com/jp7677/hellocoreclr. Within src I have a c# and an f# project. When opening the c# class that uses the referenced f# project (https://github.com/jp7677/hellocoreclr/blob/master/src/app/GetHelloWorldAction.cs) omnisharp gets to work, but can't resolve the f# class/module. The project builds and runs just fine using "dotnet build"/"dotnet run".

This is my project.json (https://github.com/jp7677/hellocoreclr/blob/master/src/app/project.json) where I reference the f# project like:

"dependencies": {
    ..
    "rules": {
      "version": "0.0.1",
      "target": "project"
    }
    ..
}

PS: Thanks a lot for VS Code, its a really cool project!

@jp7677: That's generally expected (at least if the project isn't built yet), since neither OmniSharp nor the C# Extension for VS Code have any notion of F#.

Hi @DustinCampbell, thanks for your answer. What do mean by "at least if the project isn't built yet"? Is there a way to give a hint to Omnisharp/C# Extension how to resolve references or to point it to an assembly? Even after building VS Code can't resolve the types coming from the f# project.

Sorry for not being clear @jp7677. My point was that the C# Extension for VS Code _should_ be able to resolve types from the F# project if it's output is built and on disk. If it doesn't, that's definitely a bug. However, it will not be able to resolve types if the F# project's assembly is not built, like it can with other C# projects. Does that make sense?

Makes totally sense, thanks @DustinCampbell ;)
Unfortunately, I still got the "The name '[f# module]' does not exist in the current context [netcoreapp1.0]" error in VS Code after building and writing to disk and some VS Code restarts or omnisharp project switches. Should I enter a new issue? Where/for which project should I do that?

In my case, my C# project references two bin-wrapped libraries, one is an F# library and the other is a C# library. Same results as above. Compiles and executes fine via dotnet, but OmniSharp reports type and namespace resolution errors. I'm not sure if this is entirely the same as https://github.com/OmniSharp/omnisharp-vscode/issues/424 or not, so thought I'd post here just in case it's not.

I'm having the same issue. @jp7677 did you ever solved your issue?

@DustinCampbell anything we can do to help you nail this issue?

@luisrudge No, unfortunately not, my VS Code still complains with above message. Though would also love to help to get this resolved.

@DustinCampbell what we can do to help fix this?

Me too.

Repro: open Logary https://github.com/logary/logary and navigate to Program.cs in CSharpExample.

@luisrudge

Somebody needs to set a breakpoint and start debugging to be able to figure out what to do here. I don't know what change needs to be made.

It would seem that it's "just to try to reproduce it" and then PR it.

I have a pretty good idea what's causing this. I have a plan to fix it, but it'll need to wait until 1.11.

I'll leave this open until there's a new C# for VS Code beta with this fix.

I just wanted to let everyone here know that I just released on a new beta of C# for VS Code that should fix this issue: 1.3.0-beta5. You can following these instructions if you're interested in trying it out.

So excited for this fix! Just tried it out and works perfectly. Thank you so much!

Awesome! Thanks for confirming.

@DustinCampbell It works for me too, which is veeeeery cool, thanks!

Is there a chance to get intelisense from referenced f# projects as well?
Right now I get "The type or namespace name 'XXXX' does not exist in the namespace 'YYYY' (are you missing an assembly reference?)" error for every type from a F# lib (everything builds/runs fine).

You will need to build the F# projects first.

That is, build the project and then restart OmniSharp or VS Code. There's future work to watch the metadata output of now C# projects and reload it.

I just noticed that we didn't have a work item tracking this, so I added https://github.com/OmniSharp/omnisharp-roslyn/issues/1008.

I am still seeing this behavior -- even with 1.14.0. and after "build the F# projects first."

Here is how I reproduce...

dotnet new library -lang F# -o .\ClassLibrary
dotnet new console -lang C# -o .\MainProgram
dotnet new sln
dotnet sln add .\ClassLibrary\ClassLibrary.fsproj
dotnet sln add .\MainProgram\MainProgram.csproj
dotnet add .\MainProgram\MainProgram.csproj reference .\ClassLibrary\ClassLibrary.fsproj

_add this line code to program.cs:_ ClassLibrary.Say.hello("world.");

dotnet run -p .\MainProgram\MainProgram.csproj

All the above succeeds on the command line. However, opening in VS Code shows these errors:

The name 'ClassLibrary' does not exist in the current context [MainProgram]

[fail]: OmniSharp.MSBuild.ProjectLoader
    The target "GetTargetPath" does not exist in the project.
c:\Temp\vstest\MainProgram\MainProgram.csproj

I only see the "GetTargetPath" error when I am referencing an F# library from a C# project. I do not see it on a C#-only project.

Hey @WallaceKelly : Sorry for the delay. Could you file a new issue rather than necro-ing a closed issue? Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mshinnie picture mshinnie  Â·  3Comments

jwbay picture jwbay  Â·  3Comments

visten picture visten  Â·  4Comments

mattwoberts picture mattwoberts  Â·  3Comments

kiminuo picture kiminuo  Â·  3Comments