Omnisharp not loading properly - Visual Studio Code and Unity - c#

When I try to open a unity script in vscode, I get an error message Some projects have trouble loading. Please review the output for more details.. When I select Show Output, I get this output:
Starting OmniSharp server at 7/5/2022, 6:09:26 PM
Target: /Users/angelalindsay/Desktop/Unity Projects/First Unity Game/First Unity Game/First Unity Game.sln
OmniSharp server started with .NET 6.0.301
.
Path: /Users/angelalindsay/.vscode/extensions/ms-dotnettools.csharp-1.25.0-darwin-x64/.omnisharp/1.39.0-net6.0/OmniSharp.dll
PID: 2949
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Unknown 0.0 (Unknown)
[info]: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService
Using the 'dotnet' on the PATH.
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: .NET Core SDK 6.0.301 17.2.0 - "/usr/local/share/dotnet/sdk/6.0.301/"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: .NET Core SDK 6.0.301 17.2.0 - "/usr/local/share/dotnet/sdk/6.0.301/"
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.MSBuild.ProjectSystem
Detecting projects in '/Users/angelalindsay/Desktop/Unity Projects/First Unity Game/First Unity Game/First Unity Game.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/Users/angelalindsay/Desktop/Unity Projects/First Unity Game/First Unity Game/Assembly-CSharp.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in '/Users/angelalindsay/Desktop/Unity Projects/First Unity Game/First Unity Game'.
[info]: OmniSharp.Script.ScriptProjectSystem
Did not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location '/Users/angelalindsay/Desktop/Unity Projects/First Unity Game/First Unity Game' on host 2915.
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /Users/angelalindsay/Desktop/Unity Projects/First Unity Game/First Unity Game/Assembly-CSharp.csproj
[fail]: OmniSharp.MSBuild.ProjectLoader
This project targets .NET version that requires reference assemblies that are not installed (e.g. .NET Framework). The most common solution is to make sure Mono is fully updated on your machine (https://mono-project.com/download/) and that you are running the .NET Framework build of OmniSharp (e.g. 'omnisharp.useModernNet': false in C# Extension for VS Code).
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file '/Users/angelalindsay/Desktop/Unity Projects/First Unity Game/First Unity Game/Assembly-CSharp.csproj'.
/Users/angelalindsay/Desktop/Unity Projects/First Unity Game/First Unity Game/Assembly-CSharp.csproj
/usr/local/share/dotnet/sdk/6.0.301/Microsoft.Common.CurrentVersion.targets(1221,5): Error: This project targets .NET version that requires reference assemblies that are not installed (e.g. .NET Framework). The most common solution is to make sure Mono is fully updated on your machine (https://mono-project.com/download/) and that you are running the .NET Framework build of OmniSharp (e.g. 'omnisharp.useModernNet': false in C# Extension for VS Code).
[fail]: OmniSharp.MSBuild.ProjectManager
Attempted to update project that is not loaded: /Users/angelalindsay/Desktop/Unity Projects/First Unity Game/First Unity Game/Assembly-CSharp.csproj
[warn]: OmniSharp.Roslyn.CSharp.Services.InlayHints.InlayHintService
Inlay hints requested for document not in workspace Location { FileName = /Users/angelalindsay/Desktop/Unity Projects/First Unity Game/First Unity Game/Assets/Scripts/WayPointFollower.cs, Range = Range { Start = Point { Line = 0, Column = 0 }, End = Point { Line = 21, Column = 0 } } }
[warn]: OmniSharp.Roslyn.CSharp.Services.InlayHints.InlayHintService
Inlay hints requested for document not in workspace Location { FileName = /Users/angelalindsay/Desktop/Unity Projects/First Unity Game/First Unity Game/Assets/Scripts/WayPointFollower.cs, Range = Range { Start = Point { Line = 0, Column = 0 }, End = Point { Line = 21, Column = 0 } } }
I don't know if this is related or not but, the autocomplete for unity is not working in vscode either. I'm able to type code and it works in unity but I would like to have autocomplete and get rid of this error message. Can I fix this? Thanks.

This project targets .NET version that requires reference assemblies
that are not installed (e.g. .NET Framework). The most common solution
is to make sure Mono is fully updated on your machine
(https://mono-project.com/download/) and that you are running the .NET
Framework build of OmniSharp (e.g. 'omnisharp.useModernNet': false in
C# Extension for VS Code).
"Can I fix this?"
Yes, just set omnisharp.useModernNet property to false.

The problem as the console says (thanks for pointing me to check omnisharp's console) is that you don't have the version of .NET which the omnisharp plugin expects.
I solved the issue by installing older version of the extension as mu project was using .NET 5 and the updated version of the extension was searching for .NET 6.
I am not sure if you can set the .NET version per project - probably but didn't find a way.

Related

Unity Visual Studio Code intellisense and coloring not working

I removed the Visual studio code package while trying to fix the autofill not working but now I can't redownload it and says it's downloaded as a dependency
Now in VSC the OmniSharp log is saying all all these errors
Now not only is autofill not working but also non of the code is colored
Does anyone know the fix to this?
Here is the entire log I got
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Unknown 0.0 (Unknown)
[info]: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService
Using the 'dotnet' on the PATH.
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 5 MSBuild instance(s)
1: .NET Core SDK 7.0.101 17.4.0 - "/usr/local/share/dotnet/sdk/7.0.101/"
2: .NET Core SDK 7.0.100 17.4.0 - "/usr/local/share/dotnet/sdk/7.0.100/"
3: .NET Core SDK 6.0.403 17.3.2 - "/usr/local/share/dotnet/sdk/6.0.403/"
4: .NET Core SDK 6.0.401 17.3.1 - "/usr/local/share/dotnet/sdk/6.0.401/"
5: .NET Core SDK 6.0.400 17.3.0 - "/usr/local/share/dotnet/sdk/6.0.400/"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: .NET Core SDK 7.0.101 17.4.0 - "/usr/local/share/dotnet/sdk/7.0.101/"
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in '/Users/kim49048/Desktop/Unity Stuff/First Game'.
[info]: OmniSharp.Cake.CakeProjectSystem
Did not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
Detecting projects in '/Users/kim49048/Desktop/Unity Stuff/First Game/First Game.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/Users/kim49048/Desktop/Unity Stuff/First Game/Assembly-CSharp.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in '/Users/kim49048/Desktop/Unity Stuff/First Game'.
[info]: OmniSharp.Script.ScriptProjectSystem
Did not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location '/Users/kim49048/Desktop/Unity Stuff/First Game' on host 9673.
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /Users/kim49048/Desktop/Unity Stuff/First Game/Assembly-CSharp.csproj
[fail]: OmniSharp.MSBuild.ProjectLoader
This project targets .NET version that requires reference assemblies that are not installed (e.g. .NET Framework). The most common solution is to make sure Mono is fully updated on your machine (https://mono-project.com/download/) and that you are running the .NET Framework build of OmniSharp (e.g. 'omnisharp.useModernNet': false in C# Extension for VS Code).
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file '/Users/kim49048/Desktop/Unity Stuff/First Game/Assembly-CSharp.csproj'.
/Users/kim49048/Desktop/Unity Stuff/First Game/Assembly-CSharp.csproj
/usr/local/share/dotnet/sdk/7.0.101/Microsoft.Common.CurrentVersion.targets(1229,5): Error: This project targets .NET version that requires reference assemblies that are not installed (e.g. .NET Framework). The most common solution is to make sure Mono is fully updated on your machine (https://mono-project.com/download/) and that you are running the .NET Framework build of OmniSharp (e.g. 'omnisharp.useModernNet': false in C# Extension for VS Code).
[fail]: OmniSharp.MSBuild.ProjectManager
Attempted to update project that is not loaded: /Users/kim49048/Desktop/Unity Stuff/First Game/Assembly-CSharp.csproj
[warn]: OmniSharp.Roslyn.CSharp.Services.InlayHints.InlayHintService
Inlay hints requested for document not in workspace Location { FileName = /Users/kim49048/Desktop/Unity Stuff/First Game/Assets/Scripts/PlayerScripts/interactController.cs, Range = Range { Start = Point { Line = 0, Column = 0 }, End = Point { Line = 32, Column = 0 } } }
I've tried deleting visual studio code, redownloading the NET framework, Opened C# project multiple times in Assets, and it won't allow me to change the preferred external tool to VSC

How to made VSCode compatible with ImplicitUsings in dotnet 7?

I am trying to use VSCode on my Linux laptop to develop a dotnet7 WebAPI Application.
So, the vs code version is: 1.74.3, and the .Net Extension Pack is installed on my VSCode.
Also, the C# extension (powered by OmniSharp) v1.25.4 is installed. Nut when I create my application using dotnet new webapi and open the folder using VSCode, the Implicite Usings aren't recognized and codes are shown with a red stroke.
but my project builds successfully and run without any problems. It seems that the VSCode Intellisense is not compatible with the new C# conventions. How cloud I get rid of these fake error indicators?
here are my OmniSharp server logs:
Starting OmniSharp server at 1/31/2023, 9:05:49 PM
Target: /home/navid/Desktop/dotnetTest
OmniSharp server started with .NET 7.0.101
(/usr/share/dotnet).
Path: /home/navid/.vscode/extensions/ms-dotnettools.csharp-1.25.4-linux-x64/.omnisharp/1.39.4-net6.0/OmniSharp.dll
PID: 111338
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Unknown 0.0 (Unknown)
[info]: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService
Using the 'dotnet' on the PATH.
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 2 MSBuild instance(s)
1: .NET Core SDK 6.0.404 17.3.2 - "/usr/share/dotnet/sdk/6.0.404/"
2: .NET SDK 6.0.404 from /usr/share/dotnet/sdk/6.0.404 6.0.404 - "/usr/share/dotnet/sdk/6.0.404"
[warn]: OmniSharp.CompositionHostBuilder
It looks like you have overridden the version of MSBuild with a version lower than 16.8.0 which is the minimum supported by the configured .NET Core Sdk.
Try updating your MSBuild to version 16.8.0 or higher to enable better .NET Core Sdk support.
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: .NET SDK 6.0.404 from /usr/share/dotnet/sdk/6.0.404 6.0.404 - "/usr/share/dotnet/sdk/6.0.404"
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in '/home/navid/Desktop/dotnetTest'.
[info]: OmniSharp.Cake.CakeProjectSystem
Did not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
No solution files found in '/home/navid/Desktop/dotnetTest'
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/home/navid/Desktop/dotnetTest/dotnetTest.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in '/home/navid/Desktop/dotnetTest'.
[info]: OmniSharp.Script.ScriptProjectSystem
Did not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location '/home/navid/Desktop/dotnetTest' on host 111000.
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /home/navid/Desktop/dotnetTest/dotnetTest.csproj
[warn]: OmniSharp.MSBuild.ProjectLoader
You are running the 'restore' operation with an 'HTTP' source, 'http://nexus.xaniis.local/repository/nuget-hosted/'. Non-HTTPS access will be removed in a future version. Consider migrating to an 'HTTPS' source.
[warn]: OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService
No document found. File: /home/navid/Desktop/dotnetTest/Controllers/WeatherForecastController.cs.
[info]: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file '/home/navid/Desktop/dotnetTest/dotnetTest.csproj'.
/home/navid/Desktop/dotnetTest/dotnetTest.csproj
/home/navid/Desktop/dotnetTest/dotnetTest.csproj(0,0): Error: You are running the 'restore' operation with an 'HTTP' source, 'http://nexus.xaniis.local/repository/nuget-hosted/'. Non-HTTPS access will be removed in a future version. Consider migrating to an 'HTTPS' source.
[info]: OmniSharp.MSBuild.ProjectManager
Adding project '/home/navid/Desktop/dotnetTest/dotnetTest.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Update project: dotnetTest
Received response for /findusages but could not find request.
Received response for /findusages but could not find request.
this is my csproj file:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
</Project>
And Also this is my dotnet --list-sdks
5.0.404 [/usr/share/dotnet/sdk]
6.0.101 [/usr/share/dotnet/sdk]
6.0.404 [/usr/share/dotnet/sdk]
7.0.101 [/usr/share/dotnet/sdk]
I found the solution, I had to change the SDK directory of the OmniSharp from V6 to v7.
It is accessible by this key inside the VSCode setting: omnisharp.sdkPath

Visual Studio Intellisense missing classes in C#

Mine Intellisense on VS code isn't working properly because it isn't showing results for some classes. For example, If I type Inpu I would expect Input class to show up but the class is missing , and also if I type GetComp the GetComponent class should pop up but it doesn't. Per https://code.visualstudio.com/docs/other/unity it says for macos to have mono so I installed mono 6.12.0 (stable channel) and made sure it was on the path. I followed the entire step in the link but I still get no intellisense. Intellisense works for other langauges, any help would be appreciated.
Omnisharp settings
"omnisharp.path": "latest",
"omnisharp.useGlobalMono": "never",
Omnisharp log
Starting OmniSharp server at 3/5/2022, 10:13:49 PM
Target: /Users/MacBook/Library/Mobile Documents/com~apple~CloudDocs/game development/Projects/Rocket boost/Rocket boost.sln
OmniSharp server started with .NET 6.0.200
.
Path: /Users/MacBook/.vscode/extensions/ms-dotnettools.csharp-1.24.1/.omnisharp/1.38.1-beta.72-net6.0/OmniSharp.dll
PID: 16120
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Unknown 0.0 (Unknown)
[info]: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService
Using the 'dotnet' on the PATH.
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: .NET Core SDK 6.0.200 17.1.0 - "/usr/local/share/dotnet/sdk/6.0.200/"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: .NET Core SDK 6.0.200 17.1.0 - "/usr/local/share/dotnet/sdk/6.0.200/"
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
[info]: OmniSharp.MSBuild.ProjectSystem
Detecting projects in '/Users/MacBook/Library/Mobile Documents/com~apple~CloudDocs/game development/Projects/Rocket boost/Rocket boost.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/Users/MacBook/Library/Mobile Documents/com~apple~CloudDocs/game development/Projects/Rocket boost/Assembly-CSharp.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in '/Users/MacBook/Library/Mobile Documents/com~apple~CloudDocs/game development/Projects/Rocket boost'.
[info]: OmniSharp.Script.ScriptProjectSystem
Did not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location '/Users/MacBook/Library/Mobile Documents/com~apple~CloudDocs/game development/Projects/Rocket boost' on host 15951.
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /Users/MacBook/Library/Mobile Documents/com~apple~CloudDocs/game development/Projects/Rocket boost/Assembly-CSharp.csproj
[fail]: OmniSharp.MSBuild.ProjectLoader
This project targets .NET version that requires reference assemblies that do not ship with OmniSharp out of the box (e.g. .NET Framework). The most common solution is to make sure Mono is installed on your machine (https://mono-project.com/download/) and that OmniSharp is started with that Mono installation (e.g. "omnisharp.useGlobalMono":"always" in C# Extension for VS Code).
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file '/Users/MacBook/Library/Mobile Documents/com~apple~CloudDocs/game development/Projects/Rocket boost/Assembly-CSharp.csproj'.
/Users/MacBook/Library/Mobile Documents/com~apple~CloudDocs/game development/Projects/Rocket boost/Assembly-CSharp.csproj
/usr/local/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(1220,5): Error: This project targets .NET version that requires reference assemblies that do not ship with OmniSharp out of the box (e.g. .NET Framework). The most common solution is to make sure Mono is installed on your machine (https://mono-project.com/download/) and that OmniSharp is started with that Mono installation (e.g. "omnisharp.useGlobalMono":"always" in C# Extension for VS Code).
[fail]: OmniSharp.MSBuild.ProjectManager
Attempted to update project that is not loaded: /Users/MacBook/Library/Mobile Documents/com~apple~CloudDocs/game development/Projects/Rocket boost/Assembly-CSharp.csproj
Autocomplete: class is missing for GetComponent
Autocomplete: class is missing for Input
sln and csproj generated by unity

Need help retargeting .NET application

I am trying to get vscode to enable c# code completion with unity, as this guide shows. I had a problem earlier that for some reason the .NET targeting pack was installed but the SDK was not, which someone was able to help me with. However, I am still getting errors that say the reference assemblies cannot be found. I have re-installed the developer pack, the .NET SDK and targeting pack, restarted my computer, and uninstalled/ reinstalled extensions. The logs say I might have to retarget the application but that is very vague and I cannot find any guides on how to do that. Thanks for your help.
EDIT: I have tried changing the target framework to 4.8, but omnisharp has the same error log with a different version that I also installed. Could this be a problem with having multiple drives?
.csproj target framework:
v4.7.1
Omnisharp error log:
Starting OmniSharp server at 5/31/2020, 7:56:50 PM
Target: a:\Github\Unity\2_Terminal_Hacker\2_Terminal_Hacker.sln
OmniSharp server started.
Path: c:\Users\0dps1.vscode\extensions\ms-dotnettools.csharp-1.22.0.omnisharp\1.35.2\OmniSharp.exe
PID: 5544
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Windows 6.2.9200.0 (x64) [info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 2 MSBuild instance(s)
1: Visual Studio Community 2019 16.6.30114.105 - "A:\Program Files\Microsoft Visual
Studio\2019\Community\MSBuild\Current\Bin"
2: StandAlone 16.4 - "c:\Users\0dps1.vscode\extensions\ms-dotnettools.csharp-1.22.0.omnisharp\1.35.2.msbuild\Current\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: Visual Studio Community 2019 16.6.30114.105 - "A:\Program Files\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin" [info]:
OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in 'a:\Github\Unity\2_Terminal_Hacker'. [info]: OmniSharp.Cake.CakeProjectSystem
Could not find any Cake files [info]: OmniSharp.MSBuild.ProjectSystem
Detecting projects in 'a:\Github\Unity\2_Terminal_Hacker\2_Terminal_Hacker.sln'. [info]:
OmniSharp.MSBuild.ProjectManager
Queue project update for 'a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj' [info]:
OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in 'a:\Github\Unity\2_Terminal_Hacker'. [info]: OmniSharp.Script.ScriptProjectSystem
Could not find any CSX files [info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider,
Order: 0 [info]: OmniSharp.MSBuild.ProjectManager
Loading project: a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj [info]:
OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider,
Order: 100 [info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider,
Order: 110 [info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider,
Order: 140 [info]: OmniSharp.WorkspaceInitializer
Configuration finished. [info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location 'a:\Github\Unity\2_Terminal_Hacker' on host 4260. [fail]:
OmniSharp.MSBuild.ProjectLoader
The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting
Pack) for this framework version or retarget your application. You can
download .NET Framework Developer Packs at
https://aka.ms/msbuild/developerpacks [warn]:
OmniSharp.MSBuild.ProjectManager
Failed to load project file 'a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj'.
a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj A:\Program
Files\Microsoft Visual
Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1177,5):
Error: The reference assemblies for .NETFramework,Version=v4.7.1 were
not found. To resolve this, install the Developer Pack (SDK/Targeting
Pack) for this framework version or retarget your application. You can
download .NET Framework Developer Packs at
https://aka.ms/msbuild/developerpacks
[fail]: OmniSharp.MSBuild.ProjectManager
Attempted to update project that is not loaded: a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj
https://learn.microsoft.com/en-us/dotnet/standard/frameworks
If you open .csproj files you will see "TargetFramework" tag, and inside it, one of the possible values from the link. "Retarget" means changing "Target Framework" value from "net471" to, say, "net46".
Unfortunately, since this is Unity project, Unity likes to have full control of the content of the csproj files, and any changes you make will be only temporary. So you may retarget to something and make the error go away, but Unity will revert this to "net471" on its whim later.
Your options are:
Fix .net sdk /vscode installation so you get the targetting pack. You may try to open the solution in VS community and maybe it will offer a fix from the UI
Unity has an inbuilt dropdown in player settings to target net2 or something like that instead of net471, but thats a really ancient version of c#/net. It might have been completely deprecated recently.
Do hacks to inject yourself in unity csproj generation so it always use some version you have (not recommended)
EDIT - yes, it's actually very possible it's multiple drive issue. I see from your logs that Visual Studio Community is installed on A:\drive. Reference assemblies are usually found in "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework". So it's very likely that where MSBuild.exe is looking for those and where the targetting pack is actually installed are mismatched.
Don't really have any idea how to fix this other than trying to install VS in default location on C:\ - probably there are some magic environment variables that can be set to trigger MSBuild to look in the right place.

Visual Studio Code .NET framework not working when launched through unity

I am having trouble getting the .net framework to run inside vscode. I can get the .net framework running fine when I open vscode normally. However, when I open a .cs file in unity and use vscode as my default editor, I get error messages because the .net framework no longer works inside vscode. I need the framework for c# specific autocomplete and syntax errors. I have gotten comments on another post that has been closed saying I need to be more specific about this issue. This is not an issue with unity not supporting the .net framework. I have tried restarting my pc, restarting vscode, restarting unity, reimporting unity packages, and redownloading the .net framework. All c# code runs fine inside and outside of unity regardless of whether vscode was launched using the unity shortcut, but running the dotnet command and any c# related autocomplete/syntax do not work. I can edit c# code from unity by running vscode without unity and navigating to the file. Thanks for your help.
dotnet command run in vscode launched by unity
dotnet command run in vscode launched via shortcut
c# code working inside of unity
Omnisharp error message/log:
Starting OmniSharp server at 5/30/2020, 9:41:51 PM
Target: a:\Github\Unity\2_Terminal_Hacker\2_Terminal_Hacker.sln
OmniSharp server started.
Path: c:\Users\0dps1.vscode\extensions\ms-dotnettools.csharp-1.22.0.omnisharp\1.35.2\OmniSharp.exe
PID: 15076
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Windows 6.2.9200.0 (x64) [info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 2 MSBuild instance(s)
1: Visual Studio Community 2019 16.6.30114.105 - "A:\Program Files\Microsoft Visual
Studio\2019\Community\MSBuild\Current\Bin"
2: StandAlone 16.4 - "c:\Users\0dps1.vscode\extensions\ms-dotnettools.csharp-1.22.0.omnisharp\1.35.2.msbuild\Current\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: Visual Studio Community 2019 16.6.30114.105 - "A:\Program Files\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin" [info]:
OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in 'a:\Github\Unity\2_Terminal_Hacker'. [info]: OmniSharp.Cake.CakeProjectSystem
Could not find any Cake files [info]: OmniSharp.MSBuild.ProjectSystem
Detecting projects in 'a:\Github\Unity\2_Terminal_Hacker\2_Terminal_Hacker.sln'. [info]:
OmniSharp.MSBuild.ProjectManager
Queue project update for 'a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj' [info]:
OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in 'a:\Github\Unity\2_Terminal_Hacker'. [info]: OmniSharp.Script.ScriptProjectSystem
Could not find any CSX files [info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider,
Order: 0 [info]: OmniSharp.MSBuild.ProjectManager
Loading project: a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj [info]:
OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider,
Order: 100 [info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider,
Order: 110 [info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider,
Order: 140 [info]: OmniSharp.WorkspaceInitializer
Configuration finished. [info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location 'a:\Github\Unity\2_Terminal_Hacker' on host 13388. [fail]:
OmniSharp.MSBuild.ProjectLoader
The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting
Pack) for this framework version or retarget your application. You can
download .NET Framework Developer Packs at
https://aka.ms/msbuild/developerpacks [warn]:
OmniSharp.MSBuild.ProjectManager
Failed to load project file 'a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj'.
a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj A:\Program
Files\Microsoft Visual
Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1177,5):
Error: The reference assemblies for .NETFramework,Version=v4.7.1 were
not found. To resolve this, install the Developer Pack (SDK/Targeting
Pack) for this framework version or retarget your application. You can
download .NET Framework Developer Packs at
https://aka.ms/msbuild/developerpacks
[fail]: OmniSharp.MSBuild.ProjectManager
Attempted to update project that is not loaded: a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj
The answer is in the log:
[fail]: OmniSharp.MSBuild.ProjectLoader The reference assemblies for
.NETFramework,Version=v4.7.1 were not found. To resolve this, install
the Developer Pack (SDK/Targeting Pack) for this framework version or
retarget your application. You can download .NET Framework Developer
Packs at https://aka.ms/msbuild/developerpacks [warn]:
OmniSharp.MSBuild.ProjectManager Failed to load project file
'a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj'.
a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj A:\Program
Files\Microsoft Visual
Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1177,5):
Error: The reference assemblies for .NETFramework,Version=v4.7.1 were
not found. To resolve this, install the Developer Pack (SDK/Targeting
Pack) for this framework version or retarget your application. You can
download .NET Framework Developer Packs at
https://aka.ms/msbuild/developerpacks
.Net sdk/system libraries are installed through Visual Studio, so vscode/omnisharp tried to pull them from your Visual Studio Community 16.6 installation (info for that is on the start of the log). But it looks like VSCommunity is installed without v4.7.1 targetting pack.
To fix this, go to:
Visual Studio Installer -> Visual Studio Community -> More -> Modify ->
Individual Components
and check ".NETFramework v4.7.1" pack. Afrer this gets installed, reboot stuff and you should be good to go.

Categories