dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.83k stars 653 forks source link

Unity Project have some trouble. #2088

Open NakOh opened 6 years ago

NakOh commented 6 years ago

Environment data

dotnet --info output:

Product Information:
 Version:            2.1.2
 Commit SHA-1 hash:  5695315371

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.13
 OS Platform: Darwin
 RID:         osx.10.12-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.1.2/

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.3
  Build    : a9190d4a75f4a982ae4b4fa8d1a24526566c69df

VS Code version:

Version 1.20.1(1.20.1)

C# Extension version:

1.14.0

Steps to reproduce

Open Project ->

2018-03-05 9 42 58

Expected behavior

Don't Error

Actual behavior

Log :

Starting OmniSharp server at 2018-3-5 09:42:49
    Target: /Users/minsookim/GitHub/PlayHoldemClient/PlayHoldemClient.sln

OmniSharp server started wth Mono
    Path: /Users/minsookim/.vscode/extensions/ms-vscode.csharp-1.14.0/.omnisharp/omnisharp/OmniSharp.exe
    PID: 1766

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on MacOS 10.13.2 (x64)
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Mono 15.0 - "/Library/Frameworks/Mono.framework/Versions/5.2.0/lib/mono/msbuild/15.0/bin"
            2: StandAlone 15.0 - "/Users/minsookim/.vscode/extensions/ms-vscode.csharp-1.14.0/.omnisharp/omnisharp/msbuild/15.0/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Mono 15.0 - "/Library/Frameworks/Mono.framework/Versions/5.2.0/lib/mono/msbuild/15.0/bin"
            CscToolPath = /Users/minsookim/.vscode/extensions/ms-vscode.csharp-1.14.0/.omnisharp/omnisharp/msbuild/15.0/Bin/Roslyn
            CscToolExe = csc.exe
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in '/Users/minsookim/GitHub/PlayHoldemClient'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Initializing in /Users/minsookim/GitHub/PlayHoldemClient
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Auto package restore: False
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Update workspace context
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Resolving projects references
[info]: OmniSharp.MSBuild.ProjectSystem
        Detecting projects in '/Users/minsookim/GitHub/PlayHoldemClient/PlayHoldemClient.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/Users/minsookim/GitHub/PlayHoldemClient/Assembly-CSharp.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/Users/minsookim/GitHub/PlayHoldemClient/Assembly-CSharp-firstpass.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/Users/minsookim/GitHub/PlayHoldemClient/Assembly-CSharp-Editor.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/Users/minsookim/GitHub/PlayHoldemClient/Assembly-CSharp-Editor-firstpass.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in '/Users/minsookim/GitHub/PlayHoldemClient'.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /Users/minsookim/GitHub/PlayHoldemClient/Assembly-CSharp.csproj
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.Stdio.Host
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.Stdio.Host
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location '/Users/minsookim/GitHub/PlayHoldemClient' on host 1744.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project '/Users/minsookim/GitHub/PlayHoldemClient/Assembly-CSharp.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /Users/minsookim/GitHub/PlayHoldemClient/Assembly-CSharp-firstpass.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project '/Users/minsookim/GitHub/PlayHoldemClient/Assembly-CSharp-firstpass.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /Users/minsookim/GitHub/PlayHoldemClient/Assembly-CSharp-Editor.csproj
[warn]: OmniSharp.MSBuild.ProjectLoader
        The referenced project 'Assembly-UnityScript-Editor-firstpass.csproj' does not exist.
/Users/minsookim/GitHub/PlayHoldemClient/Assembly-CSharp-Editor.csproj

