Lost intellisense and squiggles - visual-studio-code

For some reason, all my new projects created using dotnet no longer have intellisense or squiggles. However, if I open an old project, those still have intellisense and squiggles.
How do I get intellisense and squiggles in my new projects?
Using C# in VSC on Linux (Ubuntu 20.04).
VERSIONS
Visual Studio Code 1.60.0
C# for Cisual Studio Code (powered by OmniSharp) 1.23.15
dotnet --list-sdks
5.0.400 [/usr/share/dotnet/sdk]
dotnet --list-runtimes
Microsoft.AspNetCore.App 5.0.9 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 5.0.9 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
COMMAND USED
dotnet new console -o project_name

Related

Omnisharp error about dotnet version - Unity

at VSCode launch today I'm receiving this error:
Starting OmniSharp server at 27/5/2022, 12:37:25
Target: f:\UnityProjects\MyGame.sln
[ERROR] Error: Found dotnet version 5.0.407. Minimum required version is 6.0.100.
I read that there have been updates in omnisharp but I really don't know how to fix the issue.
I've installed dotnet 6.0 TLS through a new visual studio installation... is there anything else I can do to bring dotnet working with my Unity project?
If you're using C# extension 1.25.0 they announced a change in the extension's details page:
.NET Framework builds of OmniSharp no longer 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 have changed the default value of omnisharp.useModernNet
to true.
If you still need Unity or .NET Framework support, you can set
omnisharp.useModernNet to false in your VS Code settings and restart
OmniSharp.
Changing that omnisharp.useModernNet setting to false worked for me.
If you use vscode for web development and your installed dotnet SDK version is < 6, this answer might be useful.
After quite some time I spotted an Ominisharp Log warning this.
[ERROR] Error: Found dotnet version 3.1.419. Minimum required version is 6.0.100.
Solution
Install dotnet SDK 6 alongside or by replacing your current version.
I recommend you install it by using the dotnet-install.{sh | ps1} script.
By running the command below it will install the latest version alongside your current one.
sudo ./dotnet-install.sh -c 6.0 --install-dir /usr/share/dotnet
~ ยป dotnet --list-sdks
3.1.419 [/usr/share/dotnet/sdk]
6.0.300 [/usr/share/dotnet/sdk]

Nuget package is not compatible, but in the supported-list (StrawberryShake.Tools)

I got this message after creating a new .NET 5-project (in VS2019) and trying to install nuget-package StrawberryShake.Tools. This seems a bit strange, since it says both that it is and it isnt compatible with "net5.0 (.NETCoreApp,Version=v5.0)"
Error NU1202 Package StrawberryShake.Tools 12.6.0 is not compatible
with net5.0 (.NETCoreApp,Version=v5.0). Package StrawberryShake.Tools
12.6.0 supports:
net5.0 (.NETCoreApp,Version=v5.0) / any
net6.0 (.NETCoreApp,Version=v6.0) / any
netcoreapp3.1 (.NETCoreApp,Version=v3.1) / any
I had the same problem, so I followed the official installation guide instead. The steps are as follows:
Open a terminal and navigate to e.g. the project where you want the package to be installed.
Run dotnet new tool-manifest.
Run dotnet tool install StrawberryShake.Tools --local. The nuget package has now been installed in ~/.nuget/packages and may be used in the project.

How to Enable Intellisense in VS Code + Ionide?

I've created an F# (script) app via the dotnet cli using the following outlined steps. However, when I open the app/project in VS Code with Ionide, intellisense is inactive. How can I resolve this?
To create the app/project, I:
Created an app directory
Ran dotnet new tool-manifest and dotnet tool install paket and dotnet paket restore
Ran dotnet paket init
Modified paket.dependencies
Opened "project" in VS Code with Ionide
paket.dependencies (Note: I removed framework restrictions)
source https://api.nuget.org/v3/index.json
storage: packages
nuget FSharp.Data
Script:
#r "./packages/FSharp.Core/lib/netstandard2.0/FSharp.Core.dll"
#r "./packages/FSharp.Data/lib/netstandard2.0/FSharp.Data.dll"
open System
open FSharp.Data
type research = CsvProvider<"./path/to/file", HasHeaders=true, PreferOptionals=true>
let data = research.GetSample()

Cordova app for Windows, NuGet fails to get correct version of System.Collections.Specialized

I'm tearing my hair out trying to build a windows app using Cordova. The build error I'm getting is:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\
MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(377, 5):
error : The package System.Collections.Specialized with version 4.0.0
could not be found in C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\.
Run a NuGet package restore to download the package.
[C:\cygwin64\home\Owner\src\apps\mytestapp-
gen\platforms\windows\CordovaApp.Windows10.jsproj]
In visual studio, I attempt to add the version of the package to the project and I get the following error:
Severity Code Description Project File Line Suppression State
Error Could not install package 'System.Collections.Specialized
4.0.0'. You are trying to install this package into a project that targets
'native,Version=v0.0', but the package does not contain any assembly
references or content files that are compatible with that framework. For
more information, contact the package author.
Can anyone advise how to resolve this?
I've looked at this very old question How can I make my managed NuGet package support C++/CLI projects? but I can't find anything (particually from the VS2017 era) that helps
May be, this helps others to solve the issue:
My Visual Studio 2017 installation must obviously have been damaged when removing the Visual Studio 2015 installation from that same machine. After I performed a repair of Visual Studio 2017 via Visual Studio Installer the isuue disappeared.

Dotnet restore not working

dotnet Version: 1.1.0 (global.json)
NuGet Version : 4.4.1.4656
VS2017 v15.5.2 (as Administrator)
.NET Core 1.1
The solution I am trying to build
Update I:
I just changed the project to run under target framework .NET Core v2.0 & sdk version 2.1.3 and I only get these kind of errors:
Severity Code Description Project File Line Suppression State
Error NU1202 Package Microsoft.Extensions.FileProviders.Physical 1.1.0
is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0).
Package Microsoft.Extensions.FileProviders.Physical 1.1.0 does not
support any target
frameworks. AspNetCoreExample C:\Users\Admin\Source\Repos\Examples\src\AspNetCoreExample\AspNetCoreExample.csproj 1
Update II:
While the following solves the current issue, i am not sure if it solves the root cause for this issue.
Delete the global nuget.config file %AppData%/Nuget/Nuget.config.
I fixed this issue by doing the following:
I migrated the project to .net core 2.0 and changed the global.json to point to sdk 2.1.3.
Removed all references in AspNetCoreExample manually and added the latest version for all of them.
Issues with target framework 1.1
When doing a restore from the solution in VS 2017:
When doing the restore from cmd (dotnet restore)
Running dotnet restore in Package Manager Console
NuGet.targets(103,5): error : Access to the path 'System.Runtime.dll'
is denied
.NET Core SDKs installed:
.NET Host
Now when opening the solution I get:
Comparing the log entries you pasted to their AppVeyor build,
https://ci.appveyor.com/project/Autofac/examples
Your machine's NuGet configuration seems to be broken. Analyze that and fix the issues.
You should add this code to your .csproj file
<RuntimeFramework>2.0.3</RuntimeFramework>
This worked for me.