Open akshita31 opened 5 years ago
@akshita31 I have the same issue on macOS. And I believe that's because there is no proper MSBuildInstanceProvider implementation that will find msbuild to use on macOS and Linux. On Windows it works for you because there is VisualStudioInstanceProvider that looks if VS is installed and gets the correct path to msbuild from it. On macOS without installed mono you only have StandAloneInstanceProvider that has hardcoded path to msbuild to look for ...
here is the code from src/OmniSharp.Host/MSBuild/Discovery/MSBuildInstanceProvider.cs
protected static string FindLocalMSBuildDirectory()
{
// If OmniSharp is running normally, MSBuild is located in an 'msbuild' folder beneath OmniSharp.exe.
var msbuildDirectory = Path.Combine(AppContext.BaseDirectory, "msbuild");
...
}
Moreover, the whole current logic of choosing msbuild to use seems more like guessing... this general approach doesn't work on Windows when you have two Visual Studio instancies installed (e.g. 2017 and 2019). I think OmniSharp.MSBuild.Discovery.MSBuildLocator should take into consideration TargetFramework or it's equvalent in old project's file format, or should be configurable. Otherwise it won't work.
Exact same issue on my Mac. Setting MsBuildSDKsPath
in omnisharp.json
and omnisharp.path
to latest
results in
[warn]: OmniSharp.MSBuild.ProjectManager Failed to load project file '/Users/puccio/Desktop/myApp/myApp.csproj'. /Users/puccio/Desktop/myApp/myApp.csproj(1,1) Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk' specified could not be found.
I've tried reinstalling VSCode, .Net Core 2.2, mono and the C# extension so many times now to no avail.
puccio @ ~/Desktop/myApp $: dotnet --info .NET Core SDK (reflecting any global.json): Version: 2.2.103 Commit: 8edbc2570a
Runtime Environment: OS Name: Mac OS X OS Version: 10.12 OS Platform: Darwin RID: osx.10.12-x64 Base Path: /usr/local/share/dotnet/sdk/2.2.103/
Host (useful for support): Version: 2.2.1 Commit: 878dd11e62
.NET Core SDKs installed: 2.2.103 [/usr/local/share/dotnet/sdk]
.NET Core runtimes installed: Microsoft.AspNetCore.All 2.2.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.2.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.2.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download
I guess there is nothing to do with the OS here. It happens in Windows too. See the error below:
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk' specified could not be found.
Here is my environment details:
dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.0.100-preview-010184
Commit: c57bde4593
Runtime Environment:
OS Name: Windows
OS Version: 10.0.17134
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.0.100-preview-010184\
Host (useful for support):
Version: 3.0.0-preview-27324-5
Commit: 63a01b08e5
@KeyurRamoliya you're absolutely right, this problem has nothing to do with OS. On Windows it's easier, because you have more options: you could install Visual Studio 2019, and than OmniSharp will be able to pick up MSbuild from it, thanks to VisualStudioInstanceProvider. On Linux and macOS you don't have it. Even though there is VS for Mac, but the latest version of VS for Mac is 7.7, and it only supports .net core 2.2. The only way that I can see is to write a new implementation of MSBuildInstanceProvider, that will be able to pick up MSBuild from the path where .net core's installed.
FYI if it helps anyone. I've got a Hyper-V VM running Ubuntu 19.04 and the snap vscode is installed, and I had this same issue, which I seem to have resolved by installing the dotnet-sdk snap and doing a "sudo ln -sv /snap/dotnet-sdk/current/dotnet /usr/local/bin/dotnet" to manually create a symbolic link where Omnisharp would find it. In a perfect world, all I'd have to do is something like "sudo snap alias dotnet-sdk.dotnet dotnet" but I never could get Omnisharp to work that way as it appears to ignore /snap/bin or something (not sure). You can also just create a "~/bin" folder and make the symbolic link there (no sudo required, obviously, but I went ahead and made it system-wide for the VM).
@byroniac Yea I've tried that before on a Mac before where you create a symbolic link from /usr/local/bin/dotnet -> /usr/local/share/dotnet/dotnet but it still doesn't work.
In my case I only have the snaps installed (dotnet-sdk, vscode). So I am not exactly in the same scenario (I did get the same Omnisharp error message and failed to get Intellisense to load). I was hoping this would give someone an idea, but apparently, there is an issue with the preview version of dotnet? I'm not familiar with Macs, so do they even have a /usr/local/bin in the default PATH? Have you tried /usr/bin? (like renaming any existing dotnet, and creating a symbolic link to point to the dotnet you want to use?)
For folks hitting this issue on windows, please try installing .Net Core Build Tools as described here
For ubuntu please try adding a omnisharp.json file as suggested here
@akshita31 I am not able to install ".NET Core build tools" workload because of some reason. So is there any chance that it will be fixed by Omnisharp devs?
I got this issue on windows too, it feels that last updated msbuild wins. I installed 3.0 SDK -> broken. Installed VS2019 preview -> works again. Updated project tools for VS2017 -> broken again. Now VS2019 version is second on list and not first.
I updated MsBuildLocatator.GetInstances() and compiled local version:
public ImmutableArray<MSBuildInstance> GetInstances()
{
var result = _providers
.SelectMany(x => x.GetInstances())
.Where(x => x != null)
.OrderByDescending(x => x.Version)
.ToImmutableArray();
LogInstances(result);
return result;
}
However i don't know is that good/bad/terrible idea to use latest version as default. Atleast that works on my machine 🤔
@KeyurRamoliya Could you set omnisharp.loggingLevel: debug and share the omnisharp log?
@akshita31 Here is the omnisharp log with log level debug
.
Starting OmniSharp server at 6/3/2019, 4:25:06 PM
Target: c:\Projects\Github\performance\src\benchmarks\micro\MicroBenchmarks.sln
OmniSharp server started.
Path: C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\OmniSharp.exe
PID: 3588
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.Cake, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.DotNet, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.DotNetTest, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.Host, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.MSBuild, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.Plugins, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.Roslyn, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.Roslyn.CSharp, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.Script, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
[dbug]: OmniSharp.MSBuild.Discovery.Providers.VisualStudioInstanceProvider
An exception was thrown while retrieving Visual Studio instances.
System.DllNotFoundException: Unable to load DLL 'Microsoft.VisualStudio.Setup.Configuration.Native.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at OmniSharp.MSBuild.Discovery.Interop.GetSetupConfiguration(ISetupConfiguration& configuration, IntPtr reserved)
at OmniSharp.MSBuild.Discovery.Interop.GetSetupConfiguration()
at OmniSharp.MSBuild.Discovery.Providers.VisualStudioInstanceProvider.GetInstances()
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: StandAlone 15.0 - "C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin"
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
SUCCESS: Resolved to 'C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\Microsoft.Build.Utilities.Core.dll' (name-only).
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
SUCCESS: Resolved to 'C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\Microsoft.Build.Tasks.Core.dll' (name-only).
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
SUCCESS: Resolved to 'C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\Microsoft.Build.dll' (name-only).
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
SUCCESS: Resolved to 'C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\Microsoft.Build.Framework.dll' (name-only).
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
MSBUILD_EXE_PATH environment variable set to 'C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\MSBuild.exe'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: StandAlone 15.0 - "C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin"
CscToolExe = csc.exe
CscToolPath = C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\Roslyn
MSBuildExtensionsPath = C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild
MSBuildToolsPath = C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Attempting to resolve 'Microsoft.Build.Utilities.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
SUCCESS: Resolved to 'C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\Microsoft.Build.Utilities.Core.dll' (name-only).
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Attempting to resolve 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
SUCCESS: Resolved to 'C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\Microsoft.Build.Framework.dll' (name-only).
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Attempting to resolve 'Microsoft.CodeAnalysis.VisualBasic.Workspaces, Version=2.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
FAILURE: Could not locate 'C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll'.
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Attempting to resolve 'Microsoft.CodeAnalysis.VisualBasic.Features, Version=2.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
FAILURE: Could not locate 'C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\Microsoft.CodeAnalysis.VisualBasic.Features.dll'.
[info]: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in 'c:\Projects\Github\performance\src\benchmarks\micro'.
[info]: OmniSharp.Cake.CakeProjectSystem
Could not find any Cake files
[info]: OmniSharp.WorkspaceInitializer
Project system 'OmniSharp.DotNet.DotNetProjectSystem' is disabled in the configuration.
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Attempting to resolve 'Microsoft.Build'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
SUCCESS: Resolved to 'C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\Microsoft.Build.dll' (name-only).
[dbug]: OmniSharp.MSBuild.ProjectSystem
MSBuild environment:
Mode: Standalone
RunningTests: False
RunningInVisualStudio: False
MSBuildToolsDirectory32: C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin
MSBuildToolsDirectory64: C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin
MSBuildSDKsPath: C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\Sdks
CurrentMSBuildConfigurationFile: C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\MSBuild.exe.config
CurrentMSBuildExePath: C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\MSBuild.exe
CurrentMSBuildToolsDirectory: C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin
VisualStudioInstallRootDirectory:
MSBuildExtensionsPath: C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin
[dbug]: OmniSharp.MSBuild.ProjectLoader
'MSBuildExtensionsPath' set to 'C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild'
[dbug]: OmniSharp.MSBuild.ProjectLoader
'CscToolPath' set to 'C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\Roslyn'
[dbug]: OmniSharp.MSBuild.ProjectLoader
'CscToolExe' set to 'csc.exe'
[info]: OmniSharp.MSBuild.ProjectSystem
Detecting projects in 'c:\Projects\Github\performance\src\benchmarks\micro\MicroBenchmarks.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for 'c:\Projects\Github\performance\src\benchmarks\micro\MicroBenchmarks.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for 'c:\Projects\Github\performance\src\tests\benchmarks\micro\Tests.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in 'c:\Projects\Github\performance\src\benchmarks\micro'.
[info]: OmniSharp.Script.ScriptProjectSystem
Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: c:\Projects\Github\performance\src\benchmarks\micro\MicroBenchmarks.csproj
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Attempting to resolve 'Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
SUCCESS: Resolved to 'C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\Microsoft.Build.dll' (name-only).
[info]: OmniSharp.WorkspaceInitializer
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location 'c:\Projects\Github\performance\src\benchmarks\micro' on host 24988.
[dbug]: OmniSharp.Stdio.Host
************ Request ************
{
"Type": "request",
"Seq": 1,
"Command": "/projects"
}
[dbug]: OmniSharp.Stdio.Host
************ Request ************
{
"Type": "request",
"Seq": 2,
"Command": "/projects"
}
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Attempting to resolve 'Microsoft.Build.resources, Version=15.1.0.0, Culture=en-US, PublicKeyToken=b03f5f7f11d50a3a'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
FAILURE: Could not locate 'C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\Microsoft.Build.resources.dll'.
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Attempting to resolve 'Microsoft.Build.resources, Version=15.1.0.0, Culture=en-US, PublicKeyToken=b03f5f7f11d50a3a'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
FAILURE: Could not locate 'C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\Microsoft.Build.resources.dll'.
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file 'c:\Projects\Github\performance\src\benchmarks\micro\MicroBenchmarks.csproj'.
c:\Projects\Github\performance\src\benchmarks\micro\MicroBenchmarks.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk' specified could not be found. c:\Projects\Github\performance\src\benchmarks\micro\MicroBenchmarks.csproj
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List`1& projects, Boolean throwOnFileNotExistsError)
at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
at Microsoft.Build.Evaluation.Evaluator`4.Evaluate(ILoggingService loggingService, BuildEventContext buildEventContext)
at Microsoft.Build.Evaluation.Project.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings)
at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings)
at Microsoft.Build.Evaluation.Project.Initialize(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings)
at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings)
at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary`2 globalProperties, String toolsVersion)
at OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore(String filePath)
at OmniSharp.MSBuild.ProjectLoader.BuildProject(String filePath)
at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load(String filePath, ProjectLoader loader)
at OmniSharp.MSBuild.ProjectManager.LoadOrReloadProject(String projectFilePath, Func`1 loader)
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: c:\Projects\Github\performance\src\tests\benchmarks\micro\Tests.csproj
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file 'c:\Projects\Github\performance\src\tests\benchmarks\micro\Tests.csproj'.
c:\Projects\Github\performance\src\tests\benchmarks\micro\Tests.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk' specified could not be found. c:\Projects\Github\performance\src\tests\benchmarks\micro\Tests.csproj
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List`1& projects, Boolean throwOnFileNotExistsError)
at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
at Microsoft.Build.Evaluation.Evaluator`4.Evaluate(ILoggingService loggingService, BuildEventContext buildEventContext)
at Microsoft.Build.Evaluation.Project.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings)
at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings)
at Microsoft.Build.Evaluation.Project.Initialize(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings)
at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings)
at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary`2 globalProperties, String toolsVersion)
at OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore(String filePath)
at OmniSharp.MSBuild.ProjectLoader.BuildProject(String filePath)
at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load(String filePath, ProjectLoader loader)
at OmniSharp.MSBuild.ProjectManager.LoadOrReloadProject(String projectFilePath, Func`1 loader)
[fail]: OmniSharp.MSBuild.ProjectManager
Attemped to update project that is not loaded: c:\Projects\Github\performance\src\benchmarks\micro\MicroBenchmarks.csproj
[fail]: OmniSharp.MSBuild.ProjectManager
Attemped to update project that is not loaded: c:\Projects\Github\performance\src\tests\benchmarks\micro\Tests.csproj
[dbug]: OmniSharp.Stdio.Host
************ Response ************
{
"Request_seq": 1,
"Command": "/projects",
"Running": true,
"Success": true,
"Message": null,
"Body": {
"Cake": {
"Projects": []
},
"DotNet": {
"Projects": [],
"RuntimePath": null
},
"MsBuild": {
"SolutionPath": "c:\\Projects\\Github\\performance\\src\\benchmarks\\micro\\MicroBenchmarks.sln",
"Projects": []
},
"Script": {
"Projects": []
}
},
"Seq": 52,
"Type": "response"
}
[dbug]: OmniSharp.Stdio.Host
************ Response ************
{
"Request_seq": 2,
"Command": "/projects",
"Running": true,
"Success": true,
"Message": null,
"Body": {
"Cake": {
"Projects": []
},
"DotNet": {
"Projects": [],
"RuntimePath": null
},
"MsBuild": {
"SolutionPath": "c:\\Projects\\Github\\performance\\src\\benchmarks\\micro\\MicroBenchmarks.sln",
"Projects": []
},
"Script": {
"Projects": []
}
},
"Seq": 51,
"Type": "response"
}
[dbug]: OmniSharp.Stdio.Host
************ Request ************
{
"Type": "request",
"Seq": 3,
"Command": "/projects"
}
[dbug]: OmniSharp.Stdio.Host
************ Response ************
{
"Request_seq": 3,
"Command": "/projects",
"Running": true,
"Success": true,
"Message": null,
"Body": {
"Cake": {
"Projects": []
},
"DotNet": {
"Projects": [],
"RuntimePath": null
},
"MsBuild": {
"SolutionPath": "c:\\Projects\\Github\\performance\\src\\benchmarks\\micro\\MicroBenchmarks.sln",
"Projects": []
},
"Script": {
"Projects": []
}
},
"Seq": 67,
"Type": "response"
}
[dbug]: OmniSharp.Stdio.Host
************ Request ************
{
"Type": "request",
"Seq": 4,
"Command": "/codecheck",
"Arguments": {
"FileName": "c:\\Projects\\Github\\performance\\src\\benchmarks\\micro\\coreclr\\Span\\Indexer.cs"
}
}
[dbug]: OmniSharp.Stdio.Host
************ Request ************
{
"Type": "request",
"Seq": 5,
"Command": "/v2/blockstructure",
"Arguments": {
"FileName": "c:\\Projects\\Github\\performance\\src\\benchmarks\\micro\\coreclr\\Span\\Indexer.cs"
}
}
[dbug]: OmniSharp.Stdio.Host
************ Response ************
{
"Request_seq": 4,
"Command": "/codecheck",
"Running": true,
"Success": true,
"Message": null,
"Body": {
"QuickFixes": []
},
"Seq": 70,
"Type": "response"
}
[dbug]: OmniSharp.Stdio.Host
************ Request ************
{
"Type": "request",
"Seq": 6,
"Command": "/v2/codestructure",
"Arguments": {
"FileName": "c:\\Projects\\Github\\performance\\src\\benchmarks\\micro\\coreclr\\Span\\Indexer.cs"
}
}
[dbug]: OmniSharp.Stdio.Host
************ Response ************
{
"Request_seq": 6,
"Command": "/v2/codestructure",
"Running": true,
"Success": true,
"Message": null,
"Body": null,
"Seq": 75,
"Type": "response"
}
[dbug]: OmniSharp.Stdio.Host
************ Request ************
{
"Type": "request",
"Seq": 7,
"Command": "/v2/codestructure",
"Arguments": {
"FileName": "c:\\Projects\\Github\\performance\\src\\benchmarks\\micro\\coreclr\\Span\\Indexer.cs"
}
}
[dbug]: OmniSharp.Stdio.Host
************ Response ************
{
"Request_seq": 7,
"Command": "/v2/codestructure",
"Running": true,
"Success": true,
"Message": null,
"Body": null,
"Seq": 78,
"Type": "response"
}
[dbug]: OmniSharp.Stdio.Host
************ Request ************
{
"Type": "request",
"Seq": 8,
"Command": "/v2/codestructure",
"Arguments": {
"FileName": "c:\\Projects\\Github\\performance\\src\\benchmarks\\micro\\coreclr\\Span\\Indexer.cs"
}
}
[dbug]: OmniSharp.Stdio.Host
************ Response ************
{
"Request_seq": 8,
"Command": "/v2/codestructure",
"Running": true,
"Success": true,
"Message": null,
"Body": null,
"Seq": 81,
"Type": "response"
}
[dbug]: OmniSharp.Stdio.Host
************ Request ************
{
"Type": "request",
"Seq": 9,
"Command": "/v2/codestructure",
"Arguments": {
"FileName": "c:\\Projects\\Github\\performance\\src\\benchmarks\\micro\\coreclr\\Span\\Indexer.cs"
}
}
[dbug]: OmniSharp.Stdio.Host
************ Response ************
{
"Request_seq": 9,
"Command": "/v2/codestructure",
"Running": true,
"Success": true,
"Message": null,
"Body": null,
"Seq": 84,
"Type": "response"
}
[dbug]: OmniSharp.Stdio.Host
************ Request ************
{
"Type": "request",
"Seq": 10,
"Command": "/v2/codestructure",
"Arguments": {
"FileName": "c:\\Projects\\Github\\performance\\src\\benchmarks\\micro\\coreclr\\Span\\Indexer.cs"
}
}
[dbug]: OmniSharp.Stdio.Host
************ Response ************
{
"Request_seq": 10,
"Command": "/v2/codestructure",
"Running": true,
"Success": true,
"Message": null,
"Body": null,
"Seq": 87,
"Type": "response"
}
[dbug]: OmniSharp.Stdio.Host
************ Request ************
{
"Type": "request",
"Seq": 11,
"Command": "/v2/getcodeactions",
"Arguments": {
"FileName": "c:\\Projects\\Github\\performance\\src\\benchmarks\\micro\\coreclr\\Span\\Indexer.cs",
"Line": 30,
"Column": 44
}
}
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Attempting to resolve 'Microsoft.CodeAnalysis.Workspaces.resources, Version=2.9.0.0, Culture=en-US, PublicKeyToken=31bf3856ad364e35'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
FAILURE: Could not locate 'C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\Microsoft.CodeAnalysis.Workspaces.resources.dll'.
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Attempting to resolve 'Microsoft.CodeAnalysis.Workspaces.resources, Version=2.9.0.0, Culture=en-US, PublicKeyToken=31bf3856ad364e35'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
FAILURE: Could not locate 'C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\Microsoft.CodeAnalysis.Workspaces.resources.dll'.
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Attempting to resolve 'Microsoft.CodeAnalysis.Workspaces.resources, Version=2.9.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
FAILURE: Could not locate 'C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\Microsoft.CodeAnalysis.Workspaces.resources.dll'.
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Attempting to resolve 'Microsoft.CodeAnalysis.Workspaces.resources, Version=2.9.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
FAILURE: Could not locate 'C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\Microsoft.CodeAnalysis.Workspaces.resources.dll'.
[dbug]: OmniSharp.Stdio.Host
************ Response ************
{
"Request_seq": 5,
"Command": "/v2/blockstructure",
"Running": true,
"Success": false,
"Message": "\"System.NullReferenceException: Object reference not set to an instance of an object.\\r\\n at OmniSharp.Roslyn.CSharp.Services.Structure.BlockStructureService.<Handle>d__12.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n at OmniSharp.Endpoint.EndpointHandler`2.<HandleSingleRequest>d__18.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n at OmniSharp.Endpoint.EndpointHandler`2.<Process>d__16.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n at OmniSharp.Stdio.Host.<HandleRequest>d__13.MoveNext()\"",
"Body": null,
"Seq": 72,
"Type": "response"
}
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Attempting to resolve 'Microsoft.CodeAnalysis.Features.resources, Version=2.9.0.0, Culture=en-US, PublicKeyToken=31bf3856ad364e35'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
FAILURE: Could not locate 'C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\Microsoft.CodeAnalysis.Features.resources.dll'.
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Attempting to resolve 'Microsoft.CodeAnalysis.Features.resources, Version=2.9.0.0, Culture=en-US, PublicKeyToken=31bf3856ad364e35'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
FAILURE: Could not locate 'C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\Microsoft.CodeAnalysis.Features.resources.dll'.
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Attempting to resolve 'Microsoft.CodeAnalysis.Features.resources, Version=2.9.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
FAILURE: Could not locate 'C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\Microsoft.CodeAnalysis.Features.resources.dll'.
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Attempting to resolve 'Microsoft.CodeAnalysis.Features.resources, Version=2.9.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
FAILURE: Could not locate 'C:\Users\keyurramoliya\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\Microsoft.CodeAnalysis.Features.resources.dll'.
[dbug]: OmniSharp.Stdio.Host
************ Response ************
{
"Request_seq": 11,
"Command": "/v2/getcodeactions",
"Running": true,
"Success": true,
"Message": null,
"Body": {
"CodeActions": []
},
"Seq": 90,
"Type": "response"
}
[dbug]: OmniSharp.Stdio.Host
************ Request ************
{
"Type": "request",
"Seq": 12,
"Command": "/v2/getcodeactions",
"Arguments": {
"FileName": "c:\\Projects\\Github\\performance\\src\\benchmarks\\micro\\coreclr\\Span\\Indexer.cs",
"Line": 30,
"Column": 44
}
}
[dbug]: OmniSharp.Stdio.Host
************ Response ************
{
"Request_seq": 12,
"Command": "/v2/getcodeactions",
"Running": true,
"Success": true,
"Message": null,
"Body": {
"CodeActions": []
},
"Seq": 110,
"Type": "response"
}
Let me know if you need anything else.
@KeyurRamoliya I think the problem for you is the one listed here https://github.com/OmniSharp/omnisharp-vscode/issues/2937. Basically msbuild 15 that ships with omnisharp currently is not compatible with the .net core sdk 3.0. We are working on this. Sorry that it is taking so long and thank you for the patience.
I had a similar issue with DotnetCore 2.2. I added the following to .bashrc on Ubuntu:
export MSBuildSDKsPath="/usr/share/dotnet/sdk/$(dotnet --version)/Sdks"
FWIW, on my Fedora installation where I suffered from this issues for months, I found out that the issue was that some dotnet
symlink was dead in my installation. IIRC, it was the one in /opt/dotnet/dotnet that was broken, while .NET Core was installed someplace, and MSBuild was using this broken symlink anyway then failed resolution of Sdks. Removing the broken symlink fixed it.
I had a similar issue with DotnetCore 2.2. I added the following to .bashrc on Ubuntu:
export MSBuildSDKsPath="/usr/share/dotnet/sdk/$(dotnet --version)/Sdks"
This fixed for me. Thanks!
I had a similar issue with DotnetCore 2.2. I added the following to .bashrc on Ubuntu:
export MSBuildSDKsPath="/usr/share/dotnet/sdk/$(dotnet --version)/Sdks"
Oh wow... it works in my Ubuntu 18.04 VM! THANK YOU. Kudos.
FWIW, on my Fedora installation where I suffered from this issues for months, I found out that the issue was that some
dotnet
symlink was dead in my installation. IIRC, it was the one in /opt/dotnet/dotnet that was broken, while .NET Core was installed someplace, and MSBuild was using this broken symlink anyway then failed resolution of Sdks. Removing the broken symlink fixed it.
@mickaelistria I appreciate your comment. Unfortunately, this was not my issue. In another Ubuntu VM, I am running Ubuntu 18.10 so I am using the Dotnet and VSCode snaps. I haven't tried the suggestion above for it, yet. When I do, I will put in my .bash_aliases file instead of ,bashrc and use the path for the Snap Dotnet, which is something like /snap/dotnet-sdk/current.... whatever, and I hope it will work. Before Dotnet 2.2.205, all I needed was a symlink to the snap version of dotnet, which I created as "/usr/local/bin/dotnet" pointing to the snap version of dotnet, and it worked fine. Not sure why that stopped working with this release, but I'll try a modified version of the suggestion above and see. Fingers crossed. Hope you don't have issues (I don't on Windows, but I haven't used Fedora in quite a while).
I had a similar issue with DotnetCore 2.2. I added the following to .bashrc on Ubuntu:
export MSBuildSDKsPath="/usr/share/dotnet/sdk/$(dotnet --version)/Sdks"
This fixed my issue on Fedora 29! Thank you!
I had a similar issue with DotnetCore 2.2. I added the following to .bashrc on Ubuntu:
export MSBuildSDKsPath="/usr/share/dotnet/sdk/$(dotnet --version)/Sdks"
I had a similar issue with dotnetcore 2.2.203 sdk. I add it by tar.gz on my Gentoo, solved it as you said. Thank you.
FWIW, on my Fedora installation where I suffered from this issues for months, I found out that the issue was that some
dotnet
symlink was dead in my installation. IIRC, it was the one in /opt/dotnet/dotnet that was broken, while .NET Core was installed someplace, and MSBuild was using this broken symlink anyway then failed resolution of Sdks. Removing the broken symlink fixed it.@mickaelistria I appreciate your comment. Unfortunately, this was not my issue. In another Ubuntu VM, I am running Ubuntu 18.10 so I am using the Dotnet and VSCode snaps. I haven't tried the suggestion above for it, yet. When I do, I will put in my .bash_aliases file instead of ,bashrc and use the path for the Snap Dotnet, which is something like /snap/dotnet-sdk/current.... whatever, and I hope it will work. Before Dotnet 2.2.205, all I needed was a symlink to the snap version of dotnet, which I created as "/usr/local/bin/dotnet" pointing to the snap version of dotnet, and it worked fine. Not sure why that stopped working with this release, but I'll try a modified version of the suggestion above and see. Fingers crossed. Hope you don't have issues (I don't on Windows, but I haven't used Fedora in quite a while).
I'm on Ubuntu 19.04 with both vscode and dotnet installed from snap. I haven't manged to get it working by setting $MSBuildSDKsPath. (Or any other way, for that matter :nerd_face: )
I'm on Ubuntu 19.04 with both vscode and dotnet installed from snap. I haven't manged to get it working by setting $MSBuildSDKsPath. (Or any other way, for that matter 🤓 )
On my Ubuntu 19.04 machine, I have 2.2.204 working (disclaimer: have not tried 3.0-preview), by making sure my snaps were all up to date with "sudo snap refresh" and then making sure I had a link to dotnet by doing something like (from memory, as I'm not on that machine at the moment): "sudo ln -sv /snap/dotnet-sdk/current/dotnet /usr/local/bin/dotnet" to make a global link to "dotnet". Making a snap alias was insufficient for VSCode, though for CLI work it was fine, so I removed it and did the symbolic link approach. This might all go out the window with the 3.0-preview, though. They had a problem with the SDK resolver in VSCode in the C# Omnisharp extension which is now fixed, I believe. I haven't tried it in the last few days, though.
Thanks! That got me to the next error: The imported project "/usr/lib/mono/xbuild/15.0/Microsoft.Common.props" was not found
But luckily that one has its own issue (OmniSharp/omnisharp-vscode#3049) :smile:
From @https://github.com/Vannevelj I've installed the net core 2.1 SDK and the projects load correctly. I then installed the 3.0-preview and changed the solution to use this instead and now they can no longer load in VSCode. It loads perfectly fine on my Windows machine.
I've tried setting the SDK path environment variable explicitly but no difference:
MsBuildSDKsPath=/usr/share/dotnet/sdk/3.0.100-preview-010184/Sdks/
as well as changingomnisharp.path
tolatest
, setting the path insideomnisharp.json
directly and using the insiders build of VSCode.Is there anything off in my environment? I've created a VM with Linux specifically to test .net core 3 on it so there shouldn't be anything unusual interfering with things. Happy to try out whatever you can suggest.
Example csproj file:
Environment data
dotnet --info
output:VS Code version:
C# Extension version: 1.17.1
Steps to reproduce
dotnet new console
code .
Expected behavior
The project loads correctly and code lens options show.
Actual behavior
Errors in the output and no code lens available. However, using
dotnet run
runs the project as intended.