[info]: OmniSharp.MSBuild.ProjectManager
        Adding project '/Users/minsookim/GitHub/PlayHoldemClient/Assembly-CSharp-Editor.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /Users/minsookim/GitHub/PlayHoldemClient/Assembly-CSharp-Editor-firstpass.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project '/Users/minsookim/GitHub/PlayHoldemClient/Assembly-CSharp-Editor-firstpass.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Assembly-CSharp
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve assembly '/Users/minsookim/GitHub/PlayHoldemClient/Temp/bin/Debug/Assembly-CSharp-firstpass.dll'
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Assembly-CSharp-firstpass
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Assembly-CSharp-Editor
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve project reference '/Users/minsookim/GitHub/PlayHoldemClient/Assembly-UnityScript-Editor-firstpass.csproj' for 'Assembly-CSharp-Editor'.
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve assembly '/Users/minsookim/GitHub/PlayHoldemClient/Temp/bin/Debug/Assembly-CSharp-Editor-firstpass.dll'
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve assembly '/Users/minsookim/GitHub/PlayHoldemClient/Temp/bin/Debug/Assembly-CSharp-firstpass.dll'
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve assembly '/Users/minsookim/GitHub/PlayHoldemClient/Temp/bin/Debug/Assembly-CSharp.dll'
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Assembly-CSharp-Editor-firstpass
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve assembly '/Users/minsookim/GitHub/PlayHoldemClient/Temp/bin/Debug/Assembly-CSharp-firstpass.dll'
NakOh commented 6 years ago

Occurs after updating to the latest VS Code.

rchande commented 6 years ago

@NakOh If you dotnet build your project, are there any errors?

DustinCampbell commented 6 years ago

This looks like a Unity project rather than a .NET Core project, so I'd expect dotnet build to fail.

@NakOh: Have you tried building your Unity project?

aohajin commented 6 years ago

@DustinCampbell building the unity project will not help.

DustinCampbell commented 6 years ago

@aohajin : Why would it not help? Based on the error, my assumption is that the project is expecting to find a binary on disk that isn't present.

NakOh commented 6 years ago

How to build dotnet Build?

.NET Core용 Microsoft (R) Build Engine 버전 15.5.179.9764 Copyright (C) Microsoft Corporation. All rights reserved.

MSBUILD : error MSB1011: 사용할 프로젝트 또는 솔루션 파일을 지정하십시오. 이 폴더에 프로젝트 또는 솔루션 파일이 두 개 이상 있습니다.

It's korean.

It means. One More Project or Solution in Folder

And

.NET Core용 Microsoft (R) Build Engine 버전 15.5.179.9764 Copyright (C) Microsoft Corporation. All rights reserved.

/Users/minsookim/GitHub/PlayHoldemClient/PlayHoldemClient.sln : 솔루션 파일 error MSB5004: 솔루션 파일에 이름이 "PlayHoldemClient"인 프로젝트가 두 개 있습니다.

빌드하지 못했습니다.

/Users/minsookim/GitHub/PlayHoldemClient/PlayHoldemClient.sln : 솔루션 파일 error MSB5004: 솔루션 파일에 이름이 "PlayHoldemClient"인 프로젝트가 두 개 있습니다. 경고 0개 오류 1개 It means Two Project in same file...

DustinCampbell commented 6 years ago

@NakOh: @rchande's suggestion won't work. Building a Unity project with dotnet build will not work. Have you tried building it with xbuild from your Mono installation?

NakOh commented 6 years ago

If i xbuild -> msbuild .

2018-03-21 9 21 59

2018-03-21 9 22 09

aohajin commented 6 years ago

@DustinCampbell because the dll required was not at the place where omnisharp thought it should be.. for my case image

but Unity(5.6.5f1) actually put the dll here: C:\xiimoon\Ngame\Library\ScriptAssemblies\Assembly-CSharp.dll

Leopotam commented 6 years ago

@NakOh did you tried to install mono package from homebrew? If not - try it, unity projects works on my side with dotnet + mono. Looks like this extension will never work as should, better to use old good checked solutions like mono.

DustinCampbell commented 6 years ago

FWIW, to work with Unity, I recommend installing mono from brew like so:

brew cask install mono-mdk

rather than

brew cask mono

The latter does not include large swaths of Mono, including Mono's msbuild (which OmniSharp will use if present).

Leopotam commented 6 years ago

@DustinCampbell standard mono package was broken half year ago, now it works, I use it instead of cask mono-mdk:

brew install mono
DustinCampbell commented 6 years ago

it works now? Cool! I haven't looked at it in quite awhile.

Leopotam commented 6 years ago
> brew info mono
mono: stable 5.4.1.6 (bottled)

and 2 packages:

brew cask install dotnet
brew cask install dotnet-sdk
DustinCampbell commented 6 years ago

I just tried brew install mono and it still doesn't include Mono's MSBuild. So, installing the MDK is still needed to allow more project types to work with C# for VS Code. However, if it works for you -- great!

Leopotam commented 6 years ago

Well, it works for unity projects on osx, I dont care about vscode as standalone C# development editor, only as IDE-companion for unity.

Leopotam commented 6 years ago

@DustinCampbell btw, I checked omnisharp log, it filled with warnings too, but no errors and intellisense works correctly.

NakOh commented 6 years ago

OK. I installed

brew install mono brew cask instasll dotnet brew cask install dotnet-sdk brew cask install mono-mdk

There was no problem with the original operation, but I was constantly concerned about this warning.

2018-03-22 9 47 17

I will give up and just use vsCode..

Leopotam commented 6 years ago

@NakOh I have only 3 packages installed through homebrew:

mono
cask dotnet
cask dotnet-sdk

With unity 2017.3 i have similar warnings at log: https://gist.github.com/Leopotam/316ccbb113ae191e73618ec432ef3492 But no errors that stops normal execution of this extension.

NakOh commented 6 years ago

@Leopotam Yeah. No Error Yes Warning. I might ignore this problem. but I do not want to see the warning. Why should I look at the warning text that there are no problems?

i want to fix this problem..

Leopotam commented 6 years ago

@NakOh I dont remember (I dont see any settings at my prefs about it), but there is "gear" button at notification window, maybe you can tweak this behaviour through some settings there?

NakOh commented 6 years ago

@Leopotam It is only a temporary solution, and I want a fundamental solution. I hope that OmniSharp's Development Team will be able to solve this problem.

Leopotam commented 6 years ago

@NakOh ahaha, you have the sense of humor :D You can check last year of development in commits list - they fixed only unit-tests support, nothing more. All critical fixes were did by community PRs. So, if you want to see how MS-team works - you will die for age first. If you want to see solution - you should doing it by yourself and make PR.

NakOh commented 6 years ago

@Leopotam I am grateful for the good points and will try to solve the problem. Thank you~

rchande commented 6 years ago

Hi @NakOh @Leopotam The warning about project load issues may or may not reflect a problem. OmniSharp raises this warning if there are actual issues loading the project, or if there are MSBuild warnings when building/restoring the project. We plan to fix this via https://github.com/OmniSharp/omnisharp-vscode/issues/2110.

You can verify that these warnings are ignorable by building/restoring your project and seeing if there are any warnings or errors. If there are, this is what OmniSharp is prompting for. I agree that this behavior is annoying and that's why we plan to fix it.

iambumblehead commented 6 years ago

I've been trying to setup vscode for use with an existing project and am having the same issue as @aohajin above.

My system, Darwin x86_64 mono: 5.10.1.47 dotnet: 2.1.4 VS Code C#: 1.15.2

TheWanderingBen commented 5 years ago

I've been trying to setup vscode for use with an existing project and am having the same issue as @aohajin above.

My system, Darwin x86_64 mono: 5.10.1.47 dotnet: 2.1.4 VS Code C#: 1.15.2

I was just in the same boat, @iambumblehead. I believe if you change your OutputPath in your .csproj files that should fix your problems, though!

JamesYFC commented 5 years ago

I'm getting the wrong directory issue too. dlls and such are expected to be in temp/bin, are actually in library/ScriptAssemblies instead.

... I believe if you change your OutputPath in your .csproj files that should fix your problems, though!

@TheWanderingBen I tried this and it worked for a while, until those lines got switched back again in my .csproj files later on the same day :/ Is there a way to make the change permanently?

MJLeeKor commented 5 years ago

@NakOh It's so long time ago but for the others, just using 'Debugger for Unity' extension, since than everything is good.

lugehorsam commented 5 years ago

I use Debugger for Unity and still have this issue.

LoranceChen commented 5 years ago

