Skip to content

Search Syntax

Kirill Osenkov edited this page Sep 7, 2024 · 16 revisions

under(), project() and notunder()

You can scope down search results to search only particular nodes or types of nodes.

  • Add the under(...) clause to your query to filter the results that are only contained under nodes matching the inner query.
  • Add the project(...) clause to filter results under a specific project (like under, but only matches the nearest parent project, not any of them)
  • Add the notunder(...) clause to exclude results under a specific node.

You can combine multiple under, project and notunder clauses, which will result in the union of all matching results.

Examples:

  • $metadata name=CopyToOutputDirectory value=PreserveNewest under($item .txt under($additem None)) - searches for *.txt files included in the None item group with metadata CopyToOutputDirectory=PreserveNewest. Note how parentheses can include arbitrary nested queries, including nested under() clauses.
  • $csc under($project A) under($project B) - finds all C# compiler task invocations under projects A and B. Results from multiple under() clauses are unified, so it's "in either A or B".
  • $rar under($1234) - you can right-click on a project, target or task, and click on "Search in subtree" context menu item to search under that node specifically. It will add the under() clause to the search textbox, where $1234 is the node ID. Again, you can combine multiple nodes to search under each of them.
  • $csc project(A) is a special kind of under() clause which only finds results where the nearest parent project node matches the nested query in parentheses. The difference between under($project A) and project(A) is that under($project A) will match any project named A even if it's not the first direct parent, so if project A builds project B, results from project B will be included. In contrast, project(A) will not match results under project B which itself is under project A.
  • $csc under(A) notunder(B) notunder(Evaluation) matches all Csc tasks under project A which aren't under project B and not under the Evaluation node.

$copy search (file copy map)

$copy filename: find all files copied during the build. You can specify a substring of a file name.

$copy directory\path: find all files copied in and out of the given directory. The results will be grouped into Incoming and Outgoing.

$copy full\file\path: see the copy operations involving the given file.

If the file was copied from a NuGet package it will show which NuGet package and why the project depends on that package (via which chain of dependencies).

If the file was copied because it was added to None or Content item with CopyToOutputDirectory Always or PreserveNewest, this will be shown as well.

$nuget search (project.assets.json)

Search for NuGet packages (by name or version), dependencies (direct or transitive) and files coming from NuGet packages.

$nuget project(MyProject.csproj): list MyProject.csproj dependencies

$nuget project(MyProject.csproj) Package.Name: search for Package.Name in both dependencies and resolved packages

$nuget project(MyProject.csproj) File.dll: Search for a file coming from a NuGet package

$nuget project(.csproj) 13.0.3: search for a specific version or version range

Use project(.) or project(.csproj) to search all projects (slow).

Right-click on a project and click "Search project.assets.json" to view NuGet dependencies.

$projectreference search (project reference graph)

Search for $projectreference project(structuredlogviewer.csproj) core will find all projects matching 'core' referenced by StructuredLogViewer.csproj directly or indirectly. Search for just $projectreference project(structuredlogviewer) to show the transitive closure of all projects referenced by StructuredLogViewer.csproj.

If a single StructuredLogViewer.csproj is found, this feature will also display all projects referencing it (the opposite direction).

You can double-click any project in the search results to view the references and referencing projects for that project. You can thus navigate the project reference graph in both directions.

$project height=N

Finds projects of the given height/depth/tier. height=0 finds all projects with no references. height=1 finds projects who only reference projects of height 0. If you specify height=max it also displays what the max is.

E.g. $project height=0 $project height=1 ... $project height=max

$target skipped=false and $target skipped=true

Add skipped=false to filter out skipped targets, skipped=true to only show skipped targets when searching for a target.