tintoy / msbuild-project-tools-vscode

VS Code extension for MSBuild intellisense (including PackageReference completion).
MIT License
83 stars 17 forks source link

CSPROJ package autocomplete not working #44

Closed SimantoR closed 5 years ago

SimantoR commented 5 years ago

image

Autocomplete for packages not working

tintoy commented 5 years ago

Hmm, sorry about that; it seems the newest SDKs for .NET Core have changed a bit in ways the extension wasn't expecting and this is causing problems for some people (I thought I'd fixed this problem but perhaps not for everyone).

If you look in the output window under "MSBuild Project Tools", do you see any output there?

SimantoR commented 5 years ago

Where exactly should I be looking for "MSBuild Project Tools"?

And could it be because I have two MSBuild in my path?

tintoy commented 5 years ago

image

could it be because I have two MSBuild in my path?

I wouldn't think so, the extension doesn't use msbuild.exe, it uses the MSBuild engine as a library (bundled with the extension's language server) and then calls dotnet --info to determine where the .NET Core SDK base directory (containing common .props and .targets files) is located.

tintoy commented 5 years ago

Some other steps to gather information for troubleshooting:

SimantoR commented 5 years ago

Starting MSBuild language service... MSBuild language service is running. [Info - 8:17:07 PM] Successfully loaded project "c:\Users\SimantoR\Documents\Projects\WorldFactory\VulkanCore.Framework\VulkanCore.Framework.csproj". [Info - 8:17:37 PM] Successfully loaded project "c:\Users\SimantoR\Documents\Projects\WorldFactory\WorldFactory\WorldFactory.csproj" as a sub-project of "VulkanCore.Framework.csproj". [Error - 8:17:47 PM] Failed to provide completions. System.Net.Http.HttpRequestException: Response status code does not indicate success: 404 (Not Found). at HttpResponseMessage System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode() at void NuGet.Protocol.HttpSource+<>c__DisplayClass13_0<T>+<<ProcessStreamAsync>b__0>d.MoveNext() at async Task<T> NuGet.Protocol.HttpSource.ProcessResponseAsync<T>(HttpSourceRequest request, Func<HttpResponseMessage, Task<T>> processAsync, ILogger log, CancellationToken token) at async Task<T> NuGet.Protocol.HttpSource.ProcessStreamAsync<T>(HttpSourceRequest request, Func<Stream, Task<T>> processAsync, ILogger log, CancellationToken token) at async Task<IEnumerable<string>> NuGet.Protocol.AutoCompleteResourceV2Feed.GetResults(Uri apiEndpointUri, ILogger logger, CancellationToken token) at async Task<IEnumerable<string>> NuGet.Protocol.AutoCompleteResourceV2Feed.IdStartsWith(string packageIdPrefix, bool includePrerelease, ILogger log, CancellationToken token) at async Task<SortedSet<string>> MSBuildProjectTools.LanguageServer.Utilities.NuGetHelper.SuggestPackageIds(IEnumerable<AutoCompleteResource> autoCompleteResources, string packageIdPrefix, bool includePrerelease, ILogger logger, CancellationToken cancellationToken) in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Common\Utilities\NuGetHelper.cs:line 142 at async Task<SortedSet<string>> MSBuildProjectTools.LanguageServer.Documents.ProjectDocument.SuggestPackageIds(string packageIdPrefix, bool includePrerelease, CancellationToken cancellationToken) in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\Documents\ProjectDocument.cs:line 381 at async Task<List<CompletionItem>> MSBuildProjectTools.LanguageServer.CompletionProviders.PackageReferenceCompletion.HandlePackageReferenceAttributeCompletion(ProjectDocument projectDocument, XSAttribute attribute, CancellationToken cancellationToken) in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\CompletionProviders\PackageReferenceCompletion.cs:line 155 at async Task<CompletionList> MSBuildProjectTools.LanguageServer.CompletionProviders.PackageReferenceCompletion.ProvideCompletions(XmlLocation location, ProjectDocument projectDocument, CancellationToken cancellationToken) in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\CompletionProviders\PackageReferenceCompletion.cs:line 92 at async Task<CompletionList> MSBuildProjectTools.LanguageServer.Handlers.CompletionHandler.OnCompletion(TextDocumentPositionParams parameters, CancellationToken cancellationToken) in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\Handlers\CompletionHandler.cs:line 197

Thats the output from VSCode

tintoy commented 5 years ago

Ok, it sounds like it can't connect to one or more package feeds specified in NuGet.config (either in the solution directory or in %UserProfile%\AppData\Roaming\NuGet\NuGet.Config). Are you able to open those feed URLs in your browser?

SimantoR commented 5 years ago

Ok so fixed it. Apparently I installed Xenko game engine and xenko pushed some of its feed into the sources. I commented them out and autocomplete is back on track. What a pain from Xenko. Thank you though. Nuget feed was the problem.

tintoy commented 5 years ago

No worries - glad it was easy to fix :)

I'll add some logging so that next time it will explicitly log the set of package sources that it's using.

SimantoR commented 5 years ago

Funnily enough it cant find SixLabors.ImageSharp or any package with x.x.x-betaXXXX version. Just letting you know

tintoy commented 5 years ago

Hi - there is a command called "toggle prerelease" that will make them show up or hide them. Does that not work for you?

SimantoR commented 5 years ago

Not for packages with 'betaXXXX' format in their version. Works fine for 0.X.X versioned packages.

FbxSharp is on v0.9.0 image

SixLabors.ImageSharp is on 1.0.0-beta0005 image

tintoy commented 5 years ago

Can you open the VS Code settings editor, then open the raw settings.json file, and then post all the msbuildProjectTools* settings listed in it?

SimantoR commented 5 years ago

{ "window.titleBarStyle": "custom", "files.exclude": { "**/bin": true, "**/obj": true, "**/www*": true }, "editor.fontFamily": "'Fira Code'", "editor.fontLigatures": true, "editor.fontSize": 16, "editor.scrollBeyondLastLine": false, "zenMode.centerLayout": false, "editor.codeLens": false, "workbench.iconTheme": "material-icon-theme", "editor.minimap.enabled": false, "msbuildProjectTools.nuget.includePreRelease": true, "editor.quickSuggestions": { "other": false, "comments": false, "strings": false }, "git.confirmSync": false, "git.autofetch": true }

tintoy commented 5 years ago

Thanks! I'll try this out when I get home :)

SimantoR commented 5 years ago

I have seen this problem a few months ago too. I didn't know there was a repo I would've reported this then. I love the extension. I hate to come forward issues like this. But I'd love to keep using this as the only solution to multiple features. I have made quite a bit of enhanced csproj build systems that targets multi-OS+multi-framework, using this amazing extension (and that's awesome!). I'd love to see this become a beast.

tintoy commented 5 years ago

No worries - thanks for reporting it! The only way this extension gets better is through users like you :)

I'll let you know as soon as I've worked out what the problem is.

tintoy commented 5 years ago

Ok, so I've looked into this, and it appears to be a bug in the NuGet client library.

The client is supposed to do an HTTP GET from https://api-v2v3search-1.nuget.org/autocomplete?q=SixLabors&prerelease=true, but is instead using https://api-v2v3search-1.nuget.org/autocomplete?q=SixLabors&includePrerelease=true

I'll log an issue with the NuGet folks to see if we can get this resolved.

tintoy commented 5 years ago

Created NuGet/Home#7540.

tintoy commented 5 years ago

I've opened a new issue for the pre-release version problem, so I'm closing this one :)