warning still here after reinstall vscode and mono :-( image

I'm suppose a reference find fail problem affect by this one. image The problem occurred when create a new .cs file and it code reference some existing class.

For detail message:
image

Leopotam commented 5 years ago

@LoranceChen its because omnisharp-vscode dev-team dont want to support updating *.csproj files in old format (before .net std) if you will add new *.cs-file right inside vscode. You can fix this behaviour with switching to unity (it should start compilation + *.csproj-files will be regenerated with links to new *.cs-files), then switch back to vscode and run command reload window from command palette. vscode will restart plugins and omnisharp-vscode will get new list of project *.cs-files. Same behaviour for any new *.cs-files, even created inside unity - you should restart omnisharp-vscode plugin each time on each change on project files list.

LoranceChen commented 5 years ago

@Leopotam, Thanks. reload window fix the problem. But it's not a normal develop workflow.It seems VS Code not ready for Unity develop yet :-(

Leopotam commented 5 years ago

@LoranceChen shit happens, its my standard workflow on osx last 3 years. Custom codestyle formatting - same thing, no any progress from omnisharp-vscode team last 3 years :) But vs for mac still worse than vscode + omnisharp - slower, consumes more resources, etc. JetBrains Rider much better with code analytics, but worst IDE for performance reasons. But it will be my next choice if they will release community edition.

schplorg commented 4 years ago

I'm getting the wrong directory issue too. dlls and such are expected to be in temp/bin, are actually in library/ScriptAssemblies instead.

... I believe if you change your OutputPath in your .csproj files that should fix your problems, though!

@TheWanderingBen I tried this and it worked for a while, until those lines got switched back again in my .csproj files later on the same day :/ Is there a way to make the change permanently?

I got it working by dropping a symbolic link of Library/ScriptAssemblies into Temp/bin named Debug. It's possible via cmd or with this neat shell extension: http://schinagl.priv.at/nt/hardlinkshellext/linkshellextension.html It's a dirty hack and I wish someone could point me to the real solution to this issue ❤️

JamesYFC commented 4 years ago

I'm getting the wrong directory issue too. dlls and such are expected to be in temp/bin, are actually in library/ScriptAssemblies instead.

... I believe if you change your OutputPath in your .csproj files that should fix your problems, though!

@TheWanderingBen I tried this and it worked for a while, until those lines got switched back again in my .csproj files later on the same day :/ Is there a way to make the change permanently?

I got it working by dropping a symbolic link of Library/ScriptAssemblies into Temp/bin named Debug. It's possible via cmd or with this neat shell extension: http://schinagl.priv.at/nt/hardlinkshellext/linkshellextension.html It's a dirty hack and I wish someone could point me to the real solution to this issue ❤️

Nice solution.

Did you get it to last any decent amount of time? My symlink keeps getting deleted.

RunninglVlan commented 4 years ago

@schplorg, for me symbolic links didn't help. They just removed "Unable to resolve assembly" warnings =( I tried these commands: mklink /J "c:\<project>\Temp\bin\Debug" "C:\<project>\Library\ScriptAssemblies", mklink /D "c:\<project>\Temp\bin\Debug" "C:\<project>\Library\ScriptAssemblies" What's interesting, I have the same project at home and at work, and definitions started not working only at work. =( Yeah, and this feature works fine in Visual Studio. Well, now that's really strange, even changing OutputPath in CSPROJ files doesn't help: <OutputPath>Library\ScriptAssemblies\</OutputPath>. Again it just removes warnings

Could someone help here? BTW, it's interesting, that VS code knows about methods and documentation in these DLLs, but can't Go to Definition =D image

dvgco commented 4 years ago

same issue for me, can not found the assembles in Temp/bin/Debug so, the intellisense could not work.

filipw commented 4 years ago

Could someone help here? BTW, it's interesting, that VS code knows about methods and documentation in these DLLs, but can't Go to Definition =D

This is a regression in extension 1.21.4. See here for a workaround https://github.com/OmniSharp/omnisharp-vscode/issues/3326#issuecomment-539322963

you could also install 1.21.5 VSIX from https://github.com/OmniSharp/omnisharp-vscode/releases/tag/v1.21.5 (it's not yet available on the marketplace)

RunninglVlan commented 4 years ago

Thanks, @filipw, adding "omnisharp.path": "latest" to global (user) settings.json fixed the issue.

filipw commented 4 years ago

yep - I would just advise to remove it after 1.21.5 is shipped to the marketplace, since with "omnisharp.path": "latest" you opt into pulling the latest OmniSharp server build from master each time it's out there - which means it can be:

a) potentially unstable b) slow c) possibly incompatible with the C# extension

RunninglVlan commented 4 years ago

v1.21.5 is out in the Marketplace 🎉

filipw commented 4 years ago

yes correct it was published yesterday 👍