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

Errors when building solution which contains both C# .csproj and F# .fsproj projects. #371

Closed
jpierson opened this issue May 24, 2016 · 27 comments · Fixed by OmniSharp/omnisharp-roslyn#1005
Assignees
Milestone

Comments

@jpierson
Copy link

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

Unable to resolve project reference

@DustinCampbell
Copy link
Member

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

@jpierson
Copy link
Author

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 notifications@github.com
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
#371 (comment)

@DustinCampbell
Copy link
Member

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?

@jp7677
Copy link

jp7677 commented Jul 12, 2016

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!

@DustinCampbell
Copy link
Member

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

@jp7677
Copy link

jp7677 commented Jul 12, 2016

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.

@DustinCampbell
Copy link
Member

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?

@jp7677
Copy link

jp7677 commented Jul 13, 2016

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?

@zgramana
Copy link

zgramana commented Aug 13, 2016

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 #424 or not, so thought I'd post here just in case it's not.

@luisrudge
Copy link

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

@luisrudge
Copy link

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

@jp7677
Copy link

jp7677 commented Sep 25, 2016

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

@luisrudge
Copy link

@DustinCampbell what we can do to help fix this?

@haf
Copy link

haf commented Dec 15, 2016

Me too.

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

@haf
Copy link

haf commented Dec 16, 2016

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

@DustinCampbell
Copy link
Member

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.

@DustinCampbell
Copy link
Member

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

@DustinCampbell
Copy link
Member

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.

@ntwilson
Copy link

ntwilson commented Nov 6, 2017

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

@DustinCampbell
Copy link
Member

Awesome! Thanks for confirming.

@cbioley
Copy link

cbioley commented Nov 7, 2017

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

@mrgleba
Copy link

mrgleba commented Nov 8, 2017

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

@DustinCampbell
Copy link
Member

You will need to build the F# projects first.

@DustinCampbell
Copy link
Member

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.

@DustinCampbell
Copy link
Member

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

@WallaceKelly
Copy link

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.

@DustinCampbell
Copy link
Member

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

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

Successfully merging a pull request may close this issue.

10 participants