Closed tintoy closed 2 months ago
We can also have extension points so that Custom Sdks can have their own help files
like for my Sdk I can include <My.Custom.Sdk>\Docs
folder to include my specific props/targets/tasks and for those Sdks that don't have their own Docs folder within their Sdk, We can have one from the Community, into the fallback folder like the one you have for Common props and targets!
I will update those help files in my repo for specific files and my sdk and test them and I'll include a PR later, if you are okay with this idea!
Sure! Might be worth investigating whether there's an "official" way to package help for SDKs too? Or maybe we could add support for parsing XSDs to extract from there?
On Sat, 14 Apr. 2018, 6:02 pm Nirmal Guru, notifications@github.com wrote:
We can also have extension points so that Custom Sdks can have their own help files
like for my Sdk I can include
\Docs folder to include my specific props/targets/tasks and for those Sdks that don't have their own Docs folder within their Sdk, We can have one from the Community, like the one you have for Common props and targets! I will update those help files in my repo for specific files and my sdk and test them and I'll include a PR later, if you are okay with this idea!
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tintoy/msbuild-project-tools-server/issues/5#issuecomment-381311933, or mute the thread https://github.com/notifications/unsubscribe-auth/ABkezIt_DSbzRS7o09OLtXqfAoY2Weboks5toa0qgaJpZM4TU6jq .
The NuGet team proposed having docs along-side lib and ref folder but they killed the feature in-favour of having docs within lib or ref folder!
Now Sdks have becoming a thing I could ask NuGet team to include docs for Sdk packages, I will do that once my PoC works!
CC: @Nirmal4G - the help links are working now; if I can build you a custom .vsix
package would you be willing to try it out and provide feedback?
Yes, I'd be happy too!
I'm already experimenting with help files coming from the SDKs!
@Nirmal4G - here you go:
https://github.com/tintoy/msbuild-project-tools-server/releases/tag/v0.2.34
You'll need to manually uninstall the existing extension and then install this one via the Install from VSIX
menu item in the extension list.
Ok, I installed it and the tools are successfully loading and logging in the window but I'm not getting any intellisense or hover contents!?
Also getting this:
[Error - 12:08:09] Failed to provide completions.
System.ArgumentException: Argument cannot be null, empty, or entirely composed of whitespace: 'itemName'.
Parameter name: itemType
at MSBuildProjectTools.LanguageServer.SemanticModel.MSBuildSchemaHelp.ForItemType(String itemType) in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.SemanticModel.MSBuild\MSBuildSchemaHelp.cs:line 335
at MSBuildProjectTools.LanguageServer.CompletionProviders.ItemMetadataCompletion.<GetElementCompletions>d__5.MoveNext() in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\CompletionProviders\ItemMetadataCompletion.cs:line 231
at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1 enumerable)
at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
at MSBuildProjectTools.LanguageServer.CompletionProviders.ItemMetadataCompletion.<ProvideCompletions>d__3.MoveNext() in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\CompletionProviders\ItemMetadataCompletion.cs:line 73
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at MSBuildProjectTools.LanguageServer.Handlers.CompletionHandler.<OnCompletion>d__27.MoveNext() in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\Handlers\CompletionHandler.cs:line 193
[Error - 12:08:23] Failed to provide completions.
System.ArgumentException: Argument cannot be null, empty, or entirely composed of whitespace: 'itemName'.
Parameter name: itemType
at MSBuildProjectTools.LanguageServer.SemanticModel.MSBuildSchemaHelp.ForItemType(String itemType) in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.SemanticModel.MSBuild\MSBuildSchemaHelp.cs:line 335
at MSBuildProjectTools.LanguageServer.CompletionProviders.ItemMetadataCompletion.<GetElementCompletions>d__5.MoveNext() in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\CompletionProviders\ItemMetadataCompletion.cs:line 231
at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1 enumerable)
at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
at MSBuildProjectTools.LanguageServer.CompletionProviders.ItemMetadataCompletion.<ProvideCompletions>d__3.MoveNext() in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\CompletionProviders\ItemMetadataCompletion.cs:line 73
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at MSBuildProjectTools.LanguageServer.Handlers.CompletionHandler.<OnCompletion>d__27.MoveNext() in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\Handlers\CompletionHandler.cs:line 193
Hmm, that's odd - sorry, roll back to the official release and I'll investigate in the meanwhile.
Are you able to share the project XML where you saw this error?
If not, can you turn the logging up to Verbose
in the extension settings and post the full log when you get that error? From looking at the code, I'm not sure how that error could arise :-/
The project is open source, It's here in the source folder of this MSBuild-Sdks repo!
If not, can you turn the logging up to Verbose in the extension settings
How do I do that?
No worries - if I can open the project file myself you don't need to :)
It's dinner time here in Australia, but I'll have a look at this first thing tomorrow :) Thanks for trying it out so quickly BTW
No problem, I'm working on these projects, anyway!
I can open the project file
Then you need to set env variable MSBuildSdksPath
to point to the Source
folder of the repo to pickup my custom SDKs
@nirmal4G - was the location where you're seeing the error a PropertyGroup
element inside a Target
element (rather than inside the root Project
element by any chance? And does it happen with the currently-released version as well?
(I have a theory but am not at my computer to check right now)
Or the same pattern for an ItemGroup
...
One thing I've realised while looking into this issue is that PropertyGroup
and ItemGroup
elements appearing inside Target
elements are currently not entirely visible to the project system (because they are only evaluated when the target is built).
It's still possible to parse them (but not to evaluate them) if we extend the semantic model (MSBuildObject and its inheritors) to capture the required information from:
Although we'll need to do a bit more work to match them back up to their originating XML elements to get intellisense working because ProjectPropertyGroupTaskInstance
/ ProjectItemGroupTaskInstance
don't expose that information the way ProjectProperty
/ ProjectItem
do.
We can probably get the information we need via Microsoft.Build.Evaluation.Project::Xml
(which is a Microsoft.Build.Construction.ProjectRootElement
) which enables us to scan for all PropertyGroup
/ ItemGroup
XML elements within Target
elements.
One thing we may need to watch for is whether this additional scanning has a performance impact; I'm hoping not, but we'll have to see.
@Nirmal4G - which project file, specifically, were you having problems with? I've tried opening a couple of the files in your project, and I get full intellisense (completions and tooltips-on-hover).
which project file, specifically, were you having problems with?
*.nuproj and custom SDK based (.proj) projects
was the location where you're seeing the error a PropertyGroupelement inside a Target element (rather than inside the root Project element by any chance? And does it happen with the currently-released version as well?
No Target element. Although now that you mention it, the same problem which was happening inside the project root element with SDK attribute defined (with a custom value), is happening inside the target element as well. Nice find!
Thanks, will give it a try in an hour or so
BTW, how are you overriding the msbuild extensions path? Via environment variable?
Oops, you did already say how - sorry only just woke up about 15 mins ago :)
BTW, have you seen this? https://docs.microsoft.com/en-us/visualstudio/msbuild/how-to-use-project-sdk
@Nirmal4G - do you still get those errors if, instead of changing the MSBuildSdksPath
environment variable, you copy those SDK folders into C:\Program Files\dotnet\Sdk\<current-dotnet-sdk-version>
?
BTW, I tried following your instructions above ($env:MSBuildSdksPath = 'D:\Development\github\nirin\msbuild-sdks\Source'
) and then running VS Code and opening your project, but I still can't see any errors when opening (or using intellisense in) any of the files in your project.
Sorry to be a pain, but is there any chance you could list an exact series of steps to replicate the issue? I just want to make sure we're doing exactly the same thing :)
Oh, and while it's not implemented yet, https://github.com/tintoy/msbuild-project-tools-vscode/issues/35#issuecomment-367466192 will make it a lot easier to override the extensions directory.
Sorry to be a pain, but is there any chance you could list an exact series of steps to replicate the issue? I just want to make sure we're doing exactly the same thing
No problem. you are helping me a lot with your extension, It's not at all a PAIN!
You could override User env variables by going to System Properties control panel (that's how I'm doing it) But you have to login and logoff every time you set the path! (Now that's PAIN 😉🤣 )
Open CMD (admin/normal mode - your choice), set the env variable and open code to that directory within that CMD.
Comments related to SDK style project configuration
Since these are not released into public they are not in the NuGet or MyGet for the NuGetSdkReolver
to fetch it from. And I have to use the current state to build/pack them up for testing, that's why I'm overriding the MSBuildSDKsPath
env variable!
Oh, and while it's not implemented yet, https://github.com/tintoy/msbuild-project-tools-vscode/issues/35#issuecomment-367466192 will make it a lot easier to override the extensions directory.
I like that feature. But could we make it generic by having any of the properties and env variables to override?
Correct :)
What about the steps to cause the error? Eg. Open file xxx, go to line a, column button, and hover the mouse pointer over it / type "<foo"...
Column b, that is. Not column button (sorry, autocorrect).
What about the steps to cause the error? Eg. Open file xxx, go to line a, column b, and hover the mouse pointer over it / type "<foo"...
Sorry about that, I thought something else!
Open my custom SDK based project like .nuproj and/or .csproj in TestProjects directory.
Do a hover or ctrl+tab
completion on root project element (put the curser in the middle of the Project
word and ctrl+tab
) You'll see the same error in the log.
(sorry, autocorrect)
FYI You can edit comments on GitHub
If you can't get it, I'll post a GIF tomorrow! Also it's past my curfew, so Good Night from here!
Yeah, I'm on my phone and the mobile UI doesn't support editing comments unfortunately :)
I'll give it a try shortly and let you know what I find tomorrow!
Ah! Ok, I see the problem; the root element has no parent (of course), so that completion provider has issues; I'll fix that shortly.
Ok - I've published a new release (v0.2.36) where that should be fixed (you can download and install the VSIX package manually for now; I haven't published it to the VS Marketplace yet.
Trying it out! It's working, No crashing. But Hover won't work inside those projects
The Current Log:
Starting MSBuild language service...
MSBuild language service is running.
[Info - 12:38:54] Successfully loaded project "N:\MSBuild-Sdks\Source\NuGet.Packaging.Sdk\NuGet.Packaging.Sdk.nuproj".
[Error - 12:43:43] Error loading MSBuild project '"N:\MSBuild-Sdks\Source\NuGet.Packaging.Sdk\Sdk\Sdk.Pack.targets"'.
System.InvalidOperationException: Parent project does not have an MSBuild project.
at bool MSBuildProjectTools.LanguageServer.Documents.SubProjectDocument.TryLoadMSBuildProject() in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\Documents\SubProjectDocument.cs:line 85
[Info - 12:43:43] Successfully loaded project "N:\MSBuild-Sdks\Source\NuGet.Packaging.Sdk\Sdk\Sdk.Pack.targets" as a sub-project of "NuGet.Packaging.Sdk.nuproj".
[Info - 12:50:48] Unloaded project "N:\MSBuild-Sdks\Source\NuGet.Packaging.Sdk\Sdk\Sdk.Pack.targets".
[Error - 12:50:48] Error loading MSBuild project '"N:\MSBuild-Sdks\Source\MSBuild.NET.Extras.Sdk\Build\MSBuild.NET.Extras.Items.props"'.
System.InvalidOperationException: Parent project does not have an MSBuild project.
at bool MSBuildProjectTools.LanguageServer.Documents.SubProjectDocument.TryLoadMSBuildProject() in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\Documents\SubProjectDocument.cs:line 85
[Info - 12:50:48] Successfully loaded project "N:\MSBuild-Sdks\Source\MSBuild.NET.Extras.Sdk\Build\MSBuild.NET.Extras.Items.props" as a sub-project of "NuGet.Packaging.Sdk.nuproj".
[Error - 12:52:44] Error loading MSBuild project '"N:\MSBuild-Sdks\Source\MSBuild.NET.Extras.Sdk\Build\MSBuild.NET.Extras.Items.props"'.
System.InvalidOperationException: Parent project does not have an MSBuild project.
at bool MSBuildProjectTools.LanguageServer.Documents.SubProjectDocument.TryLoadMSBuildProject() in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\Documents\SubProjectDocument.cs:line 85
[Error - 12:52:45] Error loading MSBuild project '"N:\MSBuild-Sdks\Source\MSBuild.NET.Extras.Sdk\Build\MSBuild.NET.Extras.Items.props"'.
System.InvalidOperationException: Parent project does not have an MSBuild project.
at bool MSBuildProjectTools.LanguageServer.Documents.SubProjectDocument.TryLoadMSBuildProject() in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\Documents\SubProjectDocument.cs:line 85
[Error - 12:52:46] Error loading MSBuild project '"N:\MSBuild-Sdks\Source\MSBuild.NET.Extras.Sdk\Build\MSBuild.NET.Extras.Items.props"'.
System.InvalidOperationException: Parent project does not have an MSBuild project.
at bool MSBuildProjectTools.LanguageServer.Documents.SubProjectDocument.TryLoadMSBuildProject() in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\Documents\SubProjectDocument.cs:line 85
[Error - 12:52:47] Error loading MSBuild project '"N:\MSBuild-Sdks\Source\MSBuild.NET.Extras.Sdk\Build\MSBuild.NET.Extras.Items.props"'.
System.InvalidOperationException: Parent project does not have an MSBuild project.
at bool MSBuildProjectTools.LanguageServer.Documents.SubProjectDocument.TryLoadMSBuildProject() in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\Documents\SubProjectDocument.cs:line 85
[Error - 12:52:54] Error loading MSBuild project '"N:\MSBuild-Sdks\Source\MSBuild.NET.Extras.Sdk\Build\MSBuild.NET.Extras.Items.props"'.
System.InvalidOperationException: Parent project does not have an MSBuild project.
at bool MSBuildProjectTools.LanguageServer.Documents.SubProjectDocument.TryLoadMSBuildProject() in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\Documents\SubProjectDocument.cs:line 85
[Error - 12:52:55] Error loading MSBuild project '"N:\MSBuild-Sdks\Source\MSBuild.NET.Extras.Sdk\Build\MSBuild.NET.Extras.Items.props"'.
System.InvalidOperationException: Parent project does not have an MSBuild project.
at bool MSBuildProjectTools.LanguageServer.Documents.SubProjectDocument.TryLoadMSBuildProject() in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\Documents\SubProjectDocument.cs:line 85
Hmm, that's interesting; it says it successfully loaded the first project (which is the "parent" referred to in the following errors), but subsequent project loads fail because they can't be matched up to the parent project (because although its XML could be parsed, the MSBuild engine failed to correctly load that XML).
Can you try closing all projects and then opening one of the projects that fails? Does that work for you?
Ok, I turned on verbose logging, and MSBuild can't load the .nuproj
:
Failed to load MSBuild proiect '"d:\Development\github\nirin\msbuild-sdks\Source\NuGet.Packaging.Sdk\NuGet.Packaging.Sdk.nuproj"' because the project file is invalid. "The SDK 'NuGet.Packaging.Sdk' specified could not be found. d:\Development\github\nirin\msbuild-sdks\Source\NuGet.Packaging.Sdk\NuGet.Packaging.Sdk.nuproj"
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'NuGet.Packaging.Sdk' specified could not be found. d:\Development\github\nirin\msbuild-sdks\Source\NuGet.Packaging.Sdk\NuGet.Packaging.Sdk.nuproj
at void Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(string errorSubCategoryResourceName, IElementLocation elementLocation, string resourceName, object[] args) in E:\A\_work\17\s\src\Shared\ProjectErrorUtilities.cs:line 440
at void Microsoft.Build.Evaluation.Evaluator<P, I, M, D>.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(string directoryOfImportingFile, ProjectImportElement importElement, out List<ProjectRootElement> projects, bool throwOnFileNotExistsError) in E:\A\_work\17\s\src\Build\Evaluation\Evaluator.cs:line 2412
at List<ProjectRootElement> Microsoft.Build.Evaluation.Evaluator<P, I, M, D>.ExpandAndLoadImports(string directoryOfImportingFile, ProjectImportElement importElement) in E:\A\_work\17\s\src\Build\Evaluation\Evaluator.cs:line 2215
at void Microsoft.Build.Evaluation.Evaluator<P, I, M, D>.EvaluateImportElement(string directoryOfImportingFile, ProjectImportElement importElement) in E:\A\_work\17\s\src\Build\Evaluation\Evaluator.cs:line 2070
at void Microsoft.Build.Evaluation.Evaluator<P, I, M, D>.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport) in E:\A\_work\17\s\src\Build\Evaluation\Evaluator.cs:line 1006
at IDictionary<string, object> Microsoft.Build.Evaluation.Evaluator<P, I, M, D>.Evaluate(ILoggingService loggingService, BuildEventContext buildEventContext) in E:\A\_work\17\s\src\Build\Evaluation\Evaluator.cs:line 794
at void Microsoft.Build.Evaluation.Project.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings) in E:\A\_work\17\s\src\Build\Definition\Project.cs:line 2641
at void Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings) in E:\A\_work\17\s\src\Build\Definition\Project.cs:line 2634
at void Microsoft.Build.Evaluation.Project.Initialize(IDictionary<string, string> globalProperties, string toolsVersion, string subToolsetVersion, ProjectLoadSettings loadSettings) in E:\A\_work\17\s\src\Build\Definition\Project.cs:line 2711
at new Microsoft.Build.Evaluation.Project(string projectFile, IDictionary<string, string> globalProperties, string toolsVersion, string subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings) in E:\A\_work\17\s\src\Build\Definition\Project.cs:line 512
at Project Microsoft.Build.Evaluation.ProjectCollection.LoadProject(string fileName, IDictionary<string, string> globalProperties, string toolsVersion) in E:\A\_work\17\s\src\Build\Definition\ProjectCollection.cs:line 1122
at bool MSBuildProjectTools.LanguageServer.Documents.MasterProjectDocument.TryLoadMSBuildProject() in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\Documents\MasterProjectDocument.cs:line 168
Looks like MSBuild is failing to resolve the custom SDK (so the project won't load).
BTW, here's how you turn on verbose logging:
(you only need to specify logging level, you can leave any other settings at their default values)
Ok - the language service wasn't respecting any existing value for the MSBuildSdksPath
environment variable. I'll put out a new release shortly that supports this.
Later, this hot-fix will be replaced by the functionality from tintoy/msbuild-project-tools-server#6.
Thanks, I'll follow it up.
Update: YAY! It is ALIVE!!! So far no issues.
Includes elements such as
Import
,ItemGroup
,PropertyGroup
, etc. Also includes well-known tasks.Relates to tintoy/msbuild-project-tools-server#4