Open nightblade9 opened 5 years ago
I've run into this issue with Manjaro Linux fully updated (Arch based). I've MonoDevelop installed, working fine with Mono. I wanted to try dotnet core, so I downloaded & installed & created the expected symbols in .bashrc. These are the last two lines.
export DOTNET_ROOT=$HOME/bin/dotnet
export PATH=$PATH:$HOME/bin/dotnet
...which seem to work fine:
$ echo $DOTNET_ROOT
/home/baltasarq/bin/dotnet
$ echo $PATH
/home/baltasarq/bin/google-cloud-sdk/bin:/home/baltasarq/.local/bin:/home/baltasarq/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/home/baltasarq/.local/share/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/baltasarq/.local/share/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/baltasarq/bin/node/bin:/home/baltasarq/bin/dotnet:/home/baltasarq/bin/node/bin:/home/baltasarq/bin/dotnet
$ dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.0.100
Commit: 04339c3a26
Runtime Environment:
OS Name: manjaro
OS Version:
OS Platform: Linux
RID: linux-x64
Base Path: /home/baltasarq/bin/dotnet/sdk/3.0.100/
Host (useful for support):
Version: 3.0.0
Commit: 7d57652f33
.NET Core SDKs installed:
3.0.100 [/home/baltasarq/bin/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.0.0 [/home/baltasarq/bin/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.0.0 [/home/baltasarq/bin/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
I can create a hello world dotnet application with:
$ dotnet new console --name HelloApp
$ cd HelloApp
$ dotnet run
Hello World!
Since I wanted to try Visual Studio Code and .NET Core, I installed Visual Studio Code:
$ yay -S visual-studio-code-bin
... which worked flawlessly.
The problem is when I try to open the folder of the app HelloApp created before, then OmniSharp steps in and fails.
OmniSharp server started with Mono 6.0.0.
Path: /home/baltasarq/.vscode/extensions/ms-vscode.csharp-1.21.3/.omnisharp/1.34.3/omnisharp/OmniSharp.exe
PID: 26562
[warn]: OmniSharp.MSBuild.Discovery.Providers.MonoInstanceProvider
It looks like you have Mono 5.2.0 or greater installed but MSBuild could not be found.
Try installing MSBuild into Mono (e.g. 'sudo apt-get install msbuild') to enable better MSBuild support.
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: StandAlone 16.0 - "/home/baltasarq/.vscode/extensions/ms-vscode.csharp-1.21.3/.omnisharp/1.34.3/omnisharp/.msbuild/Current/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: StandAlone 16.0 - "/home/baltasarq/.vscode/extensions/ms-vscode.csharp-1.21.3/.omnisharp/1.34.3/omnisharp/.msbuild/Current/Bin"
CscToolExe = csc.exe
TargetFrameworkRootPath = /usr/lib/mono/xbuild-frameworks
MSBuildToolsPath = /home/baltasarq/.vscode/extensions/ms-vscode.csharp-1.21.3/.omnisharp/1.34.3/omnisharp/.msbuild/Current/Bin
CscToolPath = /home/baltasarq/.vscode/extensions/ms-vscode.csharp-1.21.3/.omnisharp/1.34.3/omnisharp/.msbuild/Current/Bin/Roslyn
BypassFrameworkInstallChecks = true
MSBuildExtensionsPath = /usr/lib/mono/xbuild
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk' specified could not be found. /home/baltasarq/tmp/HelloApp/HelloApp.csproj
[fail]: OmniSharp.MSBuild.ProjectManager
Attempted to update project that is not loaded: /home/baltasarq/tmp/HelloApp/HelloApp.csproj
I've looked for a solution in the form of a framework selector or "PATH to dotnet" or similar configuration, unfortunately to no avail. Since OmniSharp's output suggest to install msbuild for Linux, I also tried that, uninstalled the extension and installed it back again. Unofrtunately, that did not solve anything.
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk' specified could not be found. /home/nightblade/code/ali-the-android/AliTheAndroid/AliTheAndroid.csproj
PLS ADD THE FILE:
omnisharp.json :
{ "MSBuild": { "UseLegacySdkResolver": true } }
https://github.com/OmniSharp/omnisharp-vscode/issues/3287#issuecomment-536180721
PLS ADD THE FILE:
omnisharp.json :
Whoa, this actually worked for me. Thanks for the suggestion!
Just to be clear: I add this file to all my .NET Core projects, because by default, VSCode will find my Mono SDK, correct? (Or, another way to say this: don't add it for Mono projects.)
Okay, it seems it is not clear that I'm a newbie with Visual Studio Code. Where do I have to put that file?
@Baltasarq I just created a new file in the root of my project (the folder that you pick in VSCode when you pick "Open Folder" - in my case, it's the project root, and the one with a .git
subdirectory).
Well, that was what I tried for starters, anyway. I am afraid it does not work for me:
[~/tmp/HelloApp] $ ls
bin HelloApp.csproj obj omnisharp.json Program.cs
[~/tmp/HelloApp] $ cat omnisharp.json
{
"MSBuild": {
"UseLegacySdkResolver": true
}
}
My "project" is so simple that it only has one folder. The one I obtained by calling dotnet new console --name HelloApp
, which is the very same folder that I opened with Visual Studio Code.
No luck.
@Baltasarq this might be a long shot, but can you clone this repo, open the root folder, and tell me if it works for you or not? I tried it on two installs (one with Mono, one without) and Omnisharp loads fine on both.
Thanks nightblade9! Yep, I cloned your repo, but unfortunately the problem still exists, nothing new.
@Baltasarq it might be something environmental in your case. By comparing your logs to mine, I can see that my logs report this:
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
MSBUILD_EXE_PATH environment variable set to '/home/nightblade/.vscode/extensions/ms-vscode.csharp-1.21.3/.omnisharp/1.34.3/omnisharp/.msbuild/Current/Bin/MSBuild.dll'
You may want to try setting that environment variable to see if that fixes the problem.
Yep, I have a similar line in O#'s output.
Can you upgrade to 1.21.4 and see if that helps?
I'm afraid nothing changed.
VSCode reports:
Version: 1.38.1
Commit: b37e54c98e1a74ba89e03073e5a3761284e3ffb0
Date: 2019-09-11T13:30:08.229Z
Electron: 4.2.10
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Linux x64 4.19.69-1-MANJARO
Omnisharp reports:
Name: C#
Id: ms-vscode.csharp
Description: C# for Visual Studio Code (powered by OmniSharp).
Version: 1.21.4
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp
Again, the project compiles and run with "dotnet run", even from the terminal embedded inside Visual Studio Code.
[~/tmp/HelloApp] $ cat Program.cs
using System;
namespace HelloApp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
[~/tmp/HelloApp] $ dotnet run
Hello World!
Okay, this is new.
Just to remember the project's configuration of this (default) console app.
[~/tmp/HelloApp] $ cat HelloApp.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
</Project>
I browsed Omnisharp's configuration and found a combo box for when to use mono or not. Set it to "never", hoping that it would make Omnisharp use only the dotnet installation. Unfortunately, this did not work out as expected. Also, it would be great to be able to make it work with mono.
Omnisharp started with promising results:
Starting OmniSharp server at 10/8/2019, 9:30:15 AM
Target: /home/baltasarq/tmp/HelloApp
OmniSharp server started.
Path: /home/baltasarq/.vscode/extensions/ms-vscode.csharp-1.21.4/.omnisharp/1.34.4/run
PID: 18058
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on manjaro 0.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: StandAlone 16.0 - "/home/baltasarq/.vscode/extensions/ms-vscode.csharp-1.21.4/.omnisharp/1.34.4/omnisharp/.msbuild/Current/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
MSBUILD_EXE_PATH environment variable set to '/home/baltasarq/.vscode/extensions/ms-vscode.csharp-1.21.4/.omnisharp/1.34.4/omnisharp/.msbuild/Current/Bin/MSBuild.dll'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: StandAlone 16.0 - "/home/baltasarq/.vscode/extensions/ms-vscode.csharp-1.21.4/.omnisharp/1.34.4/omnisharp/.msbuild/Current/Bin"
MSBuildExtensionsPath = /usr/lib/mono/xbuild
BypassFrameworkInstallChecks = true
CscToolPath = /home/baltasarq/.vscode/extensions/ms-vscode.csharp-1.21.4/.omnisharp/1.34.4/omnisharp/.msbuild/Current/Bin/Roslyn
CscToolExe = csc.exe
MSBuildToolsPath = /home/baltasarq/.vscode/extensions/ms-vscode.csharp-1.21.4/.omnisharp/1.34.4/omnisharp/.msbuild/Current/Bin
TargetFrameworkRootPath = /usr/lib/mono/xbuild-frameworks
So, it apparently uses an existing MSBuild inside Omnisharp (instead of the one in the dotnet installation), and then goes back to mono and its xbuild
in order to find extensions and frameworks...
After some more initializations, the first warning appears, and then fails immediately:
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file '/home/baltasarq/tmp/HelloApp/HelloApp.csproj'.
/home/baltasarq/tmp/HelloApp/HelloApp.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project "/usr/lib/mono/xbuild/15.0/Microsoft.Common.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. /home/baltasarq/bin/dotnet/sdk/3.0.100/Sdks/Microsoft.NET.Sdk/Sdk/Sdk.props
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject (System.String errorSubCategoryResourceName, Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, System.Object[] args) [0x00040] in <b695b16788dd418cbe8b4d98f7a92ff3>:0
at Microsoft.Build.Shared.ProjectErrorUtilities.VerifyThrowInvalidProject[T1] (System.Boolean condition, System.String errorSubCategoryResourceName, Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, T1 arg0) [0x00003] in <b695b16788dd418cbe8b4d98f7a92ff3>:0
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject[T1] (Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, T1 arg0) [0x00000] in <b695b16788dd418cbe8b4d98f7a92ff3>:0
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].ExpandAndLoadImportsFromUnescapedImportExpression (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement, System.String unescapedExpression, System.Boolean throwOnFileNotExistsError, System.Collections.Generic.List`1[Microsoft.Build.Construction.ProjectRootElement]& imports) [0x0060f] in <b695b16788dd418cbe8b4d98f7a92ff3>:0
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].ExpandAndLoadImportsFromUnescapedImportExpressionConditioned (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement, System.Collections.Generic.List`1[Microsoft.Build.Construction.ProjectRootElement]& projects, Microsoft.Build.BackEnd.SdkResolution.SdkResult& sdkResult, System.Boolean throwOnFileNotExistsError) [0x00268] in <b695b16788dd418cbe8b4d98f7a92ff3>:0
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].ExpandAndLoadImports (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement, Microsoft.Build.BackEnd.SdkResolution.SdkResult& sdkResult) [0x00027] in <b695b16788dd418cbe8b4d98f7a92ff3>:0
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].EvaluateImportElement (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x0000d] in <b695b16788dd418cbe8b4d98f7a92ff3>:0
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].PerformDepthFirstPass (Microsoft.Build.Construction.ProjectRootElement currentProjectOrImport) [0x00209] in <b695b16788dd418cbe8b4d98f7a92ff3>:0
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].EvaluateImportElement (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x00040] in <b695b16788dd418cbe8b4d98f7a92ff3>:0
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].PerformDepthFirstPass (Microsoft.Build.Construction.ProjectRootElement currentProjectOrImport) [0x000e6] in <b695b16788dd418cbe8b4d98f7a92ff3>:0
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].Evaluate (Microsoft.Build.BackEnd.Logging.ILoggingService loggingService, Microsoft.Build.Framework.BuildEventContext buildEventContext) [0x0011c] in <b695b16788dd418cbe8b4d98f7a92ff3>:0
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].Evaluate (Microsoft.Build.Evaluation.IEvaluatorData`4[P,I,M,D] data, Microsoft.Build.Construction.ProjectRootElement root, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, System.Int32 maxNodeCount, Microsoft.Build.Collections.PropertyDictionary`1[T] environmentProperties, Microsoft.Build.BackEnd.Logging.ILoggingService loggingService, Microsoft.Build.Evaluation.IItemFactory`2[S,T] itemFactory, Microsoft.Build.Evaluation.IToolsetProvider toolsetProvider, Microsoft.Build.Evaluation.ProjectRootElementCache projectRootElementCache, Microsoft.Build.Framework.BuildEventContext buildEventContext, Microsoft.Build.BackEnd.SdkResolution.ISdkResolverService sdkResolverService, System.Int32 submissionId, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext, System.Boolean interactive) [0x0002f] in <b695b16788dd418cbe8b4d98f7a92ff3>:0
at Microsoft.Build.Evaluation.Project.Reevaluate (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x0005e] in <b695b16788dd418cbe8b4d98f7a92ff3>:0
at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00035] in <b695b16788dd418cbe8b4d98f7a92ff3>:0
at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00000] in <b695b16788dd418cbe8b4d98f7a92ff3>:0
at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00007] in <b695b16788dd418cbe8b4d98f7a92ff3>:0
at Microsoft.Build.Evaluation.Project.Initialize (System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion, System.String subToolsetVersion, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00126] in <b695b16788dd418cbe8b4d98f7a92ff3>:0
at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion, System.String subToolsetVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00093] in <b695b16788dd418cbe8b4d98f7a92ff3>:0
at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion, System.String subToolsetVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x00000] in <b695b16788dd418cbe8b4d98f7a92ff3>:0
at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x00000] in <b695b16788dd418cbe8b4d98f7a92ff3>:0
at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection) [0x00000] in <b695b16788dd418cbe8b4d98f7a92ff3>:0
at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion) [0x000f7] in <b695b16788dd418cbe8b4d98f7a92ff3>:0
at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.String toolsVersion) [0x00000] in <b695b16788dd418cbe8b4d98f7a92ff3>:0
at OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore (System.String filePath) [0x0003f] in <4d39b1cf1ca84cccbd4059b400c1cde5>:0
at OmniSharp.MSBuild.ProjectLoader.BuildProject (System.String filePath) [0x0000d] in <4d39b1cf1ca84cccbd4059b400c1cde5>:0
at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load (System.String filePath, OmniSharp.MSBuild.ProjectIdInfo projectIdInfo, OmniSharp.MSBuild.ProjectLoader loader) [0x00015] in <4d39b1cf1ca84cccbd4059b400c1cde5>:0
at OmniSharp.MSBuild.ProjectManager+<>c__DisplayClass29_0.<LoadProject>b__0 () [0x00000] in <4d39b1cf1ca84cccbd4059b400c1cde5>:0
at (wrapper delegate-invoke) System.Func`1[System.ValueTuple`3[OmniSharp.MSBuild.ProjectFile.ProjectFileInfo,System.Collections.Immutable.ImmutableArray`1[OmniSharp.MSBuild.Logging.MSBuildDiagnostic],OmniSharp.MSBuild.Notification.ProjectLoadedEventArgs]].invoke_TResult()
at OmniSharp.MSBuild.ProjectManager.LoadOrReloadProject (System.String projectFilePath, System.Func`1[TResult] loader) [0x0001b] in <4d39b1cf1ca84cccbd4059b400c1cde5>:0
[fail]: OmniSharp.MSBuild.ProjectManager
Attempted to update project that is not loaded: /home/baltasarq/tmp/HelloApp/HelloApp.csproj
I've found a fix but the Props file need to be updated manually so make sure to do a backup before.
For the following error: Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project "/usr/lib/mono/xbuild/15.0/Microsoft.Common.props" was not found. Confirm that the path in the
2, Edit the props file from your output and at the following line:
Hope it helps.
I'm running into the common
The SDK 'Microsoft.NET.Sdk' specified could not be found
error on Arch Linux (Manjaro) - the same error apparently as #3287, #3160, #2356, #2937, and others.I suspect my case is different. I worked on a .NET Core game for a while, then installed
godot-mono
, which includes Mono; when I came back to .NET Core, I get this error.I suspect that VS Code finds the Mono runtime/SDK first, and then says "whelp there's no .NET Core SDK installed for that" and fails hard. I hesitate to uninstall Godot and verify that this works, because I really do need both working side-by-side.
Is this an impossible/unsupported configuration?
OmniSharp log
Environment information
VSCode version: 1.38.1 C# Extension: 1.21.3
Mono Information
OmniSharp using global mono :6.0.0Dotnet Information
.NET Core SDK (reflecting any global.json): Version: 2.2.108 Commit: 33ed5b90ce Runtime Environment: OS Name: manjaro OS Version: OS Platform: Linux RID: arch-x64 Base Path: /opt/dotnet/sdk/2.2.108/ Host (useful for support): Version: 2.2.6 Commit: 7dac9b1b51 .NET Core SDKs installed: 2.2.108 [/opt/dotnet/sdk] .NET Core runtimes installed: Microsoft.NETCore.App 2.2.6 [/opt/dotnet/shared/Microsoft.NETCore.App] To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-downloadVisual Studio Code Extensions
|Extension|Author|Version| |---|---|---| |csharp|ms-vscode|1.21.3| |godot-tools|geequlim|0.3.7| |mono-debug|ms-vscode|0.15.8| |python|ms-python|2019.9.34911| |vscode-nxunit-test-adapter|wghats|0.1.2| |vscode-test-explorer|hbenl|2.14.6|;