VS Code extension for MSBuild intellisense (including PackageReference completion).
Clone or download
Latest commit 33e6e8c Dec 7, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode Diagnostics indicating invalid project contents or XML now have a ran… Oct 8, 2017
docs Update build instructions. Dec 12, 2017
help Display help links for elements that don't directly correspond to MSB… Apr 21, 2018
images v0.0.1 Aug 12, 2017
lib Fix failing tests for task assembly scanner (add a reference to the M… Dec 8, 2018
snippets Remove PrivateAssets=\"All\", leave it default is fine. Feb 2, 2018
src/extension Improvements to logging during startup. Nov 16, 2018
syntaxes Enable basic support for MSBuild expression parsing (behind a feature… Sep 11, 2017
test/extension Use language server from msbuild-project-tools-server. Nov 19, 2017
.editorconfig Simplify XmlLocator API. Aug 27, 2017
.gitignore Expose task metadata cache on workspace. Sep 16, 2017
.gitmodules Use language server from msbuild-project-tools-server. Nov 19, 2017
.vscodeignore Strip out additional unused files from VSIX package. Apr 25, 2018
Build-LanguageServer.ps1 Bug-fix: Completions don't always work correctly in .props files. Dec 23, 2017
CHANGELOG.md Use correct MSBuild SDK folder for .NET Core 3.0 and newer. Dec 6, 2018
CONTRIBUTORS.md Update contributor list. Dec 8, 2018
LICENSE Initial commit. Aug 12, 2017
OSSREADME.json Display task documentation extracted from docs.microsoft.com. Sep 17, 2017
README.md Add message about VS Code API changes to README Sep 22, 2018
build-language-server.sh Add Linux / MacOS build script for language server. Jan 8, 2018
global.json Language Server: prevent "dotnet --info" hanging when its output is l… Nov 20, 2018
language-configuration.json Automatically insert closing parenthesis for common MSBuild expressio… Sep 11, 2017
package-lock.json Use correct MSBuild SDK folder for .NET Core 3.0 and newer. Dec 6, 2018
package.json Remove extra keyword from package manifest. Dec 7, 2018
tsconfig.json Initial commit. Aug 12, 2017
tslint.json Automatically insert closing parenthesis for common MSBuild expressio… Sep 11, 2017

README.md

MSBuild project file tools

An extension for VS Code that provides intellisense for MSBuild project files, including auto-complete for <PackageReference> elements.

The extension in action

The language service used by this extension can be found here: tintoy/msbuild-project-tools-server

Note: there are features in the extension (marked "language service feature" below) that use an out-of-process language service; this is enabled by default but if all you want is PackageReference completion, you can disable the language service by setting msbuildProjectTools.language.enable to false in your VSCode preferences. You will need to reload VSCode after changing this setting.

You need .NET Core 2.0.0 or newer installed to use the language service (but your projects can target any version you have installed).

Usage

  • Completions for PackageReference and DotNetCliToolReference.
    • Completions for Include and Version attributes of these items (invoke the NuGet: toggle pre-release command to include / exclude pre-release packages / package versions).
    • Language service feature: Completions to create these elements.
  • Language service feature: Completions for common top-level elements (e.g. PropertyGroup, ItemGroup, Target).
  • Language service feature: Completions for import elements.
  • Language service feature: Completions for property elements.
  • Language service feature: Completions for item elements.
  • Language service feature: Completions for common item attributes.
  • Language service feature: Completions for common property Condition attributes.
  • Language service feature: Hover the mouse over imports, targets, items, properties, and conditions to see information about them.
  • Language service feature: Document symbols are supported for imports, targets, items, and properties.
  • Language service feature: Go-to-definition is implemented for both SDK-style and regular project imports.
  • Basic syntax highlighting of MSBuild expressions in attribute values.
    To see this highlighting, change the editor language from XML to MSBuild.
  • Language service feature: Completions for $() property, @() item, and %() item metadata expressions.
    To enable these completions, ensure that the editor language is MSBuild (not XML).
  • Language service feature: Completions for task elements and attributes based on metadata for tasks declared in the project and its imported projects.
    To enable these completions, add the string Tasks to the msbuildProjectTools.language.completionsFromProject setting.
  • Useful snippets for common elements of MSBuild project XML (added by @doggy8088).
    To use these snippets, ensure that the editor language is MSBuild (not XML).

File extensions

By default, the language service is automatically available for files with the following extensions:

  • *.*proj
  • .targets
  • .props
  • .tasks

If you want to use it with additional file types:

  1. Open the desired file.
  2. Change the language mode by pressing Ctrl-Shift-P (or Cmd-Shift-P on Mac) and choosing "Change Language Mode".
    associate language with file extension
  3. Choose "configure file association".
    associate language with file extension
  4. Choose language MSBuild.

Installation

You can install this extension from the VS marketplace, or simply download the VSIX package for the latest release and install it by choosing "Install from VSIX" from the menu on the top right of the extensions panel.

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

  • The VS Code extension API has changed somewhat since this extension was first created, and some features (such as hyperlinks to files in hover tooltips) are only partially functional at present (broken by VS Code API / behaviour changes).
    This is being worked on :-)
  • 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.
  • 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 :-)