Intellisense has stopped working for me and whenever I run VSCode this error comes up in the OmniSharp Log.
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file '/Users/leogaunt/Documents/Programming/Unity/Cube Stack/Assembly-CSharp.csproj'.
/Users/leogaunt/Documents/Programming/Unity/Cube Stack/Assembly-CSharp.csproj
/Users/leogaunt/.vscode/extensions/ms-dotnettools.csharp-1.23.1/.omnisharp/1.37.0/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1178,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: /Users/leogaunt/Documents/Programming/Unity/Cube Stack/Assembly-CSharp.csproj
I have tried re-installing the plugin, and re-intsalling VSCode but it hasn't worked.
I know I have .NET Core installed as I am a Mac user and I know this because when I type dotnet --version in terminal it outputs:
3.1.401
I am programming in Unity and am creating a game for iOS.
Change the mono path to always, in C# extension config.
For anyone that uses VSCode v1.67.2 dotnet v3.x.x and OmniSharp v1.25.0 (or v1.23.17 and above).
The above accepted answer does not solve the issue.
The simplest thing to do is downgrade ms-dotnettools.csharp (C# Extension), the only issue is if you downgrade to any version above v1.23.16 it gives you "Can't install 'ms-dotnettools.csharp' extension because it is not compatible with the current version of Visual Studio Code (version 1.67.2)"
I suggest to downgrade it to version 1.23.16 and restart vscode.
Your Intellisense should start working.
My Environment
dotnet v3.1.417
VSCode v1.67.2
C# Extension v1.25.0 (now downgraded to v1.23.16)
Running in Remote Container on a Mac host.
Yes I am using 3+ year old dotnet version. It's a legacy software, it happens, everyone has skeletons in their systems ;)
Trust me it'll work, tried everything and then came to this
Go into VS code Preferences
Search for omnisharp.path and click on edit in settings.json
Add/edit line "omnisharp.path": "latest" (remember to add a comma at the end of the previous line)
Go back into settings and search omnisharp, scroll down till you find Use Global Mono, change that to Always
After this you will have to download Mono, mac's mono download link is this https://www.mono-project.com/download/stable/#download-mac
After the download finishes, set it up by opening the download file
Go back to settings.json and add mono's /bin path as "omnisharp.monoPath": "/Library/Frameworks/Mono.framework/Versions/6.12.0/bin" which is the default download path for mac, if you wanna confirm this, go into mac's disk space and then follow the above mentioned path)
Finally restart VS Code and it should work (in case it still doesn't, restart it again)
I downgraded the VS Code's C# extension to 1.24.3 from 1.25.0 and it worked.
I had the same Problem after fetching Unity from a git repository.
For me it worked to reset the .Net Version in Unity.
Edit -> Project Settings -> Api Compatibility Level
Switched that back and forth, restarted VSCode. The .csproj-file will file out all the missing dlls.
I solved this by uninstalling all SDK's and installed the older 4.7.1, then everything worked instantly.
I had the same problem. Here's how I fixed it:
I added all projects to the solution file (dotnet sln add <project name>) and opened the project in vs code by passing the path to vscode from terminal
(code <project path>).
The error says that OmniSharp is looking for Version=v4.7.1. You may want to install the latest version of it.
Related
I started to learn C# and .net and just installed Microsoft VS 2022 and also installed .net 6.0. I was trying to run the first code and it came up the error as follows. I did some research but can't figure out what's wrong. I noticed there is a similar question on StackOverflow before I tried the answers but didn't work. Can anyone help please?
The error message: The debug executable
'C:\user\owener\source\repos\ConsoleApp2\ConsoleApp2\bin\Debug\net6.0\ConsoleApp2.exe'specified in the 'ConsoleApp2' debug profile does not exist.
Output showing error message:error NETSDK1004: Assets file 'C:\user\owener\source\repos\ConsoleApp2\ConsoleApp2\obj\project.assets.json'not found. Run a NuGet package restore to generate this file.
Select Tools->NuGet Package Manager -> Package Manager Console and type
dotnet restore
or you can first go in settings and search for Nuget->General and Clear the Caches
It is all fixed now. debug, Nuget, PowerShell are all working. I just uninstalled VS 2022 and reinstalled VS 2019 and ticked all extra optional when choosing .Net desktop development. I guess I'm missing some software in my computer system.
I have found many questions about this but non have helped me. I am trying to write c# code and the omnisharp auto complete doesn't work and I get this back from the Omnisharp Log:
OmniSharp server started.
Path: c:\Users\GeorgV.216\.vscode\extensions\ms-dotnettools.csharp-1.24.1\.omnisharp\1.38.3-beta.31\OmniSharp.exe
PID: 11536
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Windows 6.2.9200.0 (x64)
[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 0 MSBuild instance(s)
Could not locate MSBuild instance to register with OmniSharp.
What could be a possible solution?
As of May 2022, Omnisharp does not include MSBuild.
It can be installed with Build Tools for Visual Studio, found at the bottom of this page.
During install select .NET desktop build tools:
More info in this issue.
The solution that worked for me was to change the "omnisharp.path": from "latest" to "" in the setting.json file and delete the 1.38.3-beta.31 folder in C:\Users{username}.vscode\extensions\ms-dotnettools.csharp-1.24.1.omnisharp
If you're using VSCode, a simple fix is to install an older C# extension version.
Extensions -> arrow next to uninstall -> install another version -> v1.24.1
It's a temporary fix as you're stuck with an old version of C# extension but it's a quick and simple one.
Suddenly got this problem too, adding "omnisharp.useModernNet": true to the settings.json fixed it for me.
Working for me now. Maybe the cause is (from omnisharp github):
"Planned removal of the included Mono & MSBuild Tools
In the future .NET Framework builds of OmniSharp will not ship with Mono or the MSBuild tooling (See announcement omnisharp-roslyn#2339). To ensure that the C# extension remains usable out of the box for .NET SDK projects, we will be changing the default value of omnisharp.useModernNet to true."
But " omnisharp.useModernNet to true" does not work with Unity 3d.
So.
I uninstall all dotnets from ubuntu.
Unistall mono.
Reinstall dotnet using this: https://learn.microsoft.com/es-es/dotnet/core/install/linux-ubuntu#2110-
Reinstall mono-complete using synaptics.
And in VS settings set omnisharp using global mono to "always".
Now it's working for me.
The solution that worked for me:
Manage
Settings
search for "omnisharp path"
edit in settings.json
enter code here> replace "latest" with ""
For me runs with
"omnisharp.enableEditorConfigSupport": true,
"omnisharp.path": "latest",
"omnisharp.projectLoadTimeout": 60,
"omnisharp.useGlobalMono": "always",
"omnisharp.useModernNet": true,
on settings.json file....
Omnisharp has been updated to .NET 6.0. The older .NET Framework builds will no longer ship with MSBuild tools (and you don't already have them installed) so that's the reason for your error.
Remove the msbuild error by setting the following in VSCode settings.json:
"omnisharp.path": ""
Upgrade to the newer .NET 6.0 builds of OmniSharp by setting the following:
"omnisharp.useModernNet": true
Quick Solution for every platform (Windows, Linux, Mac)
Set VS Code update mode to 'manual'
Disable Windows Background Updates
Downgrade the VS Code version to February 2022 (version 1.65)
Downgrade the C# extension version to v1.24.4
everything will be fine 💯
#5253 (comment)
Faced with same problem after upgrade to .net 6. In vs code problems with onmnisharp, intelisense and getting this error as well.
Make sure to install mono latest version.
Make sure to install .net 6.0.401 sdk.
If upgrade from .net 5 to .net 6 I suggest to uninstall first .net 5.
Uninstall C# extension from vs code.
Delete "ms-dotnettools.csharp-1.25.0-darwin-arm64" folder from
/Users//.vscode/extensions/ms-dotnettools.csharp-1.25.0-darwin-arm64
Install C# extension (1.25.0).
Restart Vs code and got to Code>Preferences>Settings
Search for "omnisharp"
Set Logging Level to: trace
Update Dotnet Path (on mac m1): "/usr/local/share/dotnet/dotnet"
Update Mono path: (mac m1): "/Library/Frameworks/Mono.framework/Versions/Current"
Update Sdk Path: "/usr/local/share/dotnet/sdk/6.0.401/"
Update Sdk Version: "6.0.401"
Set User Modern Net: true,
Restart vs code -> check output console.
If you get an error "The .NET Core SDK cannot be located. .NET Core debugging will not be enabled. Make sure the .NET Core SDK is installed and is on the path" continue line 14.
Open "/Users/user/.vscode/extensions/ms-dotnettools.csharp-1.25.0-darwin-arm64/dist/extension.js" this file, and search for this statement:
"args.push(Sdk:Path='${options.sdkPath}');" than remove quotes around curly braces => args.push(Sdk:Path=${options.sdkPath});.
Save all changes and restart vs code. => Now everything should be ok.
Seems that this VsCode extension add quotes, and cause of this its not able to find "sdkPath" specified in the configuration.
This worked for me.
Hope will help someone.
Try installing the older version of C# extension works for me. I downgraded to v1.24.4 and changing one of the line in the setting.json to "omnisharp.useGlobalMono": "always"
I have also noticed that you have to close VS Code completely and reopen to have it working.
I spent at least an hour or two troubleshooting this issue and it seems there are several solutions which work for some but not for others. If you are like me and couldn't find a working solution, this is how I finally got it to work.
I disabled all of my other extensions in VS Code aside from 'C# for VS code' and 'Unity Code Snippets'. I'm not sure which one was the culprit, but I had been using VS Code mainly for JavaScript and I assume the code formatter or live server extensions were interfering somehow with how the .cs was being interpreted. All of a sudden after disabling those, and reloading, it worked. Finally.
If you're using VS Code, a temporary fix is to install an older C# extension version.
Extensions -> install another version -> v1.24.1
it will help as it helped for me.
Here is text from release note for Omnisharp v1.25.0: "Announcement: The C# extension no longer ships with an included Mono & MSBuild Tools". I have installed .Net 6.0 and omnisharp v1.25.0 was able to locate MSBuild from there.
The older version of Omnisharp has MSBuild available within their extension install folder C:\Users\Username.vscode\extensions\ms-dotnettools.csharp-XX.XX.XX....omnisharp\X.XX.XX\msbuild
I just upgraded my visual studio 2019 to latest version 16.8.3 and suddenly I am not able to load any C# project and getting the following error for all .NET core projects:
The project file cannot be opened. Unable to locate the .NET SDK.
Check that it is installed and that the version specified in
global.json (if any) matches the installed version.
Try to edit envrionment Variables.
Right click on This PC -> Properties -> Advanced System Settings -> Advanced -> Environment Variables -> System Variables
Add [install path] C:\Program Files\dotnet\ to the variable path.
Restart visual studio.
If it does not solve this problem, you can refer to this answer.
I found that the path C:\Program Files\dotnet was already in my path but it was ordered below the C:\Program Files (x86)\dotnet entry. By simply moving C:\Program Files\dotnet above C:\Program Files (x86)\dotnet in the list and restarting Visual Studio cleared up the problem.
If there is a global.json file in your solution folder(where *.sln file reside), delete this.
In my case, I had .NET 6 preview but then uninstalled it. After uninstalling, some of my projects won't load. I have all the configurations mentioned above but still won't load the projects. I went to C:\Program Files\dotnet\sdk\ where I found that there still exist a .NET 6 folder which is empty. Deleting that empty .NET 6 folder fixes the issue and I was able to load my projects.
This works for me...
Check first if which .net Core SDK is available in the system.
Step 1: Open Command prompt (CMD) and type dotnet --info
The above image shows no SDK is installed or register
Step 2: Install SDK from https://dotnet.microsoft.com/download/dotnet-core
Done Visual studio works like charm... Verify if its properly installed and register
Above image you can see .net core SDK is registered properly on the system.
I had a similar situation upgrading from VS 2019 to VS 2022, trying to run a dotnet 5.0 solution from VS 2022 (that starts to use dotnet 6.0).
In the PATH env. variable I had both 'C:\Program Files\dotnet' and 'C:\Program Files (x86)\dotnet'. I removed the (x86) one and stopped having that error
Installing missed SDK that the project has built solved the problem
I had a similar issue when I tried to build a net5.0 solution that is not installed on my machine.
In my case, I had VS 2022, and net6.0 installed.
Installing net5.0 SDK solved the problem.
I had only C:\Program Files\dotnet in Path env
I just carefully followed the error message and tried to resolve the problem.
I got below error message:
F:\mypath\ServerlessFunc\ServerlessFunc\ServerlessFunc.csproj : error
: The project file cannot be opened. C:\Program
Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\Sdk not found. Check
that a recent enough .NET SDK is installed and/or increase the version
specified in global.json.
I then tried to navigate through
C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\Sdk
path which was mentioned in the above error and found that the above path does not exist. This problem could be resolved if I install SDK of version of 6.0. Rather I started using VS-2022.
I just upgraded my visual studio 2019 to latest version 16.8.3 and suddenly I am not able to load any C# project and getting the following error for all .NET core projects:
The project file cannot be opened. Unable to locate the .NET SDK.
Check that it is installed and that the version specified in
global.json (if any) matches the installed version.
Try to edit envrionment Variables.
Right click on This PC -> Properties -> Advanced System Settings -> Advanced -> Environment Variables -> System Variables
Add [install path] C:\Program Files\dotnet\ to the variable path.
Restart visual studio.
If it does not solve this problem, you can refer to this answer.
I found that the path C:\Program Files\dotnet was already in my path but it was ordered below the C:\Program Files (x86)\dotnet entry. By simply moving C:\Program Files\dotnet above C:\Program Files (x86)\dotnet in the list and restarting Visual Studio cleared up the problem.
If there is a global.json file in your solution folder(where *.sln file reside), delete this.
In my case, I had .NET 6 preview but then uninstalled it. After uninstalling, some of my projects won't load. I have all the configurations mentioned above but still won't load the projects. I went to C:\Program Files\dotnet\sdk\ where I found that there still exist a .NET 6 folder which is empty. Deleting that empty .NET 6 folder fixes the issue and I was able to load my projects.
This works for me...
Check first if which .net Core SDK is available in the system.
Step 1: Open Command prompt (CMD) and type dotnet --info
The above image shows no SDK is installed or register
Step 2: Install SDK from https://dotnet.microsoft.com/download/dotnet-core
Done Visual studio works like charm... Verify if its properly installed and register
Above image you can see .net core SDK is registered properly on the system.
I had a similar situation upgrading from VS 2019 to VS 2022, trying to run a dotnet 5.0 solution from VS 2022 (that starts to use dotnet 6.0).
In the PATH env. variable I had both 'C:\Program Files\dotnet' and 'C:\Program Files (x86)\dotnet'. I removed the (x86) one and stopped having that error
Installing missed SDK that the project has built solved the problem
I had a similar issue when I tried to build a net5.0 solution that is not installed on my machine.
In my case, I had VS 2022, and net6.0 installed.
Installing net5.0 SDK solved the problem.
I had only C:\Program Files\dotnet in Path env
I just carefully followed the error message and tried to resolve the problem.
I got below error message:
F:\mypath\ServerlessFunc\ServerlessFunc\ServerlessFunc.csproj : error
: The project file cannot be opened. C:\Program
Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\Sdk not found. Check
that a recent enough .NET SDK is installed and/or increase the version
specified in global.json.
I then tried to navigate through
C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\Sdk
path which was mentioned in the above error and found that the above path does not exist. This problem could be resolved if I install SDK of version of 6.0. Rather I started using VS-2022.
When I'm trying to update or configure service reference in .NET 4.6.1 project, VS throws next error:
Could not resolve mscorlib for target framework '.NETFramework,Version=v4.6.1'. This can happen if the target framework is not installed or if the framework moniker is incorrectly formatted.
Path lenght is OK, I'd also checked another answers on SO and nothing works.
Maybe someone has something like that?
I get the same error on VS2019.
This error occurred because I never restored nuget packages and built the solution.
After a restore of nuget packages and a full rebuild of the solution the error disappeared!
It is hard to confirm, but I believe my issue had to do with exceeding a TFS limit of 259 characters in the path. In short, when getting latest from TFS, I think some files were not downloading to my local machine due to their path exceeding 259 characters.
After renaming the working directory to a shorter path, I was able to configure existing and new service references. Here's one link discussing the limitation: TFS Path Too Long Problems
I had the same issue with VS 16.10.0 Preview 1.0 for 4.8
To fit it I did first clean project, then retargeted from 4.8 to 4.7.2 and back and then it worked.
In my case going into the project folders and manually deleting contents of:
/bin
/obj of each project in the solution. And then contents of
/packages in solution folder
then reopening solution and rebuilding + restoring the nuget packages worked.
You should refresh the target framework in the Application properties of the project
In my situation; I was rebuilding a projected I had worked on using Visual Studio 2010. To resolve this error, I downloaded the .NET Framework 4.8 Developer Pack via this site https://dotnet.microsoft.com/en-us/download/visual-studio-sdks?cid=getdotnetsdk
I restarted my IDE and everything was fine.