When I try to open a dotNet core 1.1 mvc project in visual studio code, the csproj file is not recognized and I cant get any symbols from the project.
VSCode displays a [warn] message saying "Some projects have trouble loading, please review the output for more details". In the output i got the following message:
[warn]: OmniSharp.MSBuild.MSBuildProjectSystem Failed to process project file 'c:\Users\humam\Projects\AM\AM.csproj'. c:\Users\humam\Projects\AM\AM.csproj(1,1) Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Sdks\Microsoft.NET.Sdk.Web\Sdk\Sdk.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk. c:\Users\humam\Projects\AM\AM.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.Evaluator4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement) at Microsoft.Build.Evaluation.Evaluator
4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement) at Microsoft.Build.Evaluation.Evaluator4.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(IDictionary2 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, IDictionary2 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)
Any idea what could be the source of this problem?
My environment is Windows 10 includes DotNet Core SDK 1.1.0, VSCode 1.12.2 and Omnisharp 1.9.0 C# extension for VSCode along with other extensions.
The project is created using dotnet core command "dotnet new mvc --auth Individual -o AM".
OmniSharp seems to load the VS 2017 build tools which don't support .NET Core projects at the moment: https://github.com/Microsoft/msbuild/issues/1697. Try installing a version of VS 2017 with the web development / cross-platform workloads instead or create an omnisharp.json
file in your project containing:
{
"msbuild": {
"msbuildextensionspath": "C:\\Program Files\\dotnet\\sdk\\1.0.4\\Sdks"
}
}
You then need to dotnet restore
via command line (since the build tools also don't contain a version of NuGet) and reload the project in VSCode.