Git Product home page Git Product logo

msbuild-project-tools-server's Introduction

MSBuild project file tools

An LSP-compatible language service that provides intellisense for MSBuild project files, including auto-complete for <PackageReference> elements.

For more information, see msbuild-project-tools-vscode.

Building from source

See BUILDING.md.

Design

See architectural overview for details (this is a work-in-progress; if you have questions, feel free to create an issue).

Limitations

  • Limited intellisense is available for dynamic PropertyGroup / ItemGroup declarations (i.e. those appearing inside a Target element); these are only evaluated when the project is built and so very little information about them is available to us when statically evaluating the project (see tintoy/msbuild-project-tools-server#5 for details).
  • Support for task completions is experimental; if you find a problem with it, please create an issue.
  • Support for MSBuild expressions is experimental; if you find a problem with it, please create an issue.
  • If you open more than one project at a time (or navigate to imported projects), subsequent projects will be loaded into the same MSBuild project collection as the first project. Once you have closed the last project file, the next project file you open will become the master project. The master project will become selectable in a later release.

Questions / bug reports

If you have questions, feedback, feature requests, or would like to report a bug, please feel free to reach out by creating an issue. When reporting a bug, please try to include as much information as possible about what you were doing at the time, what you expected to happen, and what actually happened.

If you're interested in collaborating that'd be great, too :-)

msbuild-project-tools-server's People

Contributors

doctorkrolic avatar inosik avatar itn3000 avatar nyrest avatar rudyschockaert-engieit avatar tintoy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

msbuild-project-tools-server's Issues

Reconsider usage of enviroment variables

