はじめに
CIでキャッシュを効かせつつ.NET Tool
のバージョンを適宜変更できるようにするなど、dotnet tool update --allow-downgrade
は非常に便利で重宝しています。
$ dotnet tool update hogehoge --version 1.0.0 --allow-downgrade
ただ.NET SDKのバージョンが低いと--allow-downgrade
のオプションがないことに気づきました。
$ dotnet --version 8.0.101 $ dotnet tool update --help Description: グローバルまたはローカル ツールを更新します。 使用法: dotnet tool update <packageId> [options] 引数: <PACKAGE_ID> インストールするツールの NuGet パッケージ ID。 オプション: -g, --global 現在のユーザーのツール ディレクトリにあるツールを更新します。 --tool-path <PATH> 更新するツールが入っているディレクトリ。 --local ツールとローカル ツール マニフェストを更新します。 --configfile <FILE> 使用する NuGet 構成ファイル。 --add-source <SOURCE> インストール中に使用する他の NuGet パッケージ ソースを追加します。 --framework <FRAMEWORK> ツールをインストールするターゲット フレームワーク。 --version <VERSION> インストールするツール パッケージのバージョン。 --tool-manifest <PATH> マニフェスト ファイルへのパス。 --prerelease プレリリース パッケージが含まれます。 --disable-parallel 複数のプロジェクトを並行して復元できないようにします。 --ignore-failed-sources パッケージ ソース エラーを警告として処理します。 --no-cache パッケージと HTTP 要求はキャッシュしません。 --interactive コマンドを停止して、ユーザーの入力またはアクション (認証の完了など) を待機できるようにします。 -v, --verbosity <LEVEL> MSBuild の詳細レベルを設定します。使用可能な値: q[uiet]、m[inimal]、n[ormal]、d[etailed]、diag[nostic]。 -?, -h, --help コマンド ラインのヘルプを表示します。
いつから入ったのかあまりネットに情報が出回って無かったので、その調査結果を書き残しておこうと思います。
詳細
具体的にはv8.0.200
から--allow-downgrade
が入ったようです。
github.com
$ dotnet --version 8.0.200 $ dotnet tool update --help Description: Update a global or local tool. Usage: dotnet tool update <packageId> [options] Arguments: <PACKAGE_ID> The NuGet Package Id of the tool to install. Options: -g, --global Install the tool for the current user. --local Install the tool and add to the local tool manifest (default). --tool-path <PATH> The directory where the tool will be installed. The directory will be created if it does not exist. --version <VERSION> The version of the tool package to install. --configfile <FILE> The NuGet configuration file to use. --tool-manifest <PATH> Path to the manifest file. --add-source <SOURCE> Add an additional NuGet package source to use during installation. --framework <FRAMEWORK> The target framework to install the tool for. --prerelease Include pre-release packages. --disable-parallel Prevent restoring multiple projects in parallel. --ignore-failed-sources Treat package source failures as warnings. --no-cache Do not cache packages and http requests. --interactive Allows the command to stop and wait for user input or action (for example to complete authentication). -v, --verbosity <LEVEL> Set the MSBuild verbosity level. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]. --allow-downgrade Allow package downgrade when installing a .NET tool package. -?, -h, --help Show command line help.