dotnet-outdated

repository·master·Indexed 23 days ago

https://github.com/dotnet-outdated/dotnet-outdated

A .NET Global tool used to identify and optionally upgrade outdated NuGet packages in .NET Core and .NET Standard projects. It provides functionality not natively built into the .NET CLI, including support for transitive dependencies, version locking to major or minor releases, and CI/CD integration via a fail-on-updates option. The tool also includes a Model Context Protocol (MCP) server for AI agents to analyze and update packages.

Tokens
3.2K
Snippets
7
Records
18
Agent score
33%

What's inside dotnet-outdated

  1. Analyze .NET file-based apps

    master

    When using --recursive --include-file-based-apps, dotnet-outdated can discover loose .cs file-based apps that start with a shebang (#!).

    File-based apps can declare dependencies using:

    • #:package for NuGet packages.
    • #:sdk for MSBuild SDK packages (e.g., #:sdk Cake.Sdk@6.0.0).
    • #:property for variable-backed versions.
  2. Use dotnet-outdated to report outdated packages

    master

    The dotnet outdated command reports outdated NuGet packages in your .NET Core and .NET Standard projects. By default, it analyzes the current directory.

    Command Syntax: dotnet outdated [options] <Path>

    Path Argument Behavior:

    • No path specified: Searches the current directory for a solution (.sln, .slnx) or a project (.csproj, .fsproj). If multiple are found, it returns an error.
    • Directory path: Performs the same search logic within the specified directory.
    • Specific file path: Analyzes the provided .sln, .slnx, .csproj, .fsproj, or .cs file-based app.
    Usage: dotnet outdated [options] <Path>
  3. Upgrade outdated packages automatically

    master

    You can use dotnet-outdated to not only report but also upgrade packages using the -u|--upgrade option.

    • Auto mode (default): Automatically attempts to upgrade outdated packages to the latest version.
    • Prompt mode: Prompts you for each outdated package before upgrading. Use -u:prompt.
  4. Install dotnet-outdated as a global tool

    master

    To use dotnet-outdated, you must have a supported .NET SDK installed. You can install it as a global .NET tool using the dotnet tool install command.

    If you are migrating from the original dotnet-outdated tool, you must first uninstall it to avoid conflicts:

    dotnet tool uninstall --global dotnet-outdated
    dotnet tool install --global dotnet-outdated-tool
  5. Working with secure NuGet feeds

    master

    To use secure feeds (like MyGet), it is recommended to add them via the NuGet CLI source command. dotnet-outdated supports:

    • Pre-authenticated URLs.
    • Username/Password via nuget sources.
    • Credential providers (e.g., Azure Artifacts credential provider).

    Important for Credential Providers: You may need to set the DOTNET_HOST_PATH environment variable to the path of your dotnet executable (e.g., /usr/local/share/dotnet/dotnet) if the SDK does not automatically provide it at runtime.

    macOS/Linux Note: Pass -StorePasswordInClearText to the nuget sources command if you need to store passwords in clear text on these platforms.

  6. Troubleshoot hostfxr.dll/libhostfxr errors

    master

    If you encounter an error stating that hostfxr.dll, libhostfxr.so, or libhostfxr.dylib was not found, it is likely because the .NET Core CLI was installed in a non-default location.

    Solution: Set the DOTNET_ROOT environment variable to point to the location of your .NET Core CLI installation.

  7. Reference: dotnet-outdated CLI options

    master

    The following options are available for the dotnet outdated command:

    Options:
      --version                                             Show version information.
      -?|-h|--help                                          Show help information.
      -i|--include-auto-references                          Specifies whether to include auto-referenced packages.
      -pre|--pre-release <PRERELEASE>                       Specifies whether to look for pre-release versions of packages. Possible values are: Auto (default), Always or Never.
      -vl|--version-lock <VERSION_LOCK>                     Specifies whether the package should be locked to the current Major or Minor version. Possible values are: None (default), Major or Minor.
      -t|--transitive                                       Specifies whether it should detect transitive dependencies.
      -td|--transitive-depth <TRANSITIVE_DEPTH>            Defines how many levels deep transitive dependencies should be analyzed. Integer value (default = 1).
      -u|--upgrade[:<TYPE>]                                 Specifies whether outdated packages should be upgraded. Possible values for <TYPE> is Auto (default) or Prompt.
      -f|--fail-on-updates                                  Specifies whether it should return a non-zero exit code when updates are found.
      -inc|--include <FILTER_INCLUDE>                       Specifies to only look at packages where the name contains the provided string. Culture and case insensitive.
      -exc|--exclude <FILTER_EXCLUDE>                      Specifies to only look at packages where the name does not contain the provided string. Culture and case insensitive.
      -o|--output <OUTPUT_FILENAME>                        Specifies the filename for a generated report.
      -of|--output-format <OUTPUT_FILE_FORMAT>              Specifies the output format for the generated report. Possible values: json (default), csv, or markdown.
      -ot|--older-than <OLDER_THAN_DAYS>                    Only include package versions that are older than the specified number of days. Default value is: 0.
      -n|--no-restore                                       Add the reference without performing restore preview and compatibility check.
      -r|--recursive                                        Recursively search for all projects within the provided directory.
      -fba|--include-file-based-apps                        Include loose file-based apps when recursively searching a directory.
      -ifs|--ignore-failed-sources                          Treat package source failures as warnings.
      -utd|--include-up-to-date                             Include all dependencies in the report even the ones not outdated.
      -prl|--pre-release-label <PRERELEASE_LABEL>           Specifies an optional label to restrict matches to when looking for pre-release versions of packages.
      -ncll|--nuget-cred-log-level <NU_GET_CRED_LOG_LEVEL>  Specifies the minimum level of logs for NuGet Credential Service. Possible values: debug, verbose, information, warning (default), or error.
      -rt|--runtime <RUNTIME>                               Specifies an optional runtime identifier to be used during the restore target when projects are analyzed.
      -mv|--maximum-version <MAX_VERSION>                   The inclusive maximum package version to upgrade to.
  8. Lock package versions to Major or Minor releases

    master

    Use the -vl|--version-lock option to restrict updates to specific version ranges, preventing accidental major version upgrades.

    Available values:

    • None (Default): Returns the absolute latest package version.
    • Major: Only reports packages within the current major version range (e.g., 4.x.x for version 4.1.0).
    • Minor: Only reports packages within the current minor version range (e.g., 4.1.x for version 4.1.0).