The main idea of a language server protocol is to provide intellisense in as client-independent way as possible. In practice, however, language servers do often contain client-dependent elements. One of such cases is using enviroment variables. I'm not saying here, that we should get rid of them all together. Even official C# extension from MS uses enviroment variables for configuring some aspects of a language server. However, it's in our interest to maintain this LSP as client-independent as possible, so it can be used outside of our own VS Code extension (see #33). Thus, IMO, we should reconsider usage of enviroment variables and avoid them as much as possible. Ideally, enviroment variables should only be used to configure options, that must be present on server startup.

For instance, we use MSBUILD_PROJECT_TOOLS_DIR variable as a base path task cache storage. Why do we need it if we can just use relative path for that?

Another example is MSBUILD_PROJECT_TOOLS_VERBOSE_LOGGING. Do we really need to know this information on server startup or we can use standard configuration endpoint? I think the latter is sufficient for our needs.

In the end, we should question every variable we use with this model of thinking. Those variables, that can be avoided, should be deleted

Settings are verbose

Whether I change one setting or ten, msbuildProjectTools seems to always inject the full settings in VS Code. even those I didn't modify.

untitled

BTW... What a great extension. Can't life wihtou it.

Microsoft.WebApplication.targets was not found

Can't build .csproj file due to the following error:

[project.csproj] The imported project "c:\Users\myuser.vscode\extensions\tintoy.msbuild-project-tools-0.2.39\out\language-server\Microsoft\VisualStudio\v12.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

Failing line:

<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />

"Unexpected error loading file <pathTo>.csproj" : "Could not load file or assembly" : 8.0 Preview

This issue has me completely vexxed...
I had copied the 8.0 preview sdk files to my dotnet folder /opt/dotnet/, and saw this extension no longer giving me autocompletion.
For a sanity-check, I:

  1. Installed vscode-insiders (instead of vscode-oss) (still failed)
  2. Futzed with the permissions which should've been fine (though I learned chmod using o+rX or o=rX would set 'x' permission on files too if 'u' also had 'x') (still failed)
  3. Moved the dotnet folder and replaced it with only the 8.0 preview (instead of 6.0, 7.0, 8.0 preview) (this worked)
  4. Copying 7.0 and 8.0 preview back in (still failed)
  5. Rm'ing all 7.0 related files ($ find /opt/dotnet -name "*7.0*") from the dotnet path (but NOT removing 7.0 references found in the 8.0 sdk) (this worked)

So it's like there's some conflict having 7.0 and 8.0 sdks together which makes no sense.

MSBuild Language Server
Failing:

Result was "System.Threading.Tasks.Task`1[[OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeResult, OmniSharp.Extensions.LanguageProtocol, Version=0.7.9.0, Culture=neutral, PublicKeyToken=null]]"
Response value was "OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeResult"
Finished: Routing Request (0) "initialize" in 39ms
Finding descriptor for "initialized"
Finding descriptor for "workspace/didChangeConfiguration"
Starting: Routing Notification "initialized"
Finished: Routing Notification "initialized" in 8ms
Starting: Routing Notification "workspace/didChangeConfiguration"
Converting params for Notification "workspace/didChangeConfiguration" to "MSBuildProjectTools.LanguageServer.CustomProtocol.DidChangeConfigurationObjectParams"
Finished: Routing Notification "workspace/didChangeConfiguration" in 56ms
Finding descriptor for "textDocument/didOpen"
Created attribute "xml::file:///<pathTo>.csproj"
Looking for handler for method ["OmniSharp.Extensions.LanguageServer.Server.HandlerDescriptor"]
Checking handler ["OmniSharp.Extensions.LanguageServer.Server.HandlerDescriptor"]:"MSBuildProjectTools.LanguageServer.Handlers.DocumentSyncHandler"
Registration options "OmniSharp.Extensions.LanguageServer.Protocol.Models.TextDocumentRegistrationOptions"
Document Selector "[msbuild, file, **/*.*], [xml, file, **/*.*proj], [xml, file, **/*.props], [xml, file, **/*.targets]"
Starting: Routing Notification "textDocument/didOpen"
Converting params for Notification "textDocument/didOpen" to "OmniSharp.Extensions.LanguageServer.Protocol.Models.DidOpenTextDocumentParams"
[Info  - 5:48:52 PM] Using MSBuild engine v8.0.100 from "/opt/dotnet/sdk/8.0.100-preview.7.23376.3/".
Language server initialised by client.
Finding descriptor for "textDocument/documentSymbol"
Found attributes 1, ["msbuild::file:///<pathTo>.csproj"]
Looking for handler for method ["OmniSharp.Extensions.LanguageServer.Server.HandlerDescriptor"]
Checking handler ["OmniSharp.Extensions.LanguageServer.Server.HandlerDescriptor"]:"MSBuildProjectTools.LanguageServer.Handlers.DocumentSymbolHandler"
Registration options "OmniSharp.Extensions.LanguageServer.Protocol.Models.TextDocumentRegistrationOptions"
Document Selector "[msbuild, file, **/*.*], [xml, file, **/*.*proj], [xml, file, **/*.props], [xml, file, **/*.targets]"
[Error - 5:48:52 PM] Unexpected error loading file "/<pathTo>.csproj".
System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

File name: 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at async Task MSBuildProjectTools.LanguageServer.Documents.ProjectDocument.Load(CancellationToken cancellationToken)
   at void System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<TStateMachine>(ref TStateMachine stateMachine)
   at Task MSBuildProjectTools.LanguageServer.Documents.ProjectDocument.Load(CancellationToken cancellationToken)
   at Task MSBuildProjectTools.LanguageServer.Documents.MasterProjectDocument.<>n__0(?)
   at async Task MSBuildProjectTools.LanguageServer.Documents.MasterProjectDocument.Load(CancellationToken cancellationToken) in /<pathTo>/D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\Documents\MasterProjectDocument.cs:line 131
   at async Task<ProjectDocument> MSBuildProjectTools.LanguageServer.Documents.Workspace.GetProjectDocument(Uri documentUri, bool reload) in /<pathTo>/D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\Documents\Workspace.cs:line 226

Working:

Result was "System.Threading.Tasks.Task`1[[OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeResult, OmniSharp.Extensions.LanguageProtocol, Version=0.7.9.0, Culture=neutral, PublicKeyToken=null]]"
Response value was "OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeResult"
Finished: Routing Request (0) "initialize" in 38ms
Finding descriptor for "initialized"
Finding descriptor for "workspace/didChangeConfiguration"
Starting: Routing Notification "initialized"
Finished: Routing Notification "initialized" in 3ms
Starting: Routing Notification "workspace/didChangeConfiguration"
Converting params for Notification "workspace/didChangeConfiguration" to "MSBuildProjectTools.LanguageServer.CustomProtocol.DidChangeConfigurationObjectParams"
Finished: Routing Notification "workspace/didChangeConfiguration" in 42ms
Finding descriptor for "textDocument/didOpen"
Created attribute "xml::file:///<pathTo>.csproj"
Looking for handler for method ["OmniSharp.Extensions.LanguageServer.Server.HandlerDescriptor"]
Checking handler ["OmniSharp.Extensions.LanguageServer.Server.HandlerDescriptor"]:"MSBuildProjectTools.LanguageServer.Handlers.DocumentSyncHandler"
Registration options "OmniSharp.Extensions.LanguageServer.Protocol.Models.TextDocumentRegistrationOptions"
Document Selector "[msbuild, file, **/*.*], [xml, file, **/*.*proj], [xml, file, **/*.props], [xml, file, **/*.targets]"
Starting: Routing Notification "textDocument/didOpen"
Converting params for Notification "textDocument/didOpen" to "OmniSharp.Extensions.LanguageServer.Protocol.Models.DidOpenTextDocumentParams"
Language server initialised by client.
Finding descriptor for "textDocument/documentSymbol"
[Info  - 6:10:36 PM] Using MSBuild engine v8.0.100 from "/opt/dotnet/sdk/8.0.100-preview.7.23376.3/".
Found attributes 1, ["msbuild::file:///<pathTo>.csproj"]
Looking for handler for method ["OmniSharp.Extensions.LanguageServer.Server.HandlerDescriptor"]
Checking handler ["OmniSharp.Extensions.LanguageServer.Server.HandlerDescriptor"]:"MSBuildProjectTools.LanguageServer.Handlers.DocumentSymbolHandler"
Registration options "OmniSharp.Extensions.LanguageServer.Protocol.Models.TextDocumentRegistrationOptions"
Document Selector "[msbuild, file, **/*.*], [xml, file, **/*.*proj], [xml, file, **/*.props], [xml, file, **/*.targets]"
[Info  - 6:10:38 PM] 1 package sources configured for project "/<pathTo>.csproj".
[Info  - 6:10:38 PM]   Locally-configured package source "nuget.org" (v3) => https://api.nuget.org/v3/index.json

Enable support for MSBuild Authoring projects

I'm doing a lot of MSBuild Sdk projects, I was using Qub's MSBuild Tools when I was first beginning to use VSCode, and then I found your's after some time. I was using them both until now.

Here are few feature suggestions for your extension that relates to language server:

1. For Conditions, Please show the detailed Evaluated result.

E.g:

<Individual Properties/Expression>: <value>
Evaluated: <Evaluated Exp>
Result: <true/false>

2. Let us set a context project to which against the props/targets for both Sdk-style and regular projects will be Evaluated!

E.g: When working on set of targets/props either separately or through Sdk pattern, the opened props/targets are evaluated as if they are used directly so, most of the properties would turn up empty or undefined which leads to serious Item issue, where a code fragment like this one:

https://github.com/nirin/msbuild-sdks/blob/feature/sdks/Source/MSBuild.NET.Extras.Sdk/Build/MSBuild.NET.Extras.Items.props#L39-L55

3. Qub's tools link docs to the known MSBuild xml element and attributes, so if possible please add this feature too!

P.S.: I'm willing to help, but I'm new at MSBuild, right now I'm learning MSBuild authoring so that I can use it in my own projects. Yours and Qub's extension really helped me a lot!

Delay publishing of diagnostics while a completion is in progress

When inserting an element (e.g. user types <), the project file contents become invalid XML and so a diagnostic is published indicating the location of the error. This makes the UX a bit unpleasant because the focus of their attention is the element being inserted and this element is underlined with red squiggles.

If possible, find a way to detect start / end of completion activity (from memory, LSP has the ability to make completions as requiring a separate "resolve" step which might suit our purposes) and then publish diagnostic(s) once the completion activity has ended.

Completion doesn't work in Neovim

Hello! Thank you for your awesome project! I'm trying to use it on neovim. For the most part, everything works out of the box... other than completion.

Completion won't work for any well-known tasks/properties or any imports. I see some errors about the plugin ignoring my repositories from work because they don't support the NuGet V3 API, but no other logs, even when I run on Debug log level. I'll keep messing with the server and update here if I figure things out. I'm guessing there might be some other pipe over which the server is sending completion information.

Error on system with 3.1 and 5

I'm trying to use this on a system with .NET5, but I saw that this isn't supported. So I installed the 3.1 runtime.

Now the extension loads, but I get an error:

Error loading MSBuild project '"/foo/bar/myproject/src/Directory.Build.props"'.
System.IO.FileNotFoundException: Could not load file or assembly 'System.Collections.Immutable, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

There is no problem with my config, as it works when I use dotnet build, dotnet run, etc.

What could this be?

Upgrade to .NET 5.0

5.0 is not an LTS release, but the MSBuild / .NET SDK treadmill is kinda forcing my hand here :-)

