Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot load projects that use an MSBuild SDK package #1190

Closed
natemcmaster opened this issue May 16, 2018 · 11 comments · Fixed by #1192
Closed

Cannot load projects that use an MSBuild SDK package #1190

natemcmaster opened this issue May 16, 2018 · 11 comments · Fixed by #1192

Comments

@natemcmaster
Copy link
Contributor

MSBuild 15.6 added a new SDK resolver that can use NuGet packages as SDKs. When opening a project that uses a NuGet-based SDK package, OmniSharp cannot load the project.

Repro
git clone https://github.com/dotnet/arcade
Open VS Code

Expected
OmniSharp uses the same SDK resolution that VS 15.6 and the .NET Core CLI 2.1.105 use.

Actual
Project fails to load with:

[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file '/Users/namc/dev/dotnet/arcade/src/Microsoft.DotNet.Build.Tasks.Feed/Microsoft.DotNet.Build.Tasks.Feed.csproj'.
/Users/namc/dev/dotnet/arcade/src/Microsoft.DotNet.Build.Tasks.Feed/Microsoft.DotNet.Build.Tasks.Feed.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'RoslynTools.RepoToolset' specified could not be found.  /Users/namc/dev/dotnet/arcade/src/Microsoft.DotNet.Build.Tasks.Feed/Microsoft.DotNet.Build.Tasks.Feed.csproj
  at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.String toolsVersion) [0x00000] in <61115f75067146fab35b10183e6ee379>:0 
  at OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore (System.String filePath) [0x0003e] in <64f2a38974d54ecaaa93e3697628b738>:0 
  at OmniSharp.MSBuild.ProjectLoader.BuildProject (System.String filePath) [0x0000d] in <64f2a38974d54ecaaa93e3697628b738>:0 
  at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load (System.String filePath, OmniSharp.MSBuild.ProjectLoader loader) [0x00014] in <64f2a38974d54ecaaa93e3697628b738>:0 
  at OmniSharp.MSBuild.ProjectManager+<>c__DisplayClass23_0.<LoadProject>b__0 () [0x00000] in <64f2a38974d54ecaaa93e3697628b738>:0 
  at (wrapper delegate-invoke) System.Func`1[System.ValueTuple`2[OmniSharp.MSBuild.ProjectFile.ProjectFileInfo,System.Collections.Immutable.ImmutableArray`1[OmniSharp.MSBuild.Logging.MSBuildDiagnostic]]].invoke_TResult()
  at OmniSharp.MSBuild.ProjectManager.LoadOrReloadProject (System.String projectFilePath, System.Func`1[TResult] loadFunc) [0x0001b] in <64f2a38974d54ecaaa93e3697628b738>:0 

Details

See https://github.com/microsoft/msbuildsdks and https://docs.microsoft.com/en-us/visualstudio/msbuild/how-to-use-project-sdk#how-project-sdks-are-resolved for more details

VS Code C# extension: 1.15.2
VS Code: 1.23.1

@DustinCampbell
Copy link
Contributor

@natemcmaster : Is this a duplicate of #1138?

@natemcmaster
Copy link
Contributor Author

Depends if this distinction is important. In #1138, the additional SDK (Typescript.Sdk) is installed into the MSBuild base path. In this bug, the additional SDK is mean to be resolved via NuGet.

@DustinCampbell
Copy link
Contributor

Yeah, I don't know if the distinction is important either. There has been no work on OmniSharp done to support MSBuild SDKs to date.

@DustinCampbell
Copy link
Contributor

Would you be willing to provide your full OmniSharp Log instead of just the error?

@natemcmaster
Copy link
Contributor Author

Sure, no problem.
log.txt

@DustinCampbell
Copy link
Contributor

FYI that I have a good idea what's causing this. Mono 5.12.0 does ship the SDK resolver for acquiring MSBuild SDKs from NuGet. However, OmniSharp is setting the MSBuildSdksPath environment variable directly, which overrides the SDK resolvers.

@DustinCampbell
Copy link
Contributor

Yup. I was able to prototype a change to OmniSharp that would allow it to properly use MSBuild SDKs when a Mono is installed SxS that supports them. I'll try to work that into a proper fix in the next day or two.

@DustinCampbell
Copy link
Contributor

@natemcmaster: I've just merged the change that I hope will fix this. Once the build is complete (probably within the hour), you should be able to set "omnisharp.path" to "latest" in VS Code. Then, C# for VS Code will download and use the latest version of OmniSharp, which will include the fix.

@DustinCampbell
Copy link
Contributor

It looks like the build is ready, so you should be able to give that option a spin.

@natemcmaster
Copy link
Contributor Author

Thanks! I gave it a spin and it fixes the error I was seeing. I'm seeing a new issues now, but I'll open a new bug as that appears to be unrelated.

@DustinCampbell
Copy link
Contributor

That's great to hear! This was a bigger work item than I'd expected, so thanks for verifying. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants