vscode-csharp: OmniSharp server picks up the wrong version of Visual Studio
It looks like if Visual Studio and Visual Studio Preview are installed the OmniSharp server will always try to the Preview version of the local Visual Studio installation for MSBuild.
Environment data
dotnet --info
output:
.NET Command Line Tools (1.0.3)
Product Information:
Version: 1.0.3
Commit SHA-1 hash: 37224c9917
Runtime Environment:
OS Name: Windows
OS Version: 10.0.15063
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\1.0.3
VS Code version: 1.11.2 C# Extension version: 1.9.0
Steps to reproduce
- Download and install Visual Studio with .NET Core support.
- Download and install Visual Studio preview without .NET Core support. (I have Visual Studio Preview setup with only Python support).
- Create a new .NET Core project using
dotnet new console
. - Open the project using VSCode.
Expected behavior
C# project loads properly.
Actual behavior
C# extension reports: Warning: Some projects have trouble loading. Please review the output for more details.
Here’s my output log.
Starting OmniSharp server at 4/28/2017, 3:04:46 AM
Target: c:\Users\Sanders\dotnettest
OmniSharp server started
Path: C:\Users\Sanders\.vscode\extensions\ms-vscode.csharp-1.9.0\bin\omnisharp\OmniSharp.exe
PID: 22872
OmniSharp: -s c:\Users\Sanders\dotnettest --hostPID 13324 --stdio DotNet:enablePackageRestore=false --encoding utf-8 --loglevel information formattingOptions:useTabs=false formattingOptions:tabSize=4 formattingOptions:indentationSize=4
[info]: OmniSharp.Startup
Omnisharp server running using Stdio at location 'c:\Users\Sanders\dotnettest' on host 13324.
[info]: OmniSharp.DotNet.DotNetProjectSystem
Initializing in c:\Users\Sanders\dotnettest
[info]: OmniSharp.DotNet.DotNetProjectSystem
Auto package restore: False
[info]: OmniSharp.DotNet.DotNetProjectSystem
Update workspace context
[info]: OmniSharp.DotNet.DotNetProjectSystem
Resolving projects references
[info]: OmniSharp.MSBuild.MSBuildProjectSystem
MSBuild will use local Visual Studio installation.
[info]: OmniSharp.MSBuild.MSBuildProjectSystem
No solution files found in 'c:\Users\Sanders\dotnettest'
[warn]: OmniSharp.MSBuild.MSBuildProjectSystem
Failed to process project file 'c:\Users\Sanders\dotnettest\dotnettest\dotnettest.csproj'.
c:\Users\Sanders\dotnettest\dotnettest\dotnettest.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\Preview\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. c:\Users\Sanders\dotnettest\dotnettest\dotnettest.csproj
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(IElementLocation elementLocation, String resourceName, Object arg0)
at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpression(String directoryOfImportingFile, ProjectImportElement importElement, String unescapedExpression, Boolean throwOnFileNotExistsError, List`1& imports)
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()
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.ProjectFile.ProjectFileInfo.Create(String projectFilePath, String solutionDirectory, ILogger logger, MSBuildOptions options, ICollection`1 diagnostics, Boolean isUnityProject)
at OmniSharp.MSBuild.MSBuildProjectSystem.CreateProjectFileInfo(String projectFilePath, Boolean isUnityProject)
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in 'c:\Users\Sanders\dotnettest'.
[info]: OmniSharp.Script.ScriptProjectSystem
Could not find any CSX files
[info]: OmniSharp.Startup
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.Startup
Configuration finished.
This worked fine before I had the Preview version installed.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 19 (13 by maintainers)
This should be addressed with https://github.com/OmniSharp/omnisharp-roslyn/pull/847, which sets MSBuildSDKsPath to the .NET CLI.