Continues the work from #20.

Enhanced functionally for Central Package Management (ie PackageVersion)

Some enhancements to the work started in #84:

  • Only offer PackageVersion element completion if the MSBuild project's ManagePackageVersionsCentrally property is set to true (or True).
  • Consider also hiding Version attribute completion on PackageReference elements if ManagePackageVersionsCentrally is set (might want to make this configurable though, if we choose to do it at all).
  • Rename HandlePackageReferenceElementCompletion and HandlePackageReferenceAttributeCompletion to HandleElementCompletion and HandleAttributeCompletion since the handler now deals with multiple item types.

[Feature] Add support for `nuspec` files

Hey! Awesome job on making a language server for msbuild! I have no clue why this isn't just part of .NET...

I was wondering if you would be interested in adding file support for raw nuspec files. Most of the functionality works just by including the schema (xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd") but there are some features that I would love:

Support for overriding MSBuild global properties

Extend the configuration schema to support specifying overrides for MSBuild global properties:

{
  "msbuildProjectTools": {
    "msbuild": {
      "globalProperties": [
        {
          "name": "MSBuildSdksPath",
          "value": "C:\\Foo\\Bar"
        },
        {
          "name": "AnotherProperty",
          "value": "HelloWorld"
        }
      ]
    }
   }
}

If these properties conflict with any existing definitions that would otherwise be supplied by the language service, then these properties will win.

Relates to tintoy/msbuild-project-tools-vscode#35 and Relates to #5

Are the language server nuget packages published publicly?

Hey there, I was thinking about trying to make a Visual Studio 2022 LSP extension for this project since our team uses VS as well as VS Code. I was wondering if there is a public nuget feed where you publish the packages? I noticed that they get published to https://ci.appveyor.com/nuget/tintoy but that appears to be a private/protected feed.

Thanks! :)

System.IO.FileNotFoundException: Could not load file or assembly 'System.Collections.Immutable, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

Using VS Code examples from C#9 and .NET 5 book. After installing MSBuild project tools 0.3.11, I get the following error and setup. Any ideas what might be causing the error? I'm new, so let me know if I need to provide additional details. Thanks.

PS C:\Users\jmurphy\Documents\VSCode\PracticalApps\NorthwindEntitiesLib> dotnet --list-sdks
5.0.102 [C:\Program Files\dotnet\sdk]
PS C:\Users\jmurphy\Documents\VSCode\PracticalApps\NorthwindEntitiesLib> dotnet --list-runtimes
Microsoft.AspNetCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
PS C:\Users\jmurphy\Documents\VSCode\PracticalApps\NorthwindEntitiesLib>

[Info - 2:29:04 PM] 1 package sources configured for project "c:\Users\jmurphy\Documents\VSCode\PracticalApps\NorthwindContextLib\NorthwindContextLib.csproj".
[Info - 2:29:04 PM] Locally-configured package source "nuget.org" (v3) => https://api.nuget.org/v3/index.json
[Error - 2:29:04 PM] Error loading MSBuild project '"c:\Users\jmurphy\Documents\VSCode\PracticalApps\NorthwindContextLib\NorthwindContextLib.csproj"'.
System.IO.FileNotFoundException: Could not load file or assembly 'System.Collections.Immutable, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Collections.Immutable, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at new Microsoft.Build.Evaluation.Context.EvaluationContext(SharingPolicy policy, IFileSystem fileSystem)
at EvaluationContext Microsoft.Build.Evaluation.Context.EvaluationContext.Create(SharingPolicy policy, MSBuildFileSystemBase fileSystem)
at void Microsoft.Build.Evaluation.Project+ProjectImpl.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at void Microsoft.Build.Evaluation.Project+ProjectImpl.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at void Microsoft.Build.Evaluation.Project+ProjectImpl.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, EvaluationContext evaluationContext)
at void Microsoft.Build.Evaluation.Project+ProjectImpl.ReevaluateIfNecessary(EvaluationContext evaluationContext)
at void Microsoft.Build.Evaluation.Project+ProjectImpl.Initialize(IDictionary<string, string> globalProperties, string toolsVersion, string subToolsetVersion, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at new Microsoft.Build.Evaluation.Project(string projectFile, IDictionary<string, string> globalProperties, string toolsVersion, string subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at Project Microsoft.Build.Evaluation.ProjectCollection.LoadProject(string fileName, IDictionary<string, string> globalProperties, string toolsVersion)
at Project Microsoft.Build.Evaluation.ProjectCollection.LoadProject(string fileName, string toolsVersion)
at Project Microsoft.Build.Evaluation.ProjectCollection.LoadProject(string fileName)
at bool MSBuildProjectTools.LanguageServer.Documents.MasterProjectDocument.TryLoadMSBuildProject() in C:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\Documents\MasterProjectDocument.cs:line 173

[Info - 2:32:02 PM] 1 package sources configured for project "c:\Users\jmurphy\Documents\VSCode\PracticalApps\NorthwindEntitiesLib\NorthwindEntitiesLib.csproj".
[Info - 2:32:02 PM] Locally-configured package source "nuget.org" (v3) => https://api.nuget.org/v3/index.json
[Error - 2:32:02 PM] Error loading MSBuild project '"c:\Users\jmurphy\Documents\VSCode\PracticalApps\NorthwindEntitiesLib\NorthwindEntitiesLib.csproj"'.
System.InvalidOperationException: Parent project does not have an MSBuild project.
at bool MSBuildProjectTools.LanguageServer.Documents.SubProjectDocument.TryLoadMSBuildProject() in C:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\Documents\SubProjectDocument.cs:line 86

Upgrade to .NET Core 3.0

Now that 3.0 is out, we should upgrade the language server to target netcoreapp3.0.

This means consumers will need either the 3.0 SDK or the 3.0 runtime if they donโ€™t want to upgrade to the 3.0 SDK yet.

May need to be careful about verifying that this doesnโ€™t affect behaviour of the MSBuild engine at runtime.

MSBuild SDK 2.2.x location path incorrect

This is basically just a reappearance of the bug from msbuild-project-tools-vscode#46 but since I don't have 3.x installed, it might be a little different.


Opening a .csproj file on Fedora 29 with .NET Core 2.2.203 installed results in a syntax error being reported in the csproj with the following message:

The imported project "/usr/share/dotnet/sdk/2.2.203/15.0/Microsoft.Common.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. /tmp/test/test.csproj(MSB4019)

At least on my machine, the Microsoft.Common.props file is actually in /usr/share/dotnet/sdk/2.2.203/Current/Microsoft.Common.props rather than the 15.0 the extension looks for in any version below 3.x.

Is this perhaps a change in 2.2.x?


I just tried a fresh .NET Core 2.2.203 install into an Ubuntu 18.10 container and it was also installed into /usr/share/dotnet/sdk/2.2.203/Current, not 15.0.

I'm guessing this is a change in 2.2.x, but I don't have a Windows machine handy to check.

Let me know if you need more info or testing.

Cannot redefine/reassign a property in the same file

System.ArgumentException: An item with the same key has already been added.
System.InvalidOperationException: Parent project does not have an MSBuild project.

My ZipPublishDir Target defines a Destination property. Then it conditionally appends to the value.

<RepoRoot>$([System.IO.Path]::GetDirectoryName($([MSBuild]::GetPathOfFileAbove('.gitignore', '$(MSBuildProjectDirectory)'))))</RepoRoot>
<Destination>$(RepoRoot)/publish/$(AssemblyName).$(Version)$(PART_RuntimeIdentifier)</Destination>
<Destination Condition="'$(RuntimeIdentifier)' != '' ">$(Destination).$(RuntimeIdentifier)</Destination>

MSBuild reassigns the value to the existing propertyโ€“or redefines itโ€“as expected.
msbuild-project-tools-server cannot handle reassignments. Instead, it throws System.ArgumentException. Consequently, it cannot load any project importing a file containing this usage.

When adding a key that already exists, msbuild-project-tools-server should

  • A: Assign the new key's value to the existing key. All instances of that property will have the same evaluated value.
  • B: Keep both, but rename duplicates in the order they're discovered. This allows all instances to evaluate to independent values e.g. if the first definition is Destination, then the second definition's key would be Destination>1 and so on.
    • The use of the > character should prevent naming collisions. It cannot be used in a property nameโ€”even as &gt;.

error caused by ZipPublishDir

[Error - 5:23:01 AM] Unhandled exception in OnHover.
System.ArgumentException: An item with the same key has already been added. Key: file:///c%3A/Repos/BinToss/GroupBox.Avalonia/node_modules/%40halospv3/hce.shared-config/dotnet/ZipPublishDir.targets
   at bool System.Collections.Generic.Dictionary<TKey, TValue>.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at Task<ProjectDocument> MSBuildProjectTools.LanguageServer.Documents.Workspace.GetProjectDocument(Uri documentUri, bool reload)+(Uri _) => { }
   at async Task<ProjectDocument> MSBuildProjectTools.LanguageServer.Documents.Workspace.GetProjectDocument(Uri documentUri, bool reload)
   at async Task<Hover> MSBuildProjectTools.LanguageServer.Handlers.HoverHandler.OnHover(TextDocumentPositionParams parameters, CancellationToken cancellationToken)
   at async Task<Hover> MSBuildProjectTools.LanguageServer.Handlers.HoverHandler.OmniSharp.Extensions.JsonRpc.IRequestHandler<OmniSharp.Extensions.LanguageServer.Protocol.Models.TextDocumentPositionParams,OmniSharp.Extensions.LanguageServer.Protocol.Models.Hover>.Handle(?)

ZipPublishDir

<Project>
  <!-- https://learn.microsoft.com/en-us/visualstudio/msbuild/zipdirectory-task?view=vs-2022 -->
  <Target Name="ZipPublishDir" AfterTargets="Publish">
    <PropertyGroup>
      <RepoRoot>$([System.IO.Path]::GetDirectoryName($([MSBuild]::GetPathOfFileAbove('.gitignore', '$(MSBuildProjectDirectory)'))))</RepoRoot>
      <Destination>$(RepoRoot)/publish/$(AssemblyName).$(Version)$(PART_RuntimeIdentifier)</Destination>
      <Destination Condition="'$(RuntimeIdentifier)' != '' ">$(Destination).$(RuntimeIdentifier)</Destination>
    </PropertyGroup>

    <ZipDirectory
      SourceDirectory="$(PublishDir)"
      DestinationFile="$(Destination).zip"
      Overwrite="true" />
  </Target>
</Project>

error in project importing ZipPublishDir

[Error - 5:36:55 AM] Error loading MSBuild project '"c:\Repos\BinToss\GroupBox.Avalonia\GroupBox.Avalonia.Sample\GroupBox.Avalonia.Sample.csproj"'.
System.InvalidOperationException: Parent project does not have an MSBuild project.
   at bool MSBuildProjectTools.LanguageServer.Documents.SubProjectDocument.TryLoadMSBuildProject()
[Warn  - 5:36:55 AM] Reloaded project file "c:\Repos\BinToss\GroupBox.Avalonia\GroupBox.Avalonia.Sample\GroupBox.Avalonia.Sample.csproj" (XML is valid, but MSBuild project is not).

Package URL in PackageReference hover tooltip can be incorrect if the version is not a simple version

Hi there.

Given <PackageReference Include="AngleSharp" Version="[0.9.11]" />, when I click on "NuGet Package: AngleSharp" link, I get error 404 because it includes square brackets in the URL.

Offending code here:

return new MarkedStringContainer(
$"NuGet Package: [{itemGroup.FirstInclude}](https://nuget.org/packages/{itemGroup.FirstInclude}/{packageVersion})",
$"Version: {packageVersion}"
);

Add completion for all well-known properties

Add completion for well-known properties in project items.
Documentation

Missing

  • GlobalPropertiesToRemove
  • SetConfiguration
  • SetPlatform
  • SetTargetFramework
  • SkipGetTargetFrameworkProperties

Because ProjectReference transforms to Reference also missing

  • HintPath
  • FusionName
  • Aliases
  • Private

image

Probably there's other properties that should be inspected

TaskReflection can be just a library

Currently TaksReflection is a separate standalone app, meaning that to get information from it it should be launched via Process class, its output is encoded (in this case as json) and the receiving side must properly decode it. I don't quite get why all this should even happen. We can just make TaskReflection just yet another library and get results directly from it without all this complication and overhead

Report document symbols in a tree view manner

As of now, document symbols are reported as flat array, e.g. for this .csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net7.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <LangVersion>preview</LangVersion>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0-1.final" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.7" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.7" />
  </ItemGroup>

</Project>

... reported symbols look like this:
Code_0QHbtD15dA

However, given the tree-like nature of xml and the fact, that LSP protocol supports tree-like symbol structure, it would make a lot more sence to report symbols as following:

Microsoft.NET.Sdk
-- PropertyGroup
---- OutputType
---- TargetFramework
---- ImplicitUsings
---- Nullable
---- LangVersion
---- AllowUnsafeBlocks
-- ItemGroup
---- PackageReference
---- PackageReference
---- PackageReference

Here not only tree structure is implemented, but also this tree represents document structure in a better way by including syntax elements like PropertyGroup or ItemGroup into it

We don't need documentation mode to be on

This line enables "documentation mode" for our source folder:

<GenerateDocumentationFile>true</GenerateDocumentationFile>

This means that C# warns on every undocumented public member of any type in our main codebase. While I agree that this can be helpful for library authors I am very much against that thing in our case since this language server is not a library, but a standalone app. If something is unclear we can always go-to-def, search symbol or use other IDE feature, all of which is not directly available when you reference a library in your project (and this is where docs come in handy. You cannot see how e.g. a parameter is used in external code, but you have a little doc, explaining what it is for). At the same time keeping this docs at least partially sane is a maintance burden and in many cases thy end up being either totally unuseful, e.g. "a logger is a logger" or "a cancellation token can be used to cancel the operation", "Main is a program entry point" and so on. At the same time these docs take vertical space, so whenever I have some code opened ~50% of my screen space is just filled with docs, which, as I showed above, are not that much useful.
So in the end I think we should remove this forcing of documentation and clean up the codebase from most of the docs. This doesn't mean that I want to remove all code comments entirely, ofc. if something is not straight obvious we might need to add a comment or doc, but this should happen only when necessary, so if I see a doc comment I know this is something important and not just a bloatware, which is here only because the compiler forces to do so

Legacy .csproj files always show "Invalid static method invocation syntax" error

I am always seeing this error when looking at "older" .csproj files (those not using the new structure that includes <PackageReference>s.

Invalid static method invocation syntax: "[Microsoft.Build.Utilities.ToolLocationHelper]::GetPathToStandardLibraries($(TargetFrameworkIdentifier), $(TargetFrameworkVersion), $(TargetFrameworkProfile), $(PlatformTarget), $(TargetFrameworkRootPath), $(TargetFrameworkFallbackSearchPaths))". Microsoft.Build.Utilities.ToolLocationHelper.GetPathToStandardLibraries Static method invocation should be of the form: $([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(a, b)).c:\repo\master\FileSystem\FileSystem.csproj(MSB4186)

Here is an example .csproj file that generates the issue:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
    <ProjectGuid>{636A7C3E-8D20-4696-A641-1F5180F0440C}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>FileSystem</RootNamespace>
    <AssemblyName>FileSystem</AssemblyName>
    <TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <TargetFrameworkProfile />
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\x86\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
    <OutputPath>bin\x86\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <Optimize>true</Optimize>
    <DebugType>pdbonly</DebugType>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
      <HintPath>..\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
    </Reference>
    <Reference Include="PresentationCore" />
    <Reference Include="System" />
    <Reference Include="System.Configuration" />
    <Reference Include="System.Core" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Management" />
    <Reference Include="System.Web" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Xml" />
    <Reference Include="WindowsBase" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="DirectoryUtilility.cs" />
    <Compile Include="FileSystemUtility.cs" />
    <Compile Include="NativeMethods.cs" />
    <Compile Include="GroupedProcessUtility.cs" />
    <Compile Include="ImageUtility.cs" />
    <Compile Include="PathConfigurations.cs" />
    <Compile Include="PathConfigurationsSection.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Compile Include="UncHelper.cs" />
    <Compile Include="VideoUtility.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="packages.config" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

I haven't been able to identify the root cause (I'm unfamiliar with the ToolLocationHelper).

Am I missing an upgrade or dependency somewhere?

I have the following installed:

  • Visual Studio 2017 Enterprise 15.9.7
  • Visual Studio 2019 Enterprise 16.0.0 Preview 2.1
  • Visual Studio Code 1.31.1

And this is the output for dotnet --info:

.NET Core SDK (reflecting any global.json):                                                                  
 Version:   2.2.103                                                                                          
 Commit:    8edbc2570a                                                                                       
                                                                                                             
Runtime Environment:                                                                                         
 OS Name:     Windows                                                                                        
 OS Version:  10.0.17763                                                                                     
 OS Platform: Windows                                                                                        
 RID:         win10-x64                                                                                      
 Base Path:   C:\Program Files\dotnet\sdk\2.2.103\                                                           
                                                                                                             
Host (useful for support):                                                                                   
  Version: 2.2.1                                                                                             
  Commit:  878dd11e62                                                                                        
                                                                                                             
.NET Core SDKs installed:                                                                                    
  1.1.11 [C:\Program Files\dotnet\sdk]                                                                       
  1.1.12 [C:\Program Files\dotnet\sdk]                                                                       
  2.1.4 [C:\Program Files\dotnet\sdk]                                                                        
  2.1.100 [C:\Program Files\dotnet\sdk]                                                                      
  2.1.101 [C:\Program Files\dotnet\sdk]                                                                      
  2.1.104 [C:\Program Files\dotnet\sdk]                                                                      
  2.1.201 [C:\Program Files\dotnet\sdk]                                                                      
  2.1.202 [C:\Program Files\dotnet\sdk]                                                                      
  2.1.301 [C:\Program Files\dotnet\sdk]                                                                      
  2.1.400 [C:\Program Files\dotnet\sdk]                                                                      
  2.1.401 [C:\Program Files\dotnet\sdk]                                                                      
  2.1.402 [C:\Program Files\dotnet\sdk]                                                                      
  2.1.403 [C:\Program Files\dotnet\sdk]                                                                      
  2.1.500 [C:\Program Files\dotnet\sdk]                                                                      
  2.1.502 [C:\Program Files\dotnet\sdk]                                                                      
  2.1.503 [C:\Program Files\dotnet\sdk]                                                                      
  2.1.504 [C:\Program Files\dotnet\sdk]                                                                      
  2.1.600-preview-009426 [C:\Program Files\dotnet\sdk]                                                       
  2.1.600-preview-009472 [C:\Program Files\dotnet\sdk]                                                       
  2.2.102 [C:\Program Files\dotnet\sdk]                                                                      
  2.2.103 [C:\Program Files\dotnet\sdk]                                                                      
                                                                                                             
.NET Core runtimes installed:                                                                                
  Microsoft.AspNetCore.All 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]                   
  Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]                   
  Microsoft.AspNetCore.All 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]                   
  Microsoft.AspNetCore.All 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]                   
  Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]                   
  Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]                   
  Microsoft.AspNetCore.All 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]                   
  Microsoft.AspNetCore.All 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]                   
  Microsoft.AspNetCore.All 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]                   
  Microsoft.AspNetCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]                   
  Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]                   
  Microsoft.AspNetCore.App 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]                   
  Microsoft.AspNetCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]                   
  Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]                   
  Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]                   
  Microsoft.AspNetCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]                   
  Microsoft.AspNetCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]                   
  Microsoft.AspNetCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]                   
  Microsoft.NETCore.App 1.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]                        
  Microsoft.NETCore.App 1.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]                        
  Microsoft.NETCore.App 1.1.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]                        
  Microsoft.NETCore.App 1.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]                        
  Microsoft.NETCore.App 2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]                         
  Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]                         
  Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]                         
  Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]                         
  Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]                         
  Microsoft.NETCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]                         
  Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]                         
  Microsoft.NETCore.App 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]                         
  Microsoft.NETCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]                         
  Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]                         
  Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]                         
  Microsoft.NETCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]                         
  Microsoft.NETCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]                         
  Microsoft.NETCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]                         

System.ArgumentException: '' is not a valid version string. (Parameter 'value')

The extension suddenly fails to start in my devcontainer. I'm running VSCode 1.70.2 and extension version 0.4.6

Starting MSBuild language service...
Failed to start the MSBuild language server.
Error: Command failed: "/usr/bin/dotnet" "/root/.vscode-server/extensions/tintoy.msbuild-project-tools-0.4.6/out/language-server/MSBuildProjectTools.LanguageServer.Host.dll" --probe
System.ArgumentException: '' is not a valid version string. (Parameter 'value')
   at NuGet.Versioning.SemanticVersion.Parse(String value)
   at MSBuildProjectTools.LanguageServer.Utilities.DotNetRuntimeInfo.ParseDotNetVersionOutput(TextReader dotnetVersionOutput) in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Common\Utilities\DotNetRuntimeInfo.cs:line 140
   at MSBuildProjectTools.LanguageServer.Utilities.DotNetRuntimeInfo.GetCurrent(String baseDirectory, ILogger logger) in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Common\Utilities\DotNetRuntimeInfo.cs:line 69
   at MSBuildProjectTools.LanguageServer.Utilities.MSBuildHelper.DiscoverMSBuildEngine(String baseDirectory, ILogger logger) in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Common\Utilities\MSBuildHelper.cs:line 96
   at MSBuildProjectTools.LanguageServer.Program.Main() in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer\Program.cs:line 39

I can retrieve the version in a terminal. Not sure how to properly debug this.

# dotnet --version
6.0.202

Dockerfile:

FROM ubuntu:21.04

RUN apt-get update \
	&& apt-get install -y curl git wget

RUN wget https://packages.microsoft.com/config/ubuntu/21.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
	&& dpkg -i packages-microsoft-prod.deb \
	&& rm packages-microsoft-prod.deb \
	&& apt-get update \
	&& apt-get install -y apt-transport-https \
	&& apt-get update \
	&& apt-get install -y dotnet-sdk-6.0

RUN curl -fsSL https://deb.nodesource.com/setup_17.x | bash - \
	&& apt-get install -y nodejs

RUN apt-get install -y postgresql

ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
	&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \

devcontainer.json

{
	"build": {
		"dockerfile": "Dockerfile"
	},

	"postStartCommand": "service postgresql start",

	"settings": {
		"terminal.integrated.defaultProfile.linux": "bash"
	},

	"extensions": [
		"ckolkman.vscode-postgres",
		"editorconfig.editorconfig",
		"ms-dotnettools.csharp",
		"redhat.vscode-yaml",
		"tintoy.msbuild-project-tools"
	]
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.