From c3e78cca1d3d57cff67d6c465abf82bc2f29504e Mon Sep 17 00:00:00 2001 From: Peter Huene Date: Tue, 20 Feb 2018 12:57:40 -0800 Subject: [PATCH 1/6] Remove unused resource strings. This commit removes unused resource strings from commands that no longer exist. --- .../dotnet-add-proj/LocalizableStrings.resx | 129 ------------------ .../xlf/LocalizableStrings.cs.xlf | 22 --- .../xlf/LocalizableStrings.de.xlf | 22 --- .../xlf/LocalizableStrings.es.xlf | 22 --- .../xlf/LocalizableStrings.fr.xlf | 22 --- .../xlf/LocalizableStrings.it.xlf | 22 --- .../xlf/LocalizableStrings.ja.xlf | 22 --- .../xlf/LocalizableStrings.ko.xlf | 22 --- .../xlf/LocalizableStrings.pl.xlf | 22 --- .../xlf/LocalizableStrings.pt-BR.xlf | 22 --- .../xlf/LocalizableStrings.ru.xlf | 22 --- .../xlf/LocalizableStrings.tr.xlf | 22 --- .../xlf/LocalizableStrings.xlf | 20 --- .../xlf/LocalizableStrings.zh-Hans.xlf | 22 --- .../xlf/LocalizableStrings.zh-Hant.xlf | 22 --- .../dotnet-list-proj/LocalizableStrings.resx | 126 ----------------- .../xlf/LocalizableStrings.cs.xlf | 17 --- .../xlf/LocalizableStrings.de.xlf | 17 --- .../xlf/LocalizableStrings.es.xlf | 17 --- .../xlf/LocalizableStrings.fr.xlf | 17 --- .../xlf/LocalizableStrings.it.xlf | 17 --- .../xlf/LocalizableStrings.ja.xlf | 17 --- .../xlf/LocalizableStrings.ko.xlf | 17 --- .../xlf/LocalizableStrings.pl.xlf | 17 --- .../xlf/LocalizableStrings.pt-BR.xlf | 17 --- .../xlf/LocalizableStrings.ru.xlf | 17 --- .../xlf/LocalizableStrings.tr.xlf | 17 --- .../xlf/LocalizableStrings.xlf | 16 --- .../xlf/LocalizableStrings.zh-Hans.xlf | 17 --- .../xlf/LocalizableStrings.zh-Hant.xlf | 17 --- .../LocalizableStrings.resx | 129 ------------------ .../xlf/LocalizableStrings.cs.xlf | 22 --- .../xlf/LocalizableStrings.de.xlf | 22 --- .../xlf/LocalizableStrings.es.xlf | 22 --- .../xlf/LocalizableStrings.fr.xlf | 22 --- .../xlf/LocalizableStrings.it.xlf | 22 --- .../xlf/LocalizableStrings.ja.xlf | 22 --- .../xlf/LocalizableStrings.ko.xlf | 22 --- .../xlf/LocalizableStrings.pl.xlf | 22 --- .../xlf/LocalizableStrings.pt-BR.xlf | 22 --- .../xlf/LocalizableStrings.ru.xlf | 22 --- .../xlf/LocalizableStrings.tr.xlf | 22 --- .../xlf/LocalizableStrings.xlf | 20 --- .../xlf/LocalizableStrings.zh-Hans.xlf | 22 --- .../xlf/LocalizableStrings.zh-Hant.xlf | 22 --- src/dotnet/dotnet.csproj | 3 - 46 files changed, 1236 deletions(-) delete mode 100644 src/dotnet/commands/dotnet-add/dotnet-add-proj/LocalizableStrings.resx delete mode 100644 src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.cs.xlf delete mode 100644 src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.de.xlf delete mode 100644 src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.es.xlf delete mode 100644 src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.fr.xlf delete mode 100644 src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.it.xlf delete mode 100644 src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.ja.xlf delete mode 100644 src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.ko.xlf delete mode 100644 src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.pl.xlf delete mode 100644 src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.pt-BR.xlf delete mode 100644 src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.ru.xlf delete mode 100644 src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.tr.xlf delete mode 100644 src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.xlf delete mode 100644 src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.zh-Hans.xlf delete mode 100644 src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.zh-Hant.xlf delete mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-proj/LocalizableStrings.resx delete mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.cs.xlf delete mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.de.xlf delete mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.es.xlf delete mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.fr.xlf delete mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.it.xlf delete mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.ja.xlf delete mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.ko.xlf delete mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.pl.xlf delete mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.pt-BR.xlf delete mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.ru.xlf delete mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.tr.xlf delete mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.xlf delete mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.zh-Hans.xlf delete mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.zh-Hant.xlf delete mode 100644 src/dotnet/commands/dotnet-remove/dotnet-remove-proj/LocalizableStrings.resx delete mode 100644 src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.cs.xlf delete mode 100644 src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.de.xlf delete mode 100644 src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.es.xlf delete mode 100644 src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.fr.xlf delete mode 100644 src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.it.xlf delete mode 100644 src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.ja.xlf delete mode 100644 src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.ko.xlf delete mode 100644 src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.pl.xlf delete mode 100644 src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.pt-BR.xlf delete mode 100644 src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.ru.xlf delete mode 100644 src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.tr.xlf delete mode 100644 src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.xlf delete mode 100644 src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.zh-Hans.xlf delete mode 100644 src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.zh-Hant.xlf diff --git a/src/dotnet/commands/dotnet-add/dotnet-add-proj/LocalizableStrings.resx b/src/dotnet/commands/dotnet-add/dotnet-add-proj/LocalizableStrings.resx deleted file mode 100644 index a5810e897..000000000 --- a/src/dotnet/commands/dotnet-add/dotnet-add-proj/LocalizableStrings.resx +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - .NET Add Project to Solution Command - - - Command to add project to solution - - - Projects to add to solution - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.cs.xlf b/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.cs.xlf deleted file mode 100644 index 944be9708..000000000 --- a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.cs.xlf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - .NET Add Project to Solution Command - Příkaz rozhraní .NET pro přidání projektu do řešení - - - - Command to add project to solution - Příkaz pro přidání projektu do řešení - - - - Projects to add to solution - Projekty přidané do řešení - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.de.xlf b/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.de.xlf deleted file mode 100644 index ed33e3f3d..000000000 --- a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.de.xlf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - .NET Add Project to Solution Command - .NET-Befehl zum Hinzufügen eines Projekts zur Projektmappe - - - - Command to add project to solution - Befehl zum Hinzufügen eines Projekts zur Projektmappe - - - - Projects to add to solution - Zur Projektmappe hinzuzufügende Projekte - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.es.xlf b/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.es.xlf deleted file mode 100644 index f9d1dab81..000000000 --- a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.es.xlf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - .NET Add Project to Solution Command - Comando de .NET Agregar proyecto a solución - - - - Command to add project to solution - Comando para agregar un proyecto a una solución - - - - Projects to add to solution - Proyectos que se agregarán a la solución - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.fr.xlf b/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.fr.xlf deleted file mode 100644 index 2323b4ba9..000000000 --- a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.fr.xlf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - .NET Add Project to Solution Command - Commande .NET d'ajout de projet à une solution - - - - Command to add project to solution - Commande d'ajout de projet à une solution - - - - Projects to add to solution - Projets à ajouter à la solution - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.it.xlf b/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.it.xlf deleted file mode 100644 index 9f5b6b257..000000000 --- a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.it.xlf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - .NET Add Project to Solution Command - Comando Aggiungi progetto a soluzione .NET - - - - Command to add project to solution - Comando per aggiungere il progetto alla soluzione - - - - Projects to add to solution - Progetti da aggiungere alla soluzione - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.ja.xlf b/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.ja.xlf deleted file mode 100644 index 7db8904d8..000000000 --- a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.ja.xlf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - .NET Add Project to Solution Command - .NET Add Project to Solution コマンド - - - - Command to add project to solution - ソリューションにプロジェクトを追加するコマンド - - - - Projects to add to solution - ソリューションに追加するプロジェクト - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.ko.xlf b/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.ko.xlf deleted file mode 100644 index 5b6e02c56..000000000 --- a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.ko.xlf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - .NET Add Project to Solution Command - .NET 솔루션에 프로젝트 추가 명령 - - - - Command to add project to solution - 솔루션에 프로젝트를 추가하기 위한 명령입니다. - - - - Projects to add to solution - 솔루션에 추가할 프로젝트 - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.pl.xlf b/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.pl.xlf deleted file mode 100644 index 7c8e0049f..000000000 --- a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.pl.xlf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - .NET Add Project to Solution Command - Polecenie dodawania projektu do rozwiązania dla platformy .NET - - - - Command to add project to solution - Polecenie umożliwiające dodanie projektu do rozwiązania - - - - Projects to add to solution - Projekty, które mają zostać dodane do rozwiązania - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.pt-BR.xlf b/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.pt-BR.xlf deleted file mode 100644 index 1b3694bb4..000000000 --- a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.pt-BR.xlf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - .NET Add Project to Solution Command - Comando Adicionar Projeto à Solução do .NET - - - - Command to add project to solution - Comando para adicionar o projeto à solução - - - - Projects to add to solution - Projetos a serem adicionados à solução - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.ru.xlf b/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.ru.xlf deleted file mode 100644 index e609e17f9..000000000 --- a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.ru.xlf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - .NET Add Project to Solution Command - Команда .NET "Добавить проект в решение" - - - - Command to add project to solution - Команда для добавления проекта в решение - - - - Projects to add to solution - Проекты, добавляемые в решение - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.tr.xlf b/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.tr.xlf deleted file mode 100644 index ab0b0c18b..000000000 --- a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.tr.xlf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - .NET Add Project to Solution Command - .NET Çözüme Proje Ekleme Komutu - - - - Command to add project to solution - Çözüme proje ekleme komutu - - - - Projects to add to solution - Çözüme eklenecek projeler - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.xlf b/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.xlf deleted file mode 100644 index 34201b21a..000000000 --- a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.xlf +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - .NET Add Project to Solution Command - - - - Command to add project to solution - - - - Projects to add to solution - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.zh-Hans.xlf b/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.zh-Hans.xlf deleted file mode 100644 index e49d0c2b1..000000000 --- a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.zh-Hans.xlf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - .NET Add Project to Solution Command - .NET 将项目添加到解决方案命令 - - - - Command to add project to solution - 将项目添加到解决方案的命令 - - - - Projects to add to solution - 要添加到解决方案的项目 - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.zh-Hant.xlf b/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.zh-Hant.xlf deleted file mode 100644 index b24ad1c7f..000000000 --- a/src/dotnet/commands/dotnet-add/dotnet-add-proj/xlf/LocalizableStrings.zh-Hant.xlf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - .NET Add Project to Solution Command - .NET 將專案新增至解決方案命令 - - - - Command to add project to solution - 命令,將專案新增至解決方案 - - - - Projects to add to solution - 要新增至解決方案的專案 - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-proj/LocalizableStrings.resx b/src/dotnet/commands/dotnet-list/dotnet-list-proj/LocalizableStrings.resx deleted file mode 100644 index a7913dc1d..000000000 --- a/src/dotnet/commands/dotnet-list/dotnet-list-proj/LocalizableStrings.resx +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - .NET Projects in Solution viewer - - - Command to list projects in a solution - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.cs.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.cs.xlf deleted file mode 100644 index b151f7b6f..000000000 --- a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.cs.xlf +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - .NET Projects in Solution viewer - Projekty .NET v prohlížeči řešení - - - - Command to list projects in a solution - Příkaz pro zobrazení seznamu projektů v řešení - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.de.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.de.xlf deleted file mode 100644 index 8da16bcd0..000000000 --- a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.de.xlf +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - .NET Projects in Solution viewer - .NET-Projekte in Projektmappenviewer - - - - Command to list projects in a solution - Befehl zum Auflisten von Projekten in einer Projektmappe - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.es.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.es.xlf deleted file mode 100644 index 420558ecc..000000000 --- a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.es.xlf +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - .NET Projects in Solution viewer - Visor de proyectos de NET en la solución - - - - Command to list projects in a solution - Comando para mostrar los proyectos de una solución - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.fr.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.fr.xlf deleted file mode 100644 index 3066ae96e..000000000 --- a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.fr.xlf +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - .NET Projects in Solution viewer - Projets .NET dans la visionneuse de solutions - - - - Command to list projects in a solution - Commande permettant de lister les projets d'une solution - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.it.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.it.xlf deleted file mode 100644 index 6441bf146..000000000 --- a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.it.xlf +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - .NET Projects in Solution viewer - Progetti .NET nel visualizzatore soluzioni - - - - Command to list projects in a solution - Comando per elencare i progetti presenti in una soluzione - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.ja.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.ja.xlf deleted file mode 100644 index b3ac167c7..000000000 --- a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.ja.xlf +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - .NET Projects in Solution viewer - ソリューション ビューアー内の .NET プロジェクト - - - - Command to list projects in a solution - ソリューションのプロジェクトを一覧表示するコマンド - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.ko.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.ko.xlf deleted file mode 100644 index a86df7d2c..000000000 --- a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.ko.xlf +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - .NET Projects in Solution viewer - .NET 솔루션 뷰어의 프로젝트 - - - - Command to list projects in a solution - 솔루션의 프로젝트를 나열하기 위한 명령입니다. - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.pl.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.pl.xlf deleted file mode 100644 index 8bed18a05..000000000 --- a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.pl.xlf +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - .NET Projects in Solution viewer - Podgląd projektów w rozwiązaniu dla platformy .NET - - - - Command to list projects in a solution - Polecenie umożliwiające wyświetlenie listy projektów w rozwiązaniu - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.pt-BR.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.pt-BR.xlf deleted file mode 100644 index 66f962109..000000000 --- a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.pt-BR.xlf +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - .NET Projects in Solution viewer - Projetos .NET no visualizador da Solução - - - - Command to list projects in a solution - Comando para listar os projetos em uma solução - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.ru.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.ru.xlf deleted file mode 100644 index 6a7ba6513..000000000 --- a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.ru.xlf +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - .NET Projects in Solution viewer - Проекты .NET в средстве просмотра решений - - - - Command to list projects in a solution - Команда для перечисления проектов в решении - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.tr.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.tr.xlf deleted file mode 100644 index 0d071b7ed..000000000 --- a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.tr.xlf +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - .NET Projects in Solution viewer - Çözüm görüntüleyicisinde .NET Projeleri - - - - Command to list projects in a solution - Bir çözümdeki projeleri listeleme komutu - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.xlf deleted file mode 100644 index 6856ef94e..000000000 --- a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.xlf +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - .NET Projects in Solution viewer - - - - Command to list projects in a solution - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.zh-Hans.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.zh-Hans.xlf deleted file mode 100644 index ed721ca0b..000000000 --- a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.zh-Hans.xlf +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - .NET Projects in Solution viewer - 解决方案查看器中的 .NET 项目 - - - - Command to list projects in a solution - 用于列出解决方案中项目的命令 - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.zh-Hant.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.zh-Hant.xlf deleted file mode 100644 index 01551fb1e..000000000 --- a/src/dotnet/commands/dotnet-list/dotnet-list-proj/xlf/LocalizableStrings.zh-Hant.xlf +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - .NET Projects in Solution viewer - 解決方案檢視器中的 .NET 專案 - - - - Command to list projects in a solution - 命令,用以列出解決方案中的專案 - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/LocalizableStrings.resx b/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/LocalizableStrings.resx deleted file mode 100644 index 8b30c41cf..000000000 --- a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/LocalizableStrings.resx +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - .NET Remove Project from Solution Command - - - Command to remove projects from a solution - - - Projects to remove from a solution - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.cs.xlf b/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.cs.xlf deleted file mode 100644 index 3a0ed224f..000000000 --- a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.cs.xlf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - .NET Remove Project from Solution Command - Příkaz rozhraní .NET pro odebrání projektu z řešení - - - - Command to remove projects from a solution - Příkaz pro odebrání projektů z řešení - - - - Projects to remove from a solution - Projekty odebírané z řešení - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.de.xlf b/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.de.xlf deleted file mode 100644 index 6790a8458..000000000 --- a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.de.xlf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - .NET Remove Project from Solution Command - .NET-Befehl zum Entfernen des Projekts aus der Projektmappe - - - - Command to remove projects from a solution - Befehl zum Entfernen von Projekten aus einer Projektmappe - - - - Projects to remove from a solution - Aus einer Projektmappe zu entfernende Projekte - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.es.xlf b/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.es.xlf deleted file mode 100644 index ffe8694cb..000000000 --- a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.es.xlf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - .NET Remove Project from Solution Command - Comando de .NET Quitar proyecto de la solución - - - - Command to remove projects from a solution - Comando para quitar proyectos de una solución - - - - Projects to remove from a solution - Proyectos que se quitarán de una solución - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.fr.xlf b/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.fr.xlf deleted file mode 100644 index fa406f2f1..000000000 --- a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.fr.xlf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - .NET Remove Project from Solution Command - Commande .NET de suppression de projet d'une solution - - - - Command to remove projects from a solution - Commande permettant de supprimer des projets d'une solution - - - - Projects to remove from a solution - Projets à supprimer d'une solution - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.it.xlf b/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.it.xlf deleted file mode 100644 index c4c9f26e3..000000000 --- a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.it.xlf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - .NET Remove Project from Solution Command - Comando Rimuovi progetto da soluzione .NET - - - - Command to remove projects from a solution - Comando per rimuovere il progetto da una soluzione - - - - Projects to remove from a solution - Progetti da rimuovere da una soluzione - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.ja.xlf b/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.ja.xlf deleted file mode 100644 index 57dc722ce..000000000 --- a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.ja.xlf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - .NET Remove Project from Solution Command - .NET Remove Project from Solution コマンド - - - - Command to remove projects from a solution - ソリューションからプロジェクトを削除するコマンド - - - - Projects to remove from a solution - ソリューションから削除するプロジェクト - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.ko.xlf b/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.ko.xlf deleted file mode 100644 index b96b5595a..000000000 --- a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.ko.xlf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - .NET Remove Project from Solution Command - .NET 솔루션에서 프로젝트 제거 명령 - - - - Command to remove projects from a solution - 솔루션에서 프로젝트를 제거하기 위한 명령입니다. - - - - Projects to remove from a solution - 솔루션에서 제거할 프로젝트 - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.pl.xlf b/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.pl.xlf deleted file mode 100644 index 0c7a09a93..000000000 --- a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.pl.xlf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - .NET Remove Project from Solution Command - Polecenie usuwania projektu z rozwiązania dla platformy .NET - - - - Command to remove projects from a solution - Polecenie służące do usuwania projektów z rozwiązania - - - - Projects to remove from a solution - Projekty do usunięcia z rozwiązania - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.pt-BR.xlf b/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.pt-BR.xlf deleted file mode 100644 index 3f9ed9fc3..000000000 --- a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.pt-BR.xlf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - .NET Remove Project from Solution Command - Comando para Remover Projetos de uma Solução do .NET - - - - Command to remove projects from a solution - Comando para remover projetos de uma solução - - - - Projects to remove from a solution - Projetos a serem removidos de uma solução - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.ru.xlf b/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.ru.xlf deleted file mode 100644 index eba7b97ec..000000000 --- a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.ru.xlf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - .NET Remove Project from Solution Command - Команда .NET "Удалить проект из решения" - - - - Command to remove projects from a solution - Команда для удаления проектов из решения - - - - Projects to remove from a solution - Проекты, удаляемые из решения - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.tr.xlf b/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.tr.xlf deleted file mode 100644 index e1a65f44c..000000000 --- a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.tr.xlf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - .NET Remove Project from Solution Command - .NET Projeyi Çözümden Kaldırma Komutu - - - - Command to remove projects from a solution - Projeleri çözümden kaldırma komutu - - - - Projects to remove from a solution - Bir projeden kaldırılacak çözümler - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.xlf b/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.xlf deleted file mode 100644 index 1cc2436a4..000000000 --- a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.xlf +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - .NET Remove Project from Solution Command - - - - Command to remove projects from a solution - - - - Projects to remove from a solution - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.zh-Hans.xlf b/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.zh-Hans.xlf deleted file mode 100644 index 9e44a4152..000000000 --- a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.zh-Hans.xlf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - .NET Remove Project from Solution Command - .NET 从解决方案中删除项目命令 - - - - Command to remove projects from a solution - 从解决方案中删除项目的命令 - - - - Projects to remove from a solution - 要从解决方案中删除的项目 - - - - - \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.zh-Hant.xlf b/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.zh-Hant.xlf deleted file mode 100644 index 7325b0fe9..000000000 --- a/src/dotnet/commands/dotnet-remove/dotnet-remove-proj/xlf/LocalizableStrings.zh-Hant.xlf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - .NET Remove Project from Solution Command - .NET 從解決方案移除專案命令 - - - - Command to remove projects from a solution - 命令,從解決方案移除專案命令 - - - - Projects to remove from a solution - 要從解決方案移除的專案 - - - - - \ No newline at end of file diff --git a/src/dotnet/dotnet.csproj b/src/dotnet/dotnet.csproj index 35bdbeaf9..6b17fb237 100644 --- a/src/dotnet/dotnet.csproj +++ b/src/dotnet/dotnet.csproj @@ -18,7 +18,6 @@ - @@ -26,7 +25,6 @@ - @@ -34,7 +32,6 @@ - From 2ff85cdd9a8c4e9b3a25b966680dfc7f62cafbc2 Mon Sep 17 00:00:00 2001 From: Peter Huene Date: Tue, 20 Feb 2018 15:15:08 -0800 Subject: [PATCH 2/6] Update description of uninstall command to match install command. This commit updates the help text of the uninstall command to match the install command's help text. --- src/dotnet/commands/dotnet-help/LocalizableStrings.resx | 2 +- src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.cs.xlf | 4 ++-- src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.de.xlf | 4 ++-- src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.es.xlf | 4 ++-- src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.fr.xlf | 4 ++-- src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.it.xlf | 4 ++-- src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ja.xlf | 4 ++-- src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ko.xlf | 4 ++-- src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.pl.xlf | 4 ++-- .../commands/dotnet-help/xlf/LocalizableStrings.pt-BR.xlf | 4 ++-- src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ru.xlf | 4 ++-- src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.tr.xlf | 4 ++-- .../commands/dotnet-help/xlf/LocalizableStrings.zh-Hans.xlf | 4 ++-- .../commands/dotnet-help/xlf/LocalizableStrings.zh-Hant.xlf | 4 ++-- .../GivenThatIWantToShowHelpForDotnetCommand.cs | 2 +- 15 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/dotnet/commands/dotnet-help/LocalizableStrings.resx b/src/dotnet/commands/dotnet-help/LocalizableStrings.resx index 8b0c84730..77e1429ed 100644 --- a/src/dotnet/commands/dotnet-help/LocalizableStrings.resx +++ b/src/dotnet/commands/dotnet-help/LocalizableStrings.resx @@ -271,6 +271,6 @@ Installs an item into the development environment. - Uninstalls a tool from the development environment. + Uninstalls an item from the development environment. diff --git a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.cs.xlf b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.cs.xlf index b348a5041..c7e572fee 100644 --- a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.cs.xlf +++ b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.cs.xlf @@ -258,8 +258,8 @@ - Uninstalls a tool from the development environment. - Uninstalls a tool from the development environment. + Uninstalls an item from the development environment. + Uninstalls an item from the development environment. diff --git a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.de.xlf b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.de.xlf index c56460685..76a830a57 100644 --- a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.de.xlf +++ b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.de.xlf @@ -258,8 +258,8 @@ - Uninstalls a tool from the development environment. - Uninstalls a tool from the development environment. + Uninstalls an item from the development environment. + Uninstalls an item from the development environment. diff --git a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.es.xlf b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.es.xlf index 6752e1b76..156b555db 100644 --- a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.es.xlf +++ b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.es.xlf @@ -258,8 +258,8 @@ - Uninstalls a tool from the development environment. - Uninstalls a tool from the development environment. + Uninstalls an item from the development environment. + Uninstalls an item from the development environment. diff --git a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.fr.xlf b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.fr.xlf index d1de6fd3a..0c7b146c3 100644 --- a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.fr.xlf +++ b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.fr.xlf @@ -258,8 +258,8 @@ - Uninstalls a tool from the development environment. - Uninstalls a tool from the development environment. + Uninstalls an item from the development environment. + Uninstalls an item from the development environment. diff --git a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.it.xlf b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.it.xlf index d6b573506..c82936c0d 100644 --- a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.it.xlf +++ b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.it.xlf @@ -258,8 +258,8 @@ - Uninstalls a tool from the development environment. - Uninstalls a tool from the development environment. + Uninstalls an item from the development environment. + Uninstalls an item from the development environment. diff --git a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ja.xlf b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ja.xlf index 056874d3f..676fb4114 100644 --- a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ja.xlf +++ b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ja.xlf @@ -258,8 +258,8 @@ - Uninstalls a tool from the development environment. - Uninstalls a tool from the development environment. + Uninstalls an item from the development environment. + Uninstalls an item from the development environment. diff --git a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ko.xlf b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ko.xlf index c3dbcdf18..dacf14f0b 100644 --- a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ko.xlf +++ b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ko.xlf @@ -258,8 +258,8 @@ - Uninstalls a tool from the development environment. - Uninstalls a tool from the development environment. + Uninstalls an item from the development environment. + Uninstalls an item from the development environment. diff --git a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.pl.xlf b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.pl.xlf index 304b215d0..3ef41efc3 100644 --- a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.pl.xlf +++ b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.pl.xlf @@ -258,8 +258,8 @@ - Uninstalls a tool from the development environment. - Uninstalls a tool from the development environment. + Uninstalls an item from the development environment. + Uninstalls an item from the development environment. diff --git a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.pt-BR.xlf b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.pt-BR.xlf index a3a00faee..b6356780c 100644 --- a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.pt-BR.xlf +++ b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.pt-BR.xlf @@ -258,8 +258,8 @@ - Uninstalls a tool from the development environment. - Uninstalls a tool from the development environment. + Uninstalls an item from the development environment. + Uninstalls an item from the development environment. diff --git a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ru.xlf b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ru.xlf index 5a64011ec..392df0743 100644 --- a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ru.xlf +++ b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ru.xlf @@ -258,8 +258,8 @@ - Uninstalls a tool from the development environment. - Uninstalls a tool from the development environment. + Uninstalls an item from the development environment. + Uninstalls an item from the development environment. diff --git a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.tr.xlf b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.tr.xlf index 0654c6eaa..a168014f1 100644 --- a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.tr.xlf +++ b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.tr.xlf @@ -258,8 +258,8 @@ - Uninstalls a tool from the development environment. - Uninstalls a tool from the development environment. + Uninstalls an item from the development environment. + Uninstalls an item from the development environment. diff --git a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.zh-Hans.xlf b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.zh-Hans.xlf index 78a9319a0..5940a4217 100644 --- a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.zh-Hans.xlf +++ b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.zh-Hans.xlf @@ -258,8 +258,8 @@ - Uninstalls a tool from the development environment. - Uninstalls a tool from the development environment. + Uninstalls an item from the development environment. + Uninstalls an item from the development environment. diff --git a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.zh-Hant.xlf b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.zh-Hant.xlf index 98b0bb991..2babfcb51 100644 --- a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.zh-Hant.xlf +++ b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.zh-Hant.xlf @@ -258,8 +258,8 @@ - Uninstalls a tool from the development environment. - Uninstalls a tool from the development environment. + Uninstalls an item from the development environment. + Uninstalls an item from the development environment. diff --git a/test/dotnet-help.Tests/GivenThatIWantToShowHelpForDotnetCommand.cs b/test/dotnet-help.Tests/GivenThatIWantToShowHelpForDotnetCommand.cs index 5c34912ba..f1f26eca6 100644 --- a/test/dotnet-help.Tests/GivenThatIWantToShowHelpForDotnetCommand.cs +++ b/test/dotnet-help.Tests/GivenThatIWantToShowHelpForDotnetCommand.cs @@ -40,7 +40,7 @@ SDK commands: vstest Runs Microsoft Test Execution Command Line Tool. store Stores the specified assemblies in the runtime store. install Installs an item into the development environment. - uninstall Uninstalls a tool from the development environment. + uninstall Uninstalls an item from the development environment. help Show help. Common options: From 9ef495327aeede9e6ef4251615544cb280af78bf Mon Sep 17 00:00:00 2001 From: Peter Huene Date: Sun, 25 Feb 2018 17:22:11 -0800 Subject: [PATCH 3/6] Implement a printable table. This commit implements a simple printable table that can be used to display tabular data. The columns of the table can specify a maximum width which will cause the column text to wrap around to the next line. --- src/dotnet/CommonLocalizableStrings.resx | 3 + src/dotnet/PrintableTable.cs | 226 ++++++++++ .../xlf/CommonLocalizableStrings.cs.xlf | 5 + .../xlf/CommonLocalizableStrings.de.xlf | 5 + .../xlf/CommonLocalizableStrings.es.xlf | 5 + .../xlf/CommonLocalizableStrings.fr.xlf | 5 + .../xlf/CommonLocalizableStrings.it.xlf | 5 + .../xlf/CommonLocalizableStrings.ja.xlf | 5 + .../xlf/CommonLocalizableStrings.ko.xlf | 5 + .../xlf/CommonLocalizableStrings.pl.xlf | 5 + .../xlf/CommonLocalizableStrings.pt-BR.xlf | 5 + .../xlf/CommonLocalizableStrings.ru.xlf | 5 + .../xlf/CommonLocalizableStrings.tr.xlf | 5 + .../xlf/CommonLocalizableStrings.zh-Hans.xlf | 5 + .../xlf/CommonLocalizableStrings.zh-Hant.xlf | 5 + test/dotnet.Tests/PrintableTableTests.cs | 420 ++++++++++++++++++ 16 files changed, 714 insertions(+) create mode 100644 src/dotnet/PrintableTable.cs create mode 100644 test/dotnet.Tests/PrintableTableTests.cs diff --git a/src/dotnet/CommonLocalizableStrings.resx b/src/dotnet/CommonLocalizableStrings.resx index fd28bb3cf..ea905e472 100644 --- a/src/dotnet/CommonLocalizableStrings.resx +++ b/src/dotnet/CommonLocalizableStrings.resx @@ -619,4 +619,7 @@ setx PATH "%PATH%;{0}" Tool '{0}' (version '{1}') is already installed. + + Column maximum width must be greater than zero. + diff --git a/src/dotnet/PrintableTable.cs b/src/dotnet/PrintableTable.cs new file mode 100644 index 000000000..ce31e13cc --- /dev/null +++ b/src/dotnet/PrintableTable.cs @@ -0,0 +1,226 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using Microsoft.DotNet.Tools; + +namespace Microsoft.DotNet.Cli +{ + // Represents a table (with rows of type T) that can be printed to a terminal. + internal class PrintableTable + { + private const string ColumnDelimiter = " "; + private List _columns = new List(); + + private class Column + { + public string Header { get; set; } + public Func GetContent { get; set; } + public int MaxWidth { get; set; } + public override string ToString() { return Header; } + } + + public void AddColumn(string header, Func getContent, int maxWidth = int.MaxValue) + { + if (getContent == null) + { + throw new ArgumentNullException(nameof(getContent)); + } + + if (maxWidth <= 0) + { + throw new ArgumentException( + CommonLocalizableStrings.ColumnMaxWidthMustBeGreaterThanZero, + nameof(maxWidth)); + } + + _columns.Add( + new Column() { + Header = header, + GetContent = getContent, + MaxWidth = maxWidth + }); + } + + public void PrintRows(IEnumerable rows, Action writeLine) + { + if (rows == null) + { + throw new ArgumentNullException(nameof(rows)); + } + + if (writeLine == null) + { + throw new ArgumentNullException(nameof(writeLine)); + } + + var widths = CalculateColumnWidths(rows); + var totalWidth = CalculateTotalWidth(widths); + if (totalWidth == 0) + { + return; + } + + foreach (var line in EnumerateHeaderLines(widths)) + { + writeLine(line); + } + + writeLine(new string('-', totalWidth)); + + foreach (var row in rows) + { + foreach (var line in EnumerateRowLines(row, widths)) + { + writeLine(line); + } + } + } + + public int CalculateWidth(IEnumerable rows) + { + if (rows == null) + { + throw new ArgumentNullException(nameof(rows)); + } + + return CalculateTotalWidth(CalculateColumnWidths(rows)); + } + + private IEnumerable EnumerateHeaderLines(int[] widths) + { + if (_columns.Count != widths.Length) + { + throw new InvalidOperationException(); + } + + return EnumerateLines( + widths, + _columns.Select(c => new StringInfo(c.Header ?? "")).ToArray()); + } + + private IEnumerable EnumerateRowLines(T row, int[] widths) + { + if (_columns.Count != widths.Length) + { + throw new InvalidOperationException(); + } + + return EnumerateLines( + widths, + _columns.Select(c => new StringInfo(c.GetContent(row) ?? "")).ToArray()); + } + + private static IEnumerable EnumerateLines(int[] widths, StringInfo[] contents) + { + if (widths.Length != contents.Length) + { + throw new InvalidOperationException(); + } + + if (contents.Length == 0) + { + yield break; + } + + var builder = new StringBuilder(); + for (int line = 0; true; ++line) + { + builder.Clear(); + + bool emptyLine = true; + bool appendDelimiter = false; + for (int i = 0; i < contents.Length; ++i) + { + // Skip zero-width columns entirely + if (widths[i] == 0) + { + continue; + } + + if (appendDelimiter) + { + builder.Append(ColumnDelimiter); + } + + var startIndex = line * widths[i]; + var length = contents[i].LengthInTextElements; + if (startIndex < length) + { + var endIndex = (line + 1) * widths[i]; + length = endIndex >= length ? length - startIndex : widths[i]; + builder.Append(contents[i].SubstringByTextElements(startIndex, length)); + builder.Append(' ', widths[i] - length); + emptyLine = false; + } + else + { + // No more content for this column; append whitespace to fill remaining space + builder.Append(' ', widths[i]); + } + + appendDelimiter = true; + } + + if (emptyLine) + { + // Yield an "empty" line on the first line only + if (line == 0) + { + yield return builder.ToString(); + } + yield break; + } + + yield return builder.ToString(); + } + } + + private int[] CalculateColumnWidths(IEnumerable rows) + { + return _columns + .Select(c => { + var width = new StringInfo(c.Header ?? "").LengthInTextElements; + + foreach (var row in rows) + { + width = Math.Max( + width, + new StringInfo(c.GetContent(row) ?? "").LengthInTextElements); + } + + return Math.Min(width, c.MaxWidth); + }) + .ToArray(); + } + + private static int CalculateTotalWidth(int[] widths) + { + int sum = 0; + int count = 0; + + foreach (var width in widths) + { + if (width == 0) + { + // Skip zero-width columns + continue; + } + + sum += width; + ++count; + } + + if (count == 0) + { + return 0; + } + + return sum + (ColumnDelimiter.Length * (count - 1)); + } + } +} diff --git a/src/dotnet/xlf/CommonLocalizableStrings.cs.xlf b/src/dotnet/xlf/CommonLocalizableStrings.cs.xlf index 474394e5b..cde9c4124 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.cs.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.cs.xlf @@ -848,6 +848,11 @@ setx PATH "%PATH%;{0}" Failed to uninstall tool package '{0}': {1} + + Column maximum width must be greater than zero. + Column maximum width must be greater than zero. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.de.xlf b/src/dotnet/xlf/CommonLocalizableStrings.de.xlf index a197419e5..2ea94a468 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.de.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.de.xlf @@ -848,6 +848,11 @@ setx PATH "%PATH%;{0}" Failed to uninstall tool package '{0}': {1} + + Column maximum width must be greater than zero. + Column maximum width must be greater than zero. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.es.xlf b/src/dotnet/xlf/CommonLocalizableStrings.es.xlf index e19eba9aa..0b2245c24 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.es.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.es.xlf @@ -848,6 +848,11 @@ setx PATH "%PATH%;{0}" Failed to uninstall tool package '{0}': {1} + + Column maximum width must be greater than zero. + Column maximum width must be greater than zero. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.fr.xlf b/src/dotnet/xlf/CommonLocalizableStrings.fr.xlf index d9252cd95..347fa1778 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.fr.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.fr.xlf @@ -848,6 +848,11 @@ setx PATH "%PATH%;{0}" Failed to uninstall tool package '{0}': {1} + + Column maximum width must be greater than zero. + Column maximum width must be greater than zero. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.it.xlf b/src/dotnet/xlf/CommonLocalizableStrings.it.xlf index f02329445..888a733b7 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.it.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.it.xlf @@ -848,6 +848,11 @@ setx PATH "%PATH%;{0}" Failed to uninstall tool package '{0}': {1} + + Column maximum width must be greater than zero. + Column maximum width must be greater than zero. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.ja.xlf b/src/dotnet/xlf/CommonLocalizableStrings.ja.xlf index b5938c333..9fe190d9c 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.ja.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.ja.xlf @@ -848,6 +848,11 @@ setx PATH "%PATH%;{0}" Failed to uninstall tool package '{0}': {1} + + Column maximum width must be greater than zero. + Column maximum width must be greater than zero. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.ko.xlf b/src/dotnet/xlf/CommonLocalizableStrings.ko.xlf index 99f97468e..0055c89c2 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.ko.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.ko.xlf @@ -848,6 +848,11 @@ setx PATH "%PATH%;{0}" Failed to uninstall tool package '{0}': {1} + + Column maximum width must be greater than zero. + Column maximum width must be greater than zero. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.pl.xlf b/src/dotnet/xlf/CommonLocalizableStrings.pl.xlf index e86850a1a..84ab68ba8 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.pl.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.pl.xlf @@ -848,6 +848,11 @@ setx PATH "%PATH%;{0}" Failed to uninstall tool package '{0}': {1} + + Column maximum width must be greater than zero. + Column maximum width must be greater than zero. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.pt-BR.xlf b/src/dotnet/xlf/CommonLocalizableStrings.pt-BR.xlf index 1e77c8746..93c4e1338 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.pt-BR.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.pt-BR.xlf @@ -848,6 +848,11 @@ setx PATH "%PATH%;{0}" Failed to uninstall tool package '{0}': {1} + + Column maximum width must be greater than zero. + Column maximum width must be greater than zero. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.ru.xlf b/src/dotnet/xlf/CommonLocalizableStrings.ru.xlf index 2804b423c..8f686a333 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.ru.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.ru.xlf @@ -848,6 +848,11 @@ setx PATH "%PATH%;{0}" Failed to uninstall tool package '{0}': {1} + + Column maximum width must be greater than zero. + Column maximum width must be greater than zero. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.tr.xlf b/src/dotnet/xlf/CommonLocalizableStrings.tr.xlf index 3d6889704..22d6637a9 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.tr.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.tr.xlf @@ -848,6 +848,11 @@ setx PATH "%PATH%;{0}" Failed to uninstall tool package '{0}': {1} + + Column maximum width must be greater than zero. + Column maximum width must be greater than zero. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.zh-Hans.xlf b/src/dotnet/xlf/CommonLocalizableStrings.zh-Hans.xlf index d6bd07db3..14b24e453 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.zh-Hans.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.zh-Hans.xlf @@ -848,6 +848,11 @@ setx PATH "%PATH%;{0}" Failed to uninstall tool package '{0}': {1} + + Column maximum width must be greater than zero. + Column maximum width must be greater than zero. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.zh-Hant.xlf b/src/dotnet/xlf/CommonLocalizableStrings.zh-Hant.xlf index 52f904b87..01e11d97a 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.zh-Hant.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.zh-Hant.xlf @@ -848,6 +848,11 @@ setx PATH "%PATH%;{0}" Failed to uninstall tool package '{0}': {1} + + Column maximum width must be greater than zero. + Column maximum width must be greater than zero. + + \ No newline at end of file diff --git a/test/dotnet.Tests/PrintableTableTests.cs b/test/dotnet.Tests/PrintableTableTests.cs new file mode 100644 index 000000000..68737e541 --- /dev/null +++ b/test/dotnet.Tests/PrintableTableTests.cs @@ -0,0 +1,420 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; +using FluentAssertions; +using Microsoft.DotNet.Cli; +using Microsoft.DotNet.Tools.Test.Utilities; +using Xunit; + +namespace Microsoft.DotNet.Tests +{ + public class PrintableTableTests : TestBase + { + [Fact] + public void GivenNoColumnsItPrintsNoLines() + { + var table = new PrintableTable(); + + var lines = new List(); + table.PrintRows(new string[][] {}, l => lines.Add(l)); + + lines.Should().BeEmpty(); + } + + [Fact] + public void GivenAnEmptyRowsCollectionItPrintsColumnHeaders() + { + RunTest(new TestData() { + Columns = new[] { + "First Column", + "2nd Column", + "Another Column" + }, + Rows = new string[][] { + }, + ExpectedLines = new[] { + "First Column 2nd Column Another Column", + "------------------------------------------------" + }, + ExpectedTableWidth = 48 + }); + } + + [Fact] + public void GivenASingleRowItPrintsCorrectly() + { + RunTest(new TestData() { + Columns = new[] { + "1st", + "2nd", + "3rd" + }, + Rows = new string[][] { + new[] { + "first", + "second", + "third" + } + }, + ExpectedLines = new[] { + "1st 2nd 3rd ", + "----------------------------", + "first second third" + }, + ExpectedTableWidth = 28 + }); + } + + [Fact] + public void GivenMultipleRowsItPrintsCorrectly() + { + RunTest(new TestData() { + Columns = new[] { + "First", + "Second", + "Third", + "Fourth", + "Fifth" + }, + Rows = new string[][] { + new[] { + "1st", + "2nd", + "3rd", + "4th", + "5th" + }, + new [] { + "a", + "b", + "c", + "d", + "e" + }, + new [] { + "much longer string 1", + "much longer string 2", + "much longer string 3", + "much longer string 4", + "much longer string 5", + } + }, + ExpectedLines = new[] { + "First Second Third Fourth Fifth ", + "----------------------------------------------------------------------------------------------------------------------------", + "1st 2nd 3rd 4th 5th ", + "a b c d e ", + "much longer string 1 much longer string 2 much longer string 3 much longer string 4 much longer string 5" + }, + ExpectedTableWidth = 124 + }); + } + + [Fact] + public void GivenARowWithEmptyStringsItPrintsCorrectly() + { + RunTest(new TestData() { + Columns = new[] { + "First", + "Second", + "Third", + "Fourth", + "Fifth" + }, + Rows = new string[][] { + new[] { + "1st", + "2nd", + "3rd", + "4th", + "5th" + }, + new [] { + "", + "", + "", + "", + "" + }, + new [] { + "much longer string 1", + "much longer string 2", + "much longer string 3", + "much longer string 4", + "much longer string 5", + } + }, + ExpectedLines = new[] { + "First Second Third Fourth Fifth ", + "----------------------------------------------------------------------------------------------------------------------------", + "1st 2nd 3rd 4th 5th ", + " ", + "much longer string 1 much longer string 2 much longer string 3 much longer string 4 much longer string 5" + }, + ExpectedTableWidth = 124 + }); + } + + [Fact] + public void GivenColumnsWithMaximumWidthsItPrintsCorrectly() + { + RunTest(new TestData() { + Columns = new[] { + "First", + "Second", + "Third", + }, + ColumnWidths = new[] { + 3, + int.MaxValue, + 4 + }, + Rows = new string[][] { + new[] { + "123", + "1234567890", + "1234" + }, + new [] { + "1", + "1", + "1", + }, + new [] { + "12345", + "a much longer string", + "1234567890" + }, + new [] { + "123456", + "hello world", + "12345678" + } + }, + ExpectedLines = new[] { + "Fir Second Thir", + "st d ", + "---------------------------------------", + "123 1234567890 1234", + "1 1 1 ", + "123 a much longer string 1234", + "45 5678", + " 90 ", + "123 hello world 1234", + "456 5678" + }, + ExpectedTableWidth = 39 + }); + } + + [Fact] + public void GivenARowContainingUnicodeCharactersItPrintsCorrectly() + { + RunTest(new TestData() { + Columns = new[] { + "Poem" + }, + Rows = new string[][] { + new [] { + "\u3044\u308D\u306F\u306B\u307B\u3078\u3068\u3061\u308A\u306C\u308B\u3092" + } + }, + ExpectedLines = new[] { + "Poem ", + "------------", + "\u3044\u308D\u306F\u306B\u307B\u3078\u3068\u3061\u308A\u306C\u308B\u3092" + }, + ExpectedTableWidth = 12 + }); + } + + [Fact] + public void GivenARowContainingUnicodeCharactersItWrapsCorrectly() + { + RunTest(new TestData() { + Columns = new[] { + "Poem" + }, + ColumnWidths = new [] { + 5 + }, + Rows = new string[][] { + new [] { + "\u3044\u308D\u306F\u306B\u307B\u3078\u3068\u3061\u308A\u306C\u308B\u3092" + } + }, + ExpectedLines = new[] { + "Poem ", + "-----", + "\u3044\u308D\u306F\u306B\u307B", + "\u3078\u3068\u3061\u308A\u306C", + "\u308B\u3092 " + }, + ExpectedTableWidth = 5 + }); + } + + [Fact] + public void GivenARowContainingUnicodeCombiningCharactersItPrintsCorrectly() + { + // The unicode string is "test" with "enclosing circle backslash" around each character + // Given 0x20E0 is a combining character, the string should be four graphemes in length, + // despite having eight codepoints. Thus there should be 10 spaces following the characters. + RunTest(new TestData() { + Columns = new[] { + "Unicode String" + }, + Rows = new string[][] { + new [] { + "\u0074\u20E0\u0065\u20E0\u0073\u20E0\u0074\u20E0" + } + }, + ExpectedLines = new[] { + "Unicode String", + "--------------", + "\u0074\u20E0\u0065\u20E0\u0073\u20E0\u0074\u20E0 " + }, + ExpectedTableWidth = 14 + }); + } + + [Fact] + public void GivenARowContainingUnicodeCombiningCharactersItWrapsCorrectly() + { + // See comment for GivenARowContainingUnicodeCombiningCharactersItPrintsCorrectly regarding string content + // This should wrap after the second grapheme rather than the second code point (constituting the first grapheme) + RunTest(new TestData() { + Columns = new[] { + "01" + }, + ColumnWidths = new[] { + 2 + }, + Rows = new string[][] { + new [] { + "\u0074\u20E0\u0065\u20E0\u0073\u20E0\u0074\u20E0" + } + }, + ExpectedLines = new[] { + "01", + "--", + "\u0074\u20E0\u0065\u20E0", + "\u0073\u20E0\u0074\u20E0" + }, + ExpectedTableWidth = 2 + }); + } + + [Fact] + public void GivenAnEmptyColumnHeaderItPrintsTheColumnHeaderAsEmpty() + { + RunTest(new TestData() { + Columns = new[] { + "First", + "", + "Third", + }, + Rows = new string[][] { + new[] { + "1st", + "2nd", + "3rd" + } + }, + ExpectedLines = new[] { + "First Third", + "-------------------------", + "1st 2nd 3rd " + }, + ExpectedTableWidth = 25 + }); + } + + [Fact] + public void GivenAllEmptyColumnHeadersItPrintsTheEntireHeaderAsEmpty() + { + RunTest(new TestData() { + Columns = new[] { + null, + "", + null, + }, + Rows = new string[][] { + new[] { + "1st", + "2nd", + "3rd" + } + }, + ExpectedLines = new[] { + " ", + "---------------------", + "1st 2nd 3rd" + }, + ExpectedTableWidth = 21 + }); + } + + [Fact] + public void GivenZeroWidthColumnsItSkipsTheColumns() + { + RunTest(new TestData() { + Columns = new[] { + "", + "First", + null, + "Second", + "" + }, + Rows = new string[][] { + new[] { + "", + "1st", + null, + "2nd", + "" + } + }, + ExpectedLines = new[] { + "First Second", + "-----------------", + "1st 2nd " + }, + ExpectedTableWidth = 17 + }); + } + + public class TestData + { + public IEnumerable Columns { get; set; } + public int[] ColumnWidths { get; set; } + public IEnumerable Rows { get; set; } + public IEnumerable ExpectedLines { get; set; } + public int ExpectedTableWidth { get; set; } + } + + private void RunTest(TestData data) + { + var table = new PrintableTable(); + + int index = 0; + foreach (var column in data.Columns) + { + var i = index; + table.AddColumn( + column, + r => r[i], + data.ColumnWidths?[i] ?? int.MaxValue); + ++index; + } + + var lines = new List(); + table.PrintRows(data.Rows, l => lines.Add(l)); + + lines.Should().Equal(data.ExpectedLines); + table.CalculateWidth(data.Rows).Should().Be(data.ExpectedTableWidth); + } + } +} From 4490fd5aa841f2d3d9fad6a64e97e15663b32653 Mon Sep 17 00:00:00 2001 From: Peter Huene Date: Wed, 21 Feb 2018 18:34:25 -0800 Subject: [PATCH 4/6] Implement `list tool` command. This commit implements the `list tool` command. The command is responsible for displaying a list of install global tools. Fixes #8548. --- src/dotnet/CommonLocalizableStrings.resx | 8 +- src/dotnet/ToolPackage/IToolPackageStore.cs | 2 +- src/dotnet/ToolPackage/ToolPackageInstance.cs | 17 +-- src/dotnet/ToolPackage/ToolPackageStore.cs | 30 +++- .../dotnet-help/LocalizableStrings.resx | 2 +- .../dotnet-help/xlf/LocalizableStrings.cs.xlf | 4 +- .../dotnet-help/xlf/LocalizableStrings.de.xlf | 4 +- .../dotnet-help/xlf/LocalizableStrings.es.xlf | 4 +- .../dotnet-help/xlf/LocalizableStrings.fr.xlf | 4 +- .../dotnet-help/xlf/LocalizableStrings.it.xlf | 4 +- .../dotnet-help/xlf/LocalizableStrings.ja.xlf | 4 +- .../dotnet-help/xlf/LocalizableStrings.ko.xlf | 4 +- .../dotnet-help/xlf/LocalizableStrings.pl.xlf | 4 +- .../xlf/LocalizableStrings.pt-BR.xlf | 4 +- .../dotnet-help/xlf/LocalizableStrings.ru.xlf | 4 +- .../dotnet-help/xlf/LocalizableStrings.tr.xlf | 4 +- .../xlf/LocalizableStrings.zh-Hans.xlf | 4 +- .../xlf/LocalizableStrings.zh-Hant.xlf | 4 +- .../{Program.cs => ListCommand.cs} | 12 +- .../commands/dotnet-list/ListCommandParser.cs | 28 ++-- ... ListProjectToProjectReferencesCommand.cs} | 2 +- ...ProjectToProjectReferencesCommandParser.cs | 20 +++ .../LocalizableStrings.resx | 2 +- .../dotnet-list-tool/ListToolCommand.cs | 88 +++++++++++ .../dotnet-list-tool/ListToolCommandParser.cs | 23 +++ .../dotnet-list-tool/LocalizableStrings.resx | 141 ++++++++++++++++++ .../xlf/LocalizableStrings.cs.xlf | 42 ++++++ .../xlf/LocalizableStrings.de.xlf | 42 ++++++ .../xlf/LocalizableStrings.es.xlf | 42 ++++++ .../xlf/LocalizableStrings.fr.xlf | 42 ++++++ .../xlf/LocalizableStrings.it.xlf | 42 ++++++ .../xlf/LocalizableStrings.ja.xlf | 42 ++++++ .../xlf/LocalizableStrings.ko.xlf | 42 ++++++ .../xlf/LocalizableStrings.pl.xlf | 42 ++++++ .../xlf/LocalizableStrings.pt-BR.xlf | 42 ++++++ .../xlf/LocalizableStrings.ru.xlf | 42 ++++++ .../xlf/LocalizableStrings.tr.xlf | 42 ++++++ .../xlf/LocalizableStrings.zh-Hans.xlf | 42 ++++++ .../xlf/LocalizableStrings.zh-Hant.xlf | 42 ++++++ .../tool/UninstallToolCommand.cs | 6 +- src/dotnet/dotnet.csproj | 1 + .../xlf/CommonLocalizableStrings.cs.xlf | 20 +-- .../xlf/CommonLocalizableStrings.de.xlf | 20 +-- .../xlf/CommonLocalizableStrings.es.xlf | 20 +-- .../xlf/CommonLocalizableStrings.fr.xlf | 20 +-- .../xlf/CommonLocalizableStrings.it.xlf | 20 +-- .../xlf/CommonLocalizableStrings.ja.xlf | 20 +-- .../xlf/CommonLocalizableStrings.ko.xlf | 20 +-- .../xlf/CommonLocalizableStrings.pl.xlf | 20 +-- .../xlf/CommonLocalizableStrings.pt-BR.xlf | 20 +-- .../xlf/CommonLocalizableStrings.ru.xlf | 20 +-- .../xlf/CommonLocalizableStrings.tr.xlf | 20 +-- .../xlf/CommonLocalizableStrings.zh-Hans.xlf | 20 +-- .../xlf/CommonLocalizableStrings.zh-Hant.xlf | 20 +-- ...ivenThatIWantToShowHelpForDotnetCommand.cs | 2 +- .../GivenDotnetListReference.cs | 1 + 56 files changed, 1043 insertions(+), 200 deletions(-) rename src/dotnet/commands/dotnet-list/{Program.cs => ListCommand.cs} (83%) rename src/dotnet/commands/dotnet-list/dotnet-list-reference/{Program.cs => ListProjectToProjectReferencesCommand.cs} (99%) create mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-reference/ListProjectToProjectReferencesCommandParser.cs create mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-tool/ListToolCommand.cs create mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-tool/ListToolCommandParser.cs create mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-tool/LocalizableStrings.resx create mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.cs.xlf create mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.de.xlf create mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.es.xlf create mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.fr.xlf create mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.it.xlf create mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.ja.xlf create mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.ko.xlf create mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.pl.xlf create mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.pt-BR.xlf create mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.ru.xlf create mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.tr.xlf create mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.zh-Hans.xlf create mode 100644 src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.zh-Hant.xlf diff --git a/src/dotnet/CommonLocalizableStrings.resx b/src/dotnet/CommonLocalizableStrings.resx index ea905e472..77847a864 100644 --- a/src/dotnet/CommonLocalizableStrings.resx +++ b/src/dotnet/CommonLocalizableStrings.resx @@ -610,11 +610,11 @@ setx PATH "%PATH%;{0}" Failed to uninstall tool package '{0}': {1} - - Package '{0}' is missing entry point file {1}. + + Entry point file '{0}' for command '{1}' was not found in the package. - - Package '{0}' is missing tool settings file DotnetToolSettings.xml. + + Settings file 'DotnetToolSettings.xml' was not found in the package. Tool '{0}' (version '{1}') is already installed. diff --git a/src/dotnet/ToolPackage/IToolPackageStore.cs b/src/dotnet/ToolPackage/IToolPackageStore.cs index 31bea417f..72105d24d 100644 --- a/src/dotnet/ToolPackage/IToolPackageStore.cs +++ b/src/dotnet/ToolPackage/IToolPackageStore.cs @@ -11,6 +11,6 @@ namespace Microsoft.DotNet.ToolPackage { DirectoryPath Root { get; } - IEnumerable GetInstalledPackages(string packageId); + IEnumerable GetInstalledPackages(string packageId = null); } } diff --git a/src/dotnet/ToolPackage/ToolPackageInstance.cs b/src/dotnet/ToolPackage/ToolPackageInstance.cs index 0d28cfe97..5841c2ef6 100644 --- a/src/dotnet/ToolPackage/ToolPackageInstance.cs +++ b/src/dotnet/ToolPackage/ToolPackageInstance.cs @@ -109,10 +109,8 @@ namespace Microsoft.DotNet.ToolPackage var dotnetToolSettings = FindItemInTargetLibrary(library, ToolSettingsFileName); if (dotnetToolSettings == null) { - throw new ToolPackageException( - string.Format( - CommonLocalizableStrings.ToolPackageMissingSettingsFile, - PackageId)); + throw new ToolConfigurationException( + CommonLocalizableStrings.MissingToolSettingsFile); } var toolConfigurationPath = @@ -127,11 +125,11 @@ namespace Microsoft.DotNet.ToolPackage var entryPointFromLockFile = FindItemInTargetLibrary(library, configuration.ToolAssemblyEntryPoint); if (entryPointFromLockFile == null) { - throw new ToolPackageException( + throw new ToolConfigurationException( string.Format( - CommonLocalizableStrings.ToolPackageMissingEntryPointFile, - PackageId, - configuration.ToolAssemblyEntryPoint)); + CommonLocalizableStrings.MissingToolEntryPointFile, + configuration.ToolAssemblyEntryPoint, + configuration.CommandName)); } // Currently only "dotnet" commands are supported @@ -148,10 +146,9 @@ namespace Microsoft.DotNet.ToolPackage } catch (Exception ex) when (ex is UnauthorizedAccessException || ex is IOException) { - throw new ToolPackageException( + throw new ToolConfigurationException( string.Format( CommonLocalizableStrings.FailedToRetrieveToolConfiguration, - PackageId, ex.Message), ex); } diff --git a/src/dotnet/ToolPackage/ToolPackageStore.cs b/src/dotnet/ToolPackage/ToolPackageStore.cs index d2a9f79f1..f9575a9cc 100644 --- a/src/dotnet/ToolPackage/ToolPackageStore.cs +++ b/src/dotnet/ToolPackage/ToolPackageStore.cs @@ -15,13 +15,37 @@ namespace Microsoft.DotNet.ToolPackage public DirectoryPath Root { get; private set; } - public IEnumerable GetInstalledPackages(string packageId) + public IEnumerable GetInstalledPackages(string packageId = null) { - if (packageId == null) + if (packageId != null) { - throw new ArgumentNullException(nameof(packageId)); + return EnumerateVersions(packageId); } + return EnumerateAllPackages().SelectMany(p => p); + } + + private IEnumerable> EnumerateAllPackages() + { + if (!Directory.Exists(Root.Value)) + { + yield break; + } + + foreach (var subdirectory in Directory.EnumerateDirectories(Root.Value)) + { + var packageId = Path.GetFileName(subdirectory); + if (packageId == ToolPackageInstaller.StagingDirectory) + { + continue; + } + + yield return EnumerateVersions(packageId); + } + } + + private IEnumerable EnumerateVersions(string packageId) + { var packageRootDirectory = Root.WithSubDirectories(packageId); if (!Directory.Exists(packageRootDirectory.Value)) { diff --git a/src/dotnet/commands/dotnet-help/LocalizableStrings.resx b/src/dotnet/commands/dotnet-help/LocalizableStrings.resx index 77e1429ed..5c4f125dc 100644 --- a/src/dotnet/commands/dotnet-help/LocalizableStrings.resx +++ b/src/dotnet/commands/dotnet-help/LocalizableStrings.resx @@ -193,7 +193,7 @@ Remove reference from the project. - List reference in the project. + List project references or installed tools. Advanced Commands diff --git a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.cs.xlf b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.cs.xlf index c7e572fee..2075f923e 100644 --- a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.cs.xlf +++ b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.cs.xlf @@ -153,8 +153,8 @@ - List reference in the project. - Vypíše odkaz v projektu. + List project references or installed tools. + Vypíše odkaz v projektu. diff --git a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.de.xlf b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.de.xlf index 76a830a57..b5105534b 100644 --- a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.de.xlf +++ b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.de.xlf @@ -153,8 +153,8 @@ - List reference in the project. - Verweis im Projekt auflisten. + List project references or installed tools. + Verweis im Projekt auflisten. diff --git a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.es.xlf b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.es.xlf index 156b555db..2c4f24649 100644 --- a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.es.xlf +++ b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.es.xlf @@ -153,8 +153,8 @@ - List reference in the project. - Muestra referencias en el proyecto. + List project references or installed tools. + Muestra referencias en el proyecto. diff --git a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.fr.xlf b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.fr.xlf index 0c7b146c3..4b69ddc7f 100644 --- a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.fr.xlf +++ b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.fr.xlf @@ -153,8 +153,8 @@ - List reference in the project. - Listez une référence dans le projet. + List project references or installed tools. + Listez une référence dans le projet. diff --git a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.it.xlf b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.it.xlf index c82936c0d..737a25340 100644 --- a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.it.xlf +++ b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.it.xlf @@ -153,8 +153,8 @@ - List reference in the project. - Elenca il riferimento nel progetto. + List project references or installed tools. + Elenca il riferimento nel progetto. diff --git a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ja.xlf b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ja.xlf index 676fb4114..a7ed545eb 100644 --- a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ja.xlf +++ b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ja.xlf @@ -153,8 +153,8 @@ - List reference in the project. - プロジェクト内の参照を一覧表示します。 + List project references or installed tools. + プロジェクト内の参照を一覧表示します。 diff --git a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ko.xlf b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ko.xlf index dacf14f0b..d89150949 100644 --- a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ko.xlf +++ b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ko.xlf @@ -153,8 +153,8 @@ - List reference in the project. - 프로젝트의 참조를 나열합니다. + List project references or installed tools. + 프로젝트의 참조를 나열합니다. diff --git a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.pl.xlf b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.pl.xlf index 3ef41efc3..4e39e715c 100644 --- a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.pl.xlf +++ b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.pl.xlf @@ -153,8 +153,8 @@ - List reference in the project. - Wyświetl odwołanie w projekcie. + List project references or installed tools. + Wyświetl odwołanie w projekcie. diff --git a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.pt-BR.xlf b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.pt-BR.xlf index b6356780c..320d69e59 100644 --- a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.pt-BR.xlf +++ b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.pt-BR.xlf @@ -153,8 +153,8 @@ - List reference in the project. - Listar referência no projeto. + List project references or installed tools. + Listar referência no projeto. diff --git a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ru.xlf b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ru.xlf index 392df0743..bb7487a5e 100644 --- a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ru.xlf +++ b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.ru.xlf @@ -153,8 +153,8 @@ - List reference in the project. - Список ссылок в проекте. + List project references or installed tools. + Список ссылок в проекте. diff --git a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.tr.xlf b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.tr.xlf index a168014f1..b192fb32a 100644 --- a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.tr.xlf +++ b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.tr.xlf @@ -153,8 +153,8 @@ - List reference in the project. - Projede başvuruyu listeleyin. + List project references or installed tools. + Projede başvuruyu listeleyin. diff --git a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.zh-Hans.xlf b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.zh-Hans.xlf index 5940a4217..c3bb4684f 100644 --- a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.zh-Hans.xlf +++ b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.zh-Hans.xlf @@ -153,8 +153,8 @@ - List reference in the project. - 列出项目中的引用。 + List project references or installed tools. + 列出项目中的引用。 diff --git a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.zh-Hant.xlf b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.zh-Hant.xlf index 2babfcb51..6247cdae5 100644 --- a/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.zh-Hant.xlf +++ b/src/dotnet/commands/dotnet-help/xlf/LocalizableStrings.zh-Hant.xlf @@ -153,8 +153,8 @@ - List reference in the project. - 列出專案中的參考。 + List project references or installed tools. + 列出專案中的參考。 diff --git a/src/dotnet/commands/dotnet-list/Program.cs b/src/dotnet/commands/dotnet-list/ListCommand.cs similarity index 83% rename from src/dotnet/commands/dotnet-list/Program.cs rename to src/dotnet/commands/dotnet-list/ListCommand.cs index 403302b39..969a44179 100644 --- a/src/dotnet/commands/dotnet-list/Program.cs +++ b/src/dotnet/commands/dotnet-list/ListCommand.cs @@ -7,6 +7,7 @@ using Microsoft.DotNet.Cli; using Microsoft.DotNet.Cli.CommandLine; using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Tools.List.ProjectToProjectReferences; +using Microsoft.DotNet.Tools.List.Tool; namespace Microsoft.DotNet.Tools.List { @@ -22,16 +23,17 @@ namespace Microsoft.DotNet.Tools.List { { "reference", - o => new ListProjectToProjectReferencesCommand( - o, - ParseResult) + o => new ListProjectToProjectReferencesCommand(o, ParseResult) + }, + { + "tool", + o => new ListToolCommand(o["tool"], ParseResult) } }; public static int Run(string[] args) { - var command = new ListCommand(); - return command.RunCommand(args); + return new ListCommand().RunCommand(args); } } } \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/ListCommandParser.cs b/src/dotnet/commands/dotnet-list/ListCommandParser.cs index 1fee43e0f..1f2bb48d8 100644 --- a/src/dotnet/commands/dotnet-list/ListCommandParser.cs +++ b/src/dotnet/commands/dotnet-list/ListCommandParser.cs @@ -3,24 +3,24 @@ using Microsoft.DotNet.Cli.CommandLine; using Microsoft.DotNet.Tools; +using Microsoft.DotNet.Tools.List.ProjectToProjectReferences; +using Microsoft.DotNet.Tools.List.Tool; using LocalizableStrings = Microsoft.DotNet.Tools.List.LocalizableStrings; namespace Microsoft.DotNet.Cli { internal static class ListCommandParser { - public static Command List() => - Create.Command("list", - LocalizableStrings.NetListCommand, - Accept.ZeroOrOneArgument() - .With(name: CommonLocalizableStrings.CmdProjectFile, - description: - CommonLocalizableStrings.ArgumentsProjectDescription) - .DefaultToCurrentDirectory(), - CommonOptions.HelpOption(), - Create.Command("reference", - Tools.List.ProjectToProjectReferences.LocalizableStrings.AppFullName, - Accept.ZeroOrOneArgument(), - CommonOptions.HelpOption())); + public static Command List() => Create.Command( + "list", + LocalizableStrings.NetListCommand, + Accept.ZeroOrOneArgument() + .With( + name: CommonLocalizableStrings.CmdProjectFile, + description: CommonLocalizableStrings.ArgumentsProjectDescription) + .DefaultToCurrentDirectory(), + CommonOptions.HelpOption(), + ListProjectToProjectReferencesCommandParser.ListProjectToProjectReferences(), + ListToolCommandParser.ListTool()); } -} \ No newline at end of file +} diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-reference/Program.cs b/src/dotnet/commands/dotnet-list/dotnet-list-reference/ListProjectToProjectReferencesCommand.cs similarity index 99% rename from src/dotnet/commands/dotnet-list/dotnet-list-reference/Program.cs rename to src/dotnet/commands/dotnet-list/dotnet-list-reference/ListProjectToProjectReferencesCommand.cs index 7a4f3cb18..0a25c1a8c 100644 --- a/src/dotnet/commands/dotnet-list/dotnet-list-reference/Program.cs +++ b/src/dotnet/commands/dotnet-list/dotnet-list-reference/ListProjectToProjectReferencesCommand.cs @@ -50,4 +50,4 @@ namespace Microsoft.DotNet.Tools.List.ProjectToProjectReferences return 0; } } -} \ No newline at end of file +} diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-reference/ListProjectToProjectReferencesCommandParser.cs b/src/dotnet/commands/dotnet-list/dotnet-list-reference/ListProjectToProjectReferencesCommandParser.cs new file mode 100644 index 000000000..b0bf62e12 --- /dev/null +++ b/src/dotnet/commands/dotnet-list/dotnet-list-reference/ListProjectToProjectReferencesCommandParser.cs @@ -0,0 +1,20 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.DotNet.Cli.CommandLine; +using LocalizableStrings = Microsoft.DotNet.Tools.List.ProjectToProjectReferences.LocalizableStrings; + +namespace Microsoft.DotNet.Cli +{ + internal static class ListProjectToProjectReferencesCommandParser + { + public static Command ListProjectToProjectReferences() + { + return Create.Command( + "reference", + LocalizableStrings.AppFullName, + Accept.ZeroOrOneArgument(), + CommonOptions.HelpOption()); + } + } +} diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-reference/LocalizableStrings.resx b/src/dotnet/commands/dotnet-list/dotnet-list-reference/LocalizableStrings.resx index 5536ff5ef..887c6c584 100644 --- a/src/dotnet/commands/dotnet-list/dotnet-list-reference/LocalizableStrings.resx +++ b/src/dotnet/commands/dotnet-list/dotnet-list-reference/LocalizableStrings.resx @@ -127,4 +127,4 @@ There are no {0} references in project {1}. {0} is the type of the item being requested (project, package, p2p) and {1} is the object operated on (a project file or a solution file). - \ No newline at end of file + diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-tool/ListToolCommand.cs b/src/dotnet/commands/dotnet-list/dotnet-list-tool/ListToolCommand.cs new file mode 100644 index 000000000..b732ba3a8 --- /dev/null +++ b/src/dotnet/commands/dotnet-list/dotnet-list-tool/ListToolCommand.cs @@ -0,0 +1,88 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.DotNet.Cli; +using Microsoft.DotNet.Cli.CommandLine; +using Microsoft.DotNet.Cli.Utils; +using Microsoft.DotNet.Configurer; +using Microsoft.DotNet.ToolPackage; +using Microsoft.Extensions.EnvironmentAbstractions; + +namespace Microsoft.DotNet.Tools.List.Tool +{ + internal class ListToolCommand : CommandBase + { + private const string CommandDelimiter = ", "; + private readonly AppliedOption _options; + private readonly IToolPackageStore _toolPackageStore; + private readonly IReporter _reporter; + private readonly IReporter _errorReporter; + + public ListToolCommand( + AppliedOption options, + ParseResult result, + IToolPackageStore toolPackageStore = null, + IReporter reporter = null) + : base(result) + { + _options = options ?? throw new ArgumentNullException(nameof(options)); + _toolPackageStore = toolPackageStore ?? new ToolPackageStore( + new DirectoryPath(new CliFolderPathCalculator().ToolsPackagePath)); + _reporter = reporter ?? Reporter.Output; + _errorReporter = reporter ?? Reporter.Error; + } + + public override int Execute() + { + if (!_options.ValueOrDefault("global")) + { + throw new GracefulException(LocalizableStrings.ListToolCommandOnlySupportsGlobal); + } + + var table = new PrintableTable(); + + table.AddColumn( + LocalizableStrings.PackageIdColumn, + p => p.PackageId); + table.AddColumn( + LocalizableStrings.VersionColumn, + p => p.PackageVersion); + table.AddColumn( + LocalizableStrings.CommandsColumn, + p => string.Join(CommandDelimiter, p.Commands.Select(c => c.Name))); + + table.PrintRows(GetPackages(), l => _reporter.WriteLine(l)); + return 0; + } + + private IEnumerable GetPackages() + { + return _toolPackageStore.GetInstalledPackages() + .Where(PackageHasCommands) + .OrderBy(p => p.PackageId) + .ToArray(); + } + + private bool PackageHasCommands(IToolPackage p) + { + try + { + // Attempt to read the commands collection + // If it fails, print a warning and treat as no commands + return p.Commands.Count >= 0; + } + catch (Exception ex) when (ex is ToolConfigurationException) + { + _errorReporter.WriteLine( + string.Format( + LocalizableStrings.InvalidPackageWarning, + p.PackageId, + ex.Message).Yellow()); + return false; + } + } + } +} diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-tool/ListToolCommandParser.cs b/src/dotnet/commands/dotnet-list/dotnet-list-tool/ListToolCommandParser.cs new file mode 100644 index 000000000..c75e2e1ac --- /dev/null +++ b/src/dotnet/commands/dotnet-list/dotnet-list-tool/ListToolCommandParser.cs @@ -0,0 +1,23 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.DotNet.Cli.CommandLine; +using LocalizableStrings = Microsoft.DotNet.Tools.List.Tool.LocalizableStrings; + +namespace Microsoft.DotNet.Cli +{ + internal static class ListToolCommandParser + { + public static Command ListTool() + { + return Create.Command( + "tool", + LocalizableStrings.CommandDescription, + Create.Option( + "-g|--global", + LocalizableStrings.GlobalOptionDescription, + Accept.NoArguments()), + CommonOptions.HelpOption()); + } + } +} diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-tool/LocalizableStrings.resx b/src/dotnet/commands/dotnet-list/dotnet-list-tool/LocalizableStrings.resx new file mode 100644 index 000000000..b4d21c122 --- /dev/null +++ b/src/dotnet/commands/dotnet-list/dotnet-list-tool/LocalizableStrings.resx @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Lists installed tools in the current development environment. + + + List user wide tools. + + + The --global switch (-g) is currently required because only user wide tools are supported. + + + Warning: tool package '{0}' is invalid: {1} + + + Package Id + + + Version + + + Commands + + diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.cs.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.cs.xlf new file mode 100644 index 000000000..649e0ecf4 --- /dev/null +++ b/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.cs.xlf @@ -0,0 +1,42 @@ + + + + + + Lists installed tools in the current development environment. + Lists installed tools in the current development environment. + + + + List user wide tools. + List user wide tools. + + + + The --global switch (-g) is currently required because only user wide tools are supported. + The --global switch (-g) is currently required because only user wide tools are supported. + + + + Version + Version + + + + Commands + Commands + + + + Package Id + Package Id + + + + Warning: tool package '{0}' is invalid: {1} + Warning: tool package '{0}' is invalid: {1} + + + + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.de.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.de.xlf new file mode 100644 index 000000000..ea32b1a2c --- /dev/null +++ b/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.de.xlf @@ -0,0 +1,42 @@ + + + + + + Lists installed tools in the current development environment. + Lists installed tools in the current development environment. + + + + List user wide tools. + List user wide tools. + + + + The --global switch (-g) is currently required because only user wide tools are supported. + The --global switch (-g) is currently required because only user wide tools are supported. + + + + Version + Version + + + + Commands + Commands + + + + Package Id + Package Id + + + + Warning: tool package '{0}' is invalid: {1} + Warning: tool package '{0}' is invalid: {1} + + + + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.es.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.es.xlf new file mode 100644 index 000000000..65116604b --- /dev/null +++ b/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.es.xlf @@ -0,0 +1,42 @@ + + + + + + Lists installed tools in the current development environment. + Lists installed tools in the current development environment. + + + + List user wide tools. + List user wide tools. + + + + The --global switch (-g) is currently required because only user wide tools are supported. + The --global switch (-g) is currently required because only user wide tools are supported. + + + + Version + Version + + + + Commands + Commands + + + + Package Id + Package Id + + + + Warning: tool package '{0}' is invalid: {1} + Warning: tool package '{0}' is invalid: {1} + + + + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.fr.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.fr.xlf new file mode 100644 index 000000000..0f383597d --- /dev/null +++ b/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.fr.xlf @@ -0,0 +1,42 @@ + + + + + + Lists installed tools in the current development environment. + Lists installed tools in the current development environment. + + + + List user wide tools. + List user wide tools. + + + + The --global switch (-g) is currently required because only user wide tools are supported. + The --global switch (-g) is currently required because only user wide tools are supported. + + + + Version + Version + + + + Commands + Commands + + + + Package Id + Package Id + + + + Warning: tool package '{0}' is invalid: {1} + Warning: tool package '{0}' is invalid: {1} + + + + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.it.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.it.xlf new file mode 100644 index 000000000..33a6f2083 --- /dev/null +++ b/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.it.xlf @@ -0,0 +1,42 @@ + + + + + + Lists installed tools in the current development environment. + Lists installed tools in the current development environment. + + + + List user wide tools. + List user wide tools. + + + + The --global switch (-g) is currently required because only user wide tools are supported. + The --global switch (-g) is currently required because only user wide tools are supported. + + + + Version + Version + + + + Commands + Commands + + + + Package Id + Package Id + + + + Warning: tool package '{0}' is invalid: {1} + Warning: tool package '{0}' is invalid: {1} + + + + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.ja.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.ja.xlf new file mode 100644 index 000000000..c9e468b1a --- /dev/null +++ b/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.ja.xlf @@ -0,0 +1,42 @@ + + + + + + Lists installed tools in the current development environment. + Lists installed tools in the current development environment. + + + + List user wide tools. + List user wide tools. + + + + The --global switch (-g) is currently required because only user wide tools are supported. + The --global switch (-g) is currently required because only user wide tools are supported. + + + + Version + Version + + + + Commands + Commands + + + + Package Id + Package Id + + + + Warning: tool package '{0}' is invalid: {1} + Warning: tool package '{0}' is invalid: {1} + + + + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.ko.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.ko.xlf new file mode 100644 index 000000000..7d5475c1f --- /dev/null +++ b/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.ko.xlf @@ -0,0 +1,42 @@ + + + + + + Lists installed tools in the current development environment. + Lists installed tools in the current development environment. + + + + List user wide tools. + List user wide tools. + + + + The --global switch (-g) is currently required because only user wide tools are supported. + The --global switch (-g) is currently required because only user wide tools are supported. + + + + Version + Version + + + + Commands + Commands + + + + Package Id + Package Id + + + + Warning: tool package '{0}' is invalid: {1} + Warning: tool package '{0}' is invalid: {1} + + + + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.pl.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.pl.xlf new file mode 100644 index 000000000..5c81b12ec --- /dev/null +++ b/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.pl.xlf @@ -0,0 +1,42 @@ + + + + + + Lists installed tools in the current development environment. + Lists installed tools in the current development environment. + + + + List user wide tools. + List user wide tools. + + + + The --global switch (-g) is currently required because only user wide tools are supported. + The --global switch (-g) is currently required because only user wide tools are supported. + + + + Version + Version + + + + Commands + Commands + + + + Package Id + Package Id + + + + Warning: tool package '{0}' is invalid: {1} + Warning: tool package '{0}' is invalid: {1} + + + + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.pt-BR.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.pt-BR.xlf new file mode 100644 index 000000000..146703c1a --- /dev/null +++ b/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.pt-BR.xlf @@ -0,0 +1,42 @@ + + + + + + Lists installed tools in the current development environment. + Lists installed tools in the current development environment. + + + + List user wide tools. + List user wide tools. + + + + The --global switch (-g) is currently required because only user wide tools are supported. + The --global switch (-g) is currently required because only user wide tools are supported. + + + + Version + Version + + + + Commands + Commands + + + + Package Id + Package Id + + + + Warning: tool package '{0}' is invalid: {1} + Warning: tool package '{0}' is invalid: {1} + + + + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.ru.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.ru.xlf new file mode 100644 index 000000000..dfda07a01 --- /dev/null +++ b/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.ru.xlf @@ -0,0 +1,42 @@ + + + + + + Lists installed tools in the current development environment. + Lists installed tools in the current development environment. + + + + List user wide tools. + List user wide tools. + + + + The --global switch (-g) is currently required because only user wide tools are supported. + The --global switch (-g) is currently required because only user wide tools are supported. + + + + Version + Version + + + + Commands + Commands + + + + Package Id + Package Id + + + + Warning: tool package '{0}' is invalid: {1} + Warning: tool package '{0}' is invalid: {1} + + + + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.tr.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.tr.xlf new file mode 100644 index 000000000..f51db1c10 --- /dev/null +++ b/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.tr.xlf @@ -0,0 +1,42 @@ + + + + + + Lists installed tools in the current development environment. + Lists installed tools in the current development environment. + + + + List user wide tools. + List user wide tools. + + + + The --global switch (-g) is currently required because only user wide tools are supported. + The --global switch (-g) is currently required because only user wide tools are supported. + + + + Version + Version + + + + Commands + Commands + + + + Package Id + Package Id + + + + Warning: tool package '{0}' is invalid: {1} + Warning: tool package '{0}' is invalid: {1} + + + + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.zh-Hans.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.zh-Hans.xlf new file mode 100644 index 000000000..0473cd7d7 --- /dev/null +++ b/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.zh-Hans.xlf @@ -0,0 +1,42 @@ + + + + + + Lists installed tools in the current development environment. + Lists installed tools in the current development environment. + + + + List user wide tools. + List user wide tools. + + + + The --global switch (-g) is currently required because only user wide tools are supported. + The --global switch (-g) is currently required because only user wide tools are supported. + + + + Version + Version + + + + Commands + Commands + + + + Package Id + Package Id + + + + Warning: tool package '{0}' is invalid: {1} + Warning: tool package '{0}' is invalid: {1} + + + + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.zh-Hant.xlf b/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.zh-Hant.xlf new file mode 100644 index 000000000..34eadedae --- /dev/null +++ b/src/dotnet/commands/dotnet-list/dotnet-list-tool/xlf/LocalizableStrings.zh-Hant.xlf @@ -0,0 +1,42 @@ + + + + + + Lists installed tools in the current development environment. + Lists installed tools in the current development environment. + + + + List user wide tools. + List user wide tools. + + + + The --global switch (-g) is currently required because only user wide tools are supported. + The --global switch (-g) is currently required because only user wide tools are supported. + + + + Version + Version + + + + Commands + Commands + + + + Package Id + Package Id + + + + Warning: tool package '{0}' is invalid: {1} + Warning: tool package '{0}' is invalid: {1} + + + + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-uninstall/tool/UninstallToolCommand.cs b/src/dotnet/commands/dotnet-uninstall/tool/UninstallToolCommand.cs index c9778cd7a..d362e3838 100644 --- a/src/dotnet/commands/dotnet-uninstall/tool/UninstallToolCommand.cs +++ b/src/dotnet/commands/dotnet-uninstall/tool/UninstallToolCommand.cs @@ -67,9 +67,9 @@ namespace Microsoft.DotNet.Tools.Uninstall.Tool catch (InvalidOperationException) { _errorReporter.WriteLine( - string.Format( - LocalizableStrings.ToolHasMultipleVersionsInstalled, - packageId).Red()); + string.Format( + LocalizableStrings.ToolHasMultipleVersionsInstalled, + packageId).Red()); return 1; } diff --git a/src/dotnet/dotnet.csproj b/src/dotnet/dotnet.csproj index 6b17fb237..ecfeb2ba3 100644 --- a/src/dotnet/dotnet.csproj +++ b/src/dotnet/dotnet.csproj @@ -26,6 +26,7 @@ + diff --git a/src/dotnet/xlf/CommonLocalizableStrings.cs.xlf b/src/dotnet/xlf/CommonLocalizableStrings.cs.xlf index cde9c4124..8f0e7c10c 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.cs.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.cs.xlf @@ -694,16 +694,6 @@ Právě jste nainstalovali sadu .NET Core SDK, bude proto nutné před spuštěním nainstalovaného nástroje znovu otevřít okno příkazového řádku. - - Package '{0}' is missing entry point file {1}. - V balíčku {0} chybí soubor vstupního bodu {1}. - - - - Package '{0}' is missing tool settings file DotnetToolSettings.xml. - V balíčku {0} chybí soubor nastavení nástroje DotnetToolSettings.xml. - - Tool defines a command with a missing name setting. Nástroj definuje příkaz s chybějícím nastavením názvu. @@ -853,6 +843,16 @@ setx PATH "%PATH%;{0}" Column maximum width must be greater than zero. + + Entry point file '{0}' for command '{1}' was not found in the package. + Entry point file '{0}' for command '{1}' was not found in the package. + + + + Settings file 'DotnetToolSettings.xml' was not found in the package. + Settings file 'DotnetToolSettings.xml' was not found in the package. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.de.xlf b/src/dotnet/xlf/CommonLocalizableStrings.de.xlf index 2ea94a468..3a93064c3 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.de.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.de.xlf @@ -694,16 +694,6 @@ Da Sie gerade das .NET Core SDK installiert haben, müssen Sie das Eingabeaufforderungsfenster neu öffnen, bevor Sie das installierte Tool ausführen. - - Package '{0}' is missing entry point file {1}. - Im Paket "{0}" fehlt die Einstiegspunktdatei "{1}". - - - - Package '{0}' is missing tool settings file DotnetToolSettings.xml. - Im Paket "{0}" fehlt die Datei mit den Tooleinstellungen "DotnetToolSettings.xml". - - Tool defines a command with a missing name setting. Das Tool definiert einen Befehl mit fehlender Namenseinstellung. @@ -853,6 +843,16 @@ setx PATH "%PATH%;{0}" Column maximum width must be greater than zero. + + Entry point file '{0}' for command '{1}' was not found in the package. + Entry point file '{0}' for command '{1}' was not found in the package. + + + + Settings file 'DotnetToolSettings.xml' was not found in the package. + Settings file 'DotnetToolSettings.xml' was not found in the package. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.es.xlf b/src/dotnet/xlf/CommonLocalizableStrings.es.xlf index 0b2245c24..f283122ee 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.es.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.es.xlf @@ -694,16 +694,6 @@ Dado que acaba de instalar el SDK de .Net Core, tendrá que volver a abrir la ventana del símbolo del sistema antes de ejecutar la herramienta instalada. - - Package '{0}' is missing entry point file {1}. - Al paquete "{0}" le falta el archivo de punto de entrada {1}. - - - - Package '{0}' is missing tool settings file DotnetToolSettings.xml. - Al paquete "{0}" le falta el archivo de configuración de herramientas DotnetToolSettings.xml. - - Tool defines a command with a missing name setting. La herramienta define un comando en el que falta un valor de nombre. @@ -853,6 +843,16 @@ setx PATH "%PATH%;{0}" Column maximum width must be greater than zero. + + Entry point file '{0}' for command '{1}' was not found in the package. + Entry point file '{0}' for command '{1}' was not found in the package. + + + + Settings file 'DotnetToolSettings.xml' was not found in the package. + Settings file 'DotnetToolSettings.xml' was not found in the package. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.fr.xlf b/src/dotnet/xlf/CommonLocalizableStrings.fr.xlf index 347fa1778..3a668e77f 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.fr.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.fr.xlf @@ -694,16 +694,6 @@ Dans la mesure où vous venez d'installer le kit SDK .NET Core, vous devez rouvrir la fenêtre d'invite de commandes avant d'exécuter l'outil que vous avez installé. - - Package '{0}' is missing entry point file {1}. - Le package '{0}' ne contient pas le fichier de point d'entrée {1}. - - - - Package '{0}' is missing tool settings file DotnetToolSettings.xml. - Le package '{0}' ne contient pas le fichier de paramètres d'outils DotnetToolSettings.xml. - - Tool defines a command with a missing name setting. L'outil définit une commande avec un paramètre de nom manquant. @@ -853,6 +843,16 @@ setx PATH "%PATH%;{0}" Column maximum width must be greater than zero. + + Entry point file '{0}' for command '{1}' was not found in the package. + Entry point file '{0}' for command '{1}' was not found in the package. + + + + Settings file 'DotnetToolSettings.xml' was not found in the package. + Settings file 'DotnetToolSettings.xml' was not found in the package. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.it.xlf b/src/dotnet/xlf/CommonLocalizableStrings.it.xlf index 888a733b7..89d2e6f1e 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.it.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.it.xlf @@ -694,16 +694,6 @@ Dal momento che è stato appena installato .NET Core SDK, è necessario riaprire la finestra del prompt dei comandi prima di eseguire lo strumento installato. - - Package '{0}' is missing entry point file {1}. - Nel pacchetto '{0}' manca il file del punto di ingresso {1}. - - - - Package '{0}' is missing tool settings file DotnetToolSettings.xml. - Nel pacchetto '{0}' manca il file di impostazioni dello strumento DotnetToolSettings.xml. - - Tool defines a command with a missing name setting. Lo strumento definisce un comando con un'impostazione di nome mancante. @@ -853,6 +843,16 @@ setx PATH "%PATH%;{0}" Column maximum width must be greater than zero. + + Entry point file '{0}' for command '{1}' was not found in the package. + Entry point file '{0}' for command '{1}' was not found in the package. + + + + Settings file 'DotnetToolSettings.xml' was not found in the package. + Settings file 'DotnetToolSettings.xml' was not found in the package. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.ja.xlf b/src/dotnet/xlf/CommonLocalizableStrings.ja.xlf index 9fe190d9c..5d42dbf93 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.ja.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.ja.xlf @@ -694,16 +694,6 @@ .NET Core SDK をインストールしたばかりなので、インストールしたツールを実行する前に、コマンド プロンプト ウィンドウを再び開く必要があります。 - - Package '{0}' is missing entry point file {1}. - パッケージ '{0}' にエントリ ポイント ファイル {1} がありません。 - - - - Package '{0}' is missing tool settings file DotnetToolSettings.xml. - パッケージ '{0}' にツール設定ファイル DotnetToolSettings.xml がありません。 - - Tool defines a command with a missing name setting. ツールは、名前設定がないコマンドを定義します。 @@ -853,6 +843,16 @@ setx PATH "%PATH%;{0}" Column maximum width must be greater than zero. + + Entry point file '{0}' for command '{1}' was not found in the package. + Entry point file '{0}' for command '{1}' was not found in the package. + + + + Settings file 'DotnetToolSettings.xml' was not found in the package. + Settings file 'DotnetToolSettings.xml' was not found in the package. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.ko.xlf b/src/dotnet/xlf/CommonLocalizableStrings.ko.xlf index 0055c89c2..e136f3d5c 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.ko.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.ko.xlf @@ -694,16 +694,6 @@ .NET Core SDK를 방금 설치했기 때문에 설치한 도구를 실행하기 전에 명령 프롬프트 창을 다시 열어야 합니다. - - Package '{0}' is missing entry point file {1}. - 패키지 '{0}'이(가) 누락된 진입점 파일 {1}입니다. - - - - Package '{0}' is missing tool settings file DotnetToolSettings.xml. - 패키지 '{0}'이(가) 누락된 도구 설정 파일 DotnetToolSettings.xml입니다. - - Tool defines a command with a missing name setting. 도구에서 이름 설정 없이 명령을 정의합니다. @@ -853,6 +843,16 @@ setx PATH "%PATH%;{0}" Column maximum width must be greater than zero. + + Entry point file '{0}' for command '{1}' was not found in the package. + Entry point file '{0}' for command '{1}' was not found in the package. + + + + Settings file 'DotnetToolSettings.xml' was not found in the package. + Settings file 'DotnetToolSettings.xml' was not found in the package. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.pl.xlf b/src/dotnet/xlf/CommonLocalizableStrings.pl.xlf index 84ab68ba8..0a2d70abc 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.pl.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.pl.xlf @@ -694,16 +694,6 @@ Właśnie zainstalowano zestaw .NET Core SDK, dlatego należy ponownie otworzyć okno wiersza polecenia przed uruchomieniem zainstalowanego narzędzia. - - Package '{0}' is missing entry point file {1}. - Brak pliku punktu wejściowego {1} w pakiecie „{0}”. - - - - Package '{0}' is missing tool settings file DotnetToolSettings.xml. - Brak pliku ustawień narzędzia DotnetToolSettings.xml w pakiecie „{0}”. - - Tool defines a command with a missing name setting. Narzędzie definiuje polecenie z brakującym ustawieniem nazwy. @@ -853,6 +843,16 @@ setx PATH "%PATH%;{0}" Column maximum width must be greater than zero. + + Entry point file '{0}' for command '{1}' was not found in the package. + Entry point file '{0}' for command '{1}' was not found in the package. + + + + Settings file 'DotnetToolSettings.xml' was not found in the package. + Settings file 'DotnetToolSettings.xml' was not found in the package. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.pt-BR.xlf b/src/dotnet/xlf/CommonLocalizableStrings.pt-BR.xlf index 93c4e1338..81b666a10 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.pt-BR.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.pt-BR.xlf @@ -694,16 +694,6 @@ Já que você acabou de instalar o SDK do .NET Core, você ainda precisará reabrir a janela do Prompt de Comando antes de executar a ferramenta instalada. - - Package '{0}' is missing entry point file {1}. - O arquivo de ponto de entrada {1} está ausente do pacote '{0}'. - - - - Package '{0}' is missing tool settings file DotnetToolSettings.xml. - O arquivo de configuração DotnetToolSettings.xml da ferramenta está ausente do pacote '{0}'. - - Tool defines a command with a missing name setting. A ferramenta define um comando com uma configuração de nome ausente. @@ -853,6 +843,16 @@ setx PATH "%PATH%;{0}" Column maximum width must be greater than zero. + + Entry point file '{0}' for command '{1}' was not found in the package. + Entry point file '{0}' for command '{1}' was not found in the package. + + + + Settings file 'DotnetToolSettings.xml' was not found in the package. + Settings file 'DotnetToolSettings.xml' was not found in the package. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.ru.xlf b/src/dotnet/xlf/CommonLocalizableStrings.ru.xlf index 8f686a333..0926eee52 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.ru.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.ru.xlf @@ -694,16 +694,6 @@ Так как вы только что установили пакет SDK для .NET Core, перед его запуском нужно заново открыть окно командной строки. - - Package '{0}' is missing entry point file {1}. - В пакете "{0}" отсутствует файл точки входа {1}. - - - - Package '{0}' is missing tool settings file DotnetToolSettings.xml. - В пакете "{0}" отсутствует файл параметров инструмента DotnetToolSettings.xml. - - Tool defines a command with a missing name setting. Инструмент определяет команду, для которой не задано имя. @@ -853,6 +843,16 @@ setx PATH "%PATH%;{0}" Column maximum width must be greater than zero. + + Entry point file '{0}' for command '{1}' was not found in the package. + Entry point file '{0}' for command '{1}' was not found in the package. + + + + Settings file 'DotnetToolSettings.xml' was not found in the package. + Settings file 'DotnetToolSettings.xml' was not found in the package. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.tr.xlf b/src/dotnet/xlf/CommonLocalizableStrings.tr.xlf index 22d6637a9..3d316c24f 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.tr.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.tr.xlf @@ -694,16 +694,6 @@ .NET Core SDK’sını yüklediğinizden, yüklediğiniz aracı çalıştırmadan önce Komut İstemi penceresini yeniden açmanız gerekiyor. - - Package '{0}' is missing entry point file {1}. - '{0}' paketinde {1} giriş noktası dosyası eksik. - - - - Package '{0}' is missing tool settings file DotnetToolSettings.xml. - '{0}' paketinde DotnetToolSettings.xml araç ayarları dosyası eksik. - - Tool defines a command with a missing name setting. Araçta ad ayarı eksik bir komut tanımlanıyor. @@ -853,6 +843,16 @@ setx PATH "%PATH%;{0}" Column maximum width must be greater than zero. + + Entry point file '{0}' for command '{1}' was not found in the package. + Entry point file '{0}' for command '{1}' was not found in the package. + + + + Settings file 'DotnetToolSettings.xml' was not found in the package. + Settings file 'DotnetToolSettings.xml' was not found in the package. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.zh-Hans.xlf b/src/dotnet/xlf/CommonLocalizableStrings.zh-Hans.xlf index 14b24e453..b18d951b8 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.zh-Hans.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.zh-Hans.xlf @@ -694,16 +694,6 @@ 由于刚安装了 .NET Core SDK,因此在运行安装的工具之前,需要重新打开命令提示符窗口。 - - Package '{0}' is missing entry point file {1}. - 包“{0}”缺少入口点文件 {1}。 - - - - Package '{0}' is missing tool settings file DotnetToolSettings.xml. - 包“{0}”缺少工具设置文件 DotnetToolSettings.xml。 - - Tool defines a command with a missing name setting. 工具使用缺失的名称设置定义命令。 @@ -853,6 +843,16 @@ setx PATH "%PATH%;{0}" Column maximum width must be greater than zero. + + Entry point file '{0}' for command '{1}' was not found in the package. + Entry point file '{0}' for command '{1}' was not found in the package. + + + + Settings file 'DotnetToolSettings.xml' was not found in the package. + Settings file 'DotnetToolSettings.xml' was not found in the package. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.zh-Hant.xlf b/src/dotnet/xlf/CommonLocalizableStrings.zh-Hant.xlf index 01e11d97a..8c61b8d28 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.zh-Hant.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.zh-Hant.xlf @@ -694,16 +694,6 @@ 因為您剛才安裝了 .NET Core SDK,您必須先重新開啟 [命令提示字元] 視窗,才能執行您安裝的工具。 - - Package '{0}' is missing entry point file {1}. - 套件 '{0}' 缺少進入點檔案 {1}。 - - - - Package '{0}' is missing tool settings file DotnetToolSettings.xml. - 套件 '{0}' 缺少工具設定檔 DotnetToolSettings.xml。 - - Tool defines a command with a missing name setting. 工具使用了缺少的名稱設定定義命令。 @@ -853,6 +843,16 @@ setx PATH "%PATH%;{0}" Column maximum width must be greater than zero. + + Entry point file '{0}' for command '{1}' was not found in the package. + Entry point file '{0}' for command '{1}' was not found in the package. + + + + Settings file 'DotnetToolSettings.xml' was not found in the package. + Settings file 'DotnetToolSettings.xml' was not found in the package. + + \ No newline at end of file diff --git a/test/dotnet-help.Tests/GivenThatIWantToShowHelpForDotnetCommand.cs b/test/dotnet-help.Tests/GivenThatIWantToShowHelpForDotnetCommand.cs index f1f26eca6..6ed105cbf 100644 --- a/test/dotnet-help.Tests/GivenThatIWantToShowHelpForDotnetCommand.cs +++ b/test/dotnet-help.Tests/GivenThatIWantToShowHelpForDotnetCommand.cs @@ -34,7 +34,7 @@ SDK commands: sln Modify solution (SLN) files. add Add reference to the project. remove Remove reference from the project. - list List reference in the project. + list List project references or installed tools. nuget Provides additional NuGet commands. msbuild Runs Microsoft Build Engine (MSBuild). vstest Runs Microsoft Test Execution Command Line Tool. diff --git a/test/dotnet-list-reference.Tests/GivenDotnetListReference.cs b/test/dotnet-list-reference.Tests/GivenDotnetListReference.cs index 12766e983..8cfbc7173 100644 --- a/test/dotnet-list-reference.Tests/GivenDotnetListReference.cs +++ b/test/dotnet-list-reference.Tests/GivenDotnetListReference.cs @@ -33,6 +33,7 @@ Options: Commands: reference .NET Core Project-to-Project dependency viewer + tool Lists installed tools in the current development environment. "; const string FrameworkNet451Arg = "-f net451"; From 5ebbd618ec27e5c6da9142b8c1166b2755cba898 Mon Sep 17 00:00:00 2001 From: Peter Huene Date: Thu, 22 Feb 2018 19:13:36 -0800 Subject: [PATCH 5/6] Fix case sensitivity of tool package identifiers. This commit fixes the case sensitivity of tool package identifiers. Previously the install and uninstall commands unintentionally required the tool package ids to specified in all lowercase for the install / uninstall to work. Fixes #8682. --- src/dotnet/CommonLocalizableStrings.resx | 3 + src/dotnet/ToolPackage/IToolPackage.cs | 5 +- .../ToolPackage/IToolPackageInstaller.cs | 5 +- src/dotnet/ToolPackage/IToolPackageStore.cs | 15 +- src/dotnet/ToolPackage/PackageId.cs | 43 +++++ .../ToolPackage/ToolPackageInstaller.cs | 43 ++--- src/dotnet/ToolPackage/ToolPackageInstance.cs | 33 ++-- src/dotnet/ToolPackage/ToolPackageStore.cs | 84 +++++++-- .../dotnet-install-tool/InstallToolCommand.cs | 23 ++- .../LocalizableStrings.resx | 3 + .../xlf/LocalizableStrings.cs.xlf | 5 + .../xlf/LocalizableStrings.de.xlf | 5 + .../xlf/LocalizableStrings.es.xlf | 5 + .../xlf/LocalizableStrings.fr.xlf | 5 + .../xlf/LocalizableStrings.it.xlf | 5 + .../xlf/LocalizableStrings.ja.xlf | 5 + .../xlf/LocalizableStrings.ko.xlf | 5 + .../xlf/LocalizableStrings.pl.xlf | 5 + .../xlf/LocalizableStrings.pt-BR.xlf | 5 + .../xlf/LocalizableStrings.ru.xlf | 5 + .../xlf/LocalizableStrings.tr.xlf | 5 + .../xlf/LocalizableStrings.zh-Hans.xlf | 5 + .../xlf/LocalizableStrings.zh-Hant.xlf | 5 + .../dotnet-list-tool/ListToolCommand.cs | 10 +- .../tool/UninstallToolCommand.cs | 9 +- .../xlf/CommonLocalizableStrings.cs.xlf | 5 + .../xlf/CommonLocalizableStrings.de.xlf | 5 + .../xlf/CommonLocalizableStrings.es.xlf | 5 + .../xlf/CommonLocalizableStrings.fr.xlf | 5 + .../xlf/CommonLocalizableStrings.it.xlf | 5 + .../xlf/CommonLocalizableStrings.ja.xlf | 5 + .../xlf/CommonLocalizableStrings.ko.xlf | 5 + .../xlf/CommonLocalizableStrings.pl.xlf | 5 + .../xlf/CommonLocalizableStrings.pt-BR.xlf | 5 + .../xlf/CommonLocalizableStrings.ru.xlf | 5 + .../xlf/CommonLocalizableStrings.tr.xlf | 5 + .../xlf/CommonLocalizableStrings.zh-Hans.xlf | 5 + .../xlf/CommonLocalizableStrings.zh-Hant.xlf | 5 + .../ToolPackageInstallerTests.cs | 91 ++++++---- .../ProjectRestorerMock.cs | 27 +-- .../ToolPackageInstallerMock.cs | 26 ++- .../ToolPackageMock.cs | 17 +- .../ToolPackageStoreMock.cs | 77 +++++++- .../CommandTests/InstallToolCommandTests.cs | 164 +++++++++++++++--- 44 files changed, 629 insertions(+), 179 deletions(-) create mode 100644 src/dotnet/ToolPackage/PackageId.cs diff --git a/src/dotnet/CommonLocalizableStrings.resx b/src/dotnet/CommonLocalizableStrings.resx index 77847a864..236b2fd26 100644 --- a/src/dotnet/CommonLocalizableStrings.resx +++ b/src/dotnet/CommonLocalizableStrings.resx @@ -619,6 +619,9 @@ setx PATH "%PATH%;{0}" Tool '{0}' (version '{1}') is already installed. + + Failed to find staged tool package '{0}'. + Column maximum width must be greater than zero. diff --git a/src/dotnet/ToolPackage/IToolPackage.cs b/src/dotnet/ToolPackage/IToolPackage.cs index 3ee968cb9..c769b002d 100644 --- a/src/dotnet/ToolPackage/IToolPackage.cs +++ b/src/dotnet/ToolPackage/IToolPackage.cs @@ -4,14 +4,15 @@ using System; using System.Collections.Generic; using Microsoft.Extensions.EnvironmentAbstractions; +using NuGet.Versioning; namespace Microsoft.DotNet.ToolPackage { internal interface IToolPackage { - string PackageId { get; } + PackageId Id { get; } - string PackageVersion { get; } + NuGetVersion Version { get; } DirectoryPath PackageDirectory { get; } diff --git a/src/dotnet/ToolPackage/IToolPackageInstaller.cs b/src/dotnet/ToolPackage/IToolPackageInstaller.cs index d8501d22d..c6ef964e1 100644 --- a/src/dotnet/ToolPackage/IToolPackageInstaller.cs +++ b/src/dotnet/ToolPackage/IToolPackageInstaller.cs @@ -4,14 +4,15 @@ using System; using System.Collections.Generic; using Microsoft.Extensions.EnvironmentAbstractions; +using NuGet.Versioning; namespace Microsoft.DotNet.ToolPackage { internal interface IToolPackageInstaller { IToolPackage InstallPackage( - string packageId, - string packageVersion = null, + PackageId packageId, + VersionRange versionRange = null, string targetFramework = null, FilePath? nugetConfig = null, string source = null, diff --git a/src/dotnet/ToolPackage/IToolPackageStore.cs b/src/dotnet/ToolPackage/IToolPackageStore.cs index 72105d24d..4e3e88c65 100644 --- a/src/dotnet/ToolPackage/IToolPackageStore.cs +++ b/src/dotnet/ToolPackage/IToolPackageStore.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using Microsoft.Extensions.EnvironmentAbstractions; +using NuGet.Versioning; namespace Microsoft.DotNet.ToolPackage { @@ -11,6 +12,18 @@ namespace Microsoft.DotNet.ToolPackage { DirectoryPath Root { get; } - IEnumerable GetInstalledPackages(string packageId = null); + DirectoryPath GetRandomStagingDirectory(); + + NuGetVersion GetStagedPackageVersion(DirectoryPath stagingDirectory, PackageId packageId); + + DirectoryPath GetRootPackageDirectory(PackageId packageId); + + DirectoryPath GetPackageDirectory(PackageId packageId, NuGetVersion version); + + IEnumerable EnumeratePackages(); + + IEnumerable EnumeratePackageVersions(PackageId packageId); + + IToolPackage GetPackage(PackageId packageId, NuGetVersion version); } } diff --git a/src/dotnet/ToolPackage/PackageId.cs b/src/dotnet/ToolPackage/PackageId.cs new file mode 100644 index 000000000..07846bf7a --- /dev/null +++ b/src/dotnet/ToolPackage/PackageId.cs @@ -0,0 +1,43 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using Microsoft.DotNet.InternalAbstractions; + +namespace Microsoft.DotNet.ToolPackage +{ + internal struct PackageId : IEquatable, IComparable + { + private string _id; + + public PackageId(string id) + { + _id = id?.ToLowerInvariant() ?? throw new ArgumentNullException(nameof(id)); + } + + public bool Equals(PackageId other) + { + return ToString() == other.ToString(); + } + + public int CompareTo(PackageId other) + { + return string.Compare(ToString(), other.ToString(), StringComparison.Ordinal); + } + + public override bool Equals(object obj) + { + return obj is PackageId id && Equals(id); + } + + public override int GetHashCode() + { + return ToString().GetHashCode(); + } + + public override string ToString() + { + return _id ?? ""; + } + } +} diff --git a/src/dotnet/ToolPackage/ToolPackageInstaller.cs b/src/dotnet/ToolPackage/ToolPackageInstaller.cs index e30a4cc7e..cf655a301 100644 --- a/src/dotnet/ToolPackage/ToolPackageInstaller.cs +++ b/src/dotnet/ToolPackage/ToolPackageInstaller.cs @@ -7,13 +7,12 @@ using Microsoft.DotNet.Cli; using Microsoft.DotNet.Configurer; using Microsoft.DotNet.Tools; using Microsoft.Extensions.EnvironmentAbstractions; +using NuGet.Versioning; namespace Microsoft.DotNet.ToolPackage { internal class ToolPackageInstaller : IToolPackageInstaller { - public const string StagingDirectory = ".stage"; - private readonly IToolPackageStore _store; private readonly IProjectRestorer _projectRestorer; private readonly FilePath? _tempProject; @@ -32,33 +31,27 @@ namespace Microsoft.DotNet.ToolPackage } public IToolPackage InstallPackage( - string packageId, - string packageVersion = null, + PackageId packageId, + VersionRange versionRange = null, string targetFramework = null, FilePath? nugetConfig = null, string source = null, string verbosity = null) { - if (packageId == null) - { - throw new ArgumentNullException(nameof(packageId)); - } - - var packageRootDirectory = _store.Root.WithSubDirectories(packageId); + var packageRootDirectory = _store.GetRootPackageDirectory(packageId); string rollbackDirectory = null; return TransactionalAction.Run( action: () => { try { - - var stageDirectory = _store.Root.WithSubDirectories(StagingDirectory, Path.GetRandomFileName()); + var stageDirectory = _store.GetRandomStagingDirectory(); Directory.CreateDirectory(stageDirectory.Value); rollbackDirectory = stageDirectory.Value; var tempProject = CreateTempProject( packageId: packageId, - packageVersion: packageVersion, + versionRange: versionRange, targetFramework: targetFramework ?? BundledTargetFramework.GetTargetFrameworkMoniker(), restoreDirectory: stageDirectory); @@ -76,29 +69,22 @@ namespace Microsoft.DotNet.ToolPackage File.Delete(tempProject.Value); } - packageVersion = Path.GetFileName( - Directory.EnumerateDirectories( - stageDirectory.WithSubDirectories(packageId).Value).Single()); - - var packageDirectory = packageRootDirectory.WithSubDirectories(packageVersion); + var version = _store.GetStagedPackageVersion(stageDirectory, packageId); + var packageDirectory = _store.GetPackageDirectory(packageId, version); if (Directory.Exists(packageDirectory.Value)) { throw new ToolPackageException( string.Format( CommonLocalizableStrings.ToolPackageConflictPackageId, packageId, - packageVersion)); + version.ToNormalizedString())); } Directory.CreateDirectory(packageRootDirectory.Value); Directory.Move(stageDirectory.Value, packageDirectory.Value); rollbackDirectory = packageDirectory.Value; - return new ToolPackageInstance( - _store, - packageId, - packageVersion, - packageDirectory); + return new ToolPackageInstance(_store, packageId, version, packageDirectory); } catch (Exception ex) when (ex is UnauthorizedAccessException || ex is IOException) { @@ -126,8 +112,8 @@ namespace Microsoft.DotNet.ToolPackage } private FilePath CreateTempProject( - string packageId, - string packageVersion, + PackageId packageId, + VersionRange versionRange, string targetFramework, DirectoryPath restoreDirectory) { @@ -159,8 +145,9 @@ namespace Microsoft.DotNet.ToolPackage new XElement("DisableImplicitNuGetFallbackFolder", "true")), // disable SDK side implicit NuGetFallbackFolder new XElement("ItemGroup", new XElement("PackageReference", - new XAttribute("Include", packageId), - new XAttribute("Version", packageVersion ?? "*") // nuget will restore * for latest + new XAttribute("Include", packageId.ToString()), + new XAttribute("Version", + versionRange?.ToString("S", new VersionRangeFormatter()) ?? "*") // nuget will restore latest stable for * )) )); diff --git a/src/dotnet/ToolPackage/ToolPackageInstance.cs b/src/dotnet/ToolPackage/ToolPackageInstance.cs index 5841c2ef6..74b092109 100644 --- a/src/dotnet/ToolPackage/ToolPackageInstance.cs +++ b/src/dotnet/ToolPackage/ToolPackageInstance.cs @@ -6,6 +6,7 @@ using Microsoft.DotNet.Cli; using Microsoft.DotNet.Tools; using Microsoft.Extensions.EnvironmentAbstractions; using NuGet.ProjectModel; +using NuGet.Versioning; namespace Microsoft.DotNet.ToolPackage { @@ -17,20 +18,21 @@ namespace Microsoft.DotNet.ToolPackage public ToolPackageInstance( IToolPackageStore store, - string packageId, - string packageVersion, + PackageId id, + NuGetVersion version, DirectoryPath packageDirectory) { _store = store ?? throw new ArgumentNullException(nameof(store)); - PackageId = packageId ?? throw new ArgumentNullException(nameof(packageId)); - PackageVersion = packageVersion ?? throw new ArgumentNullException(nameof(packageVersion)); - PackageDirectory = packageDirectory; _commands = new Lazy>(GetCommands); + + Id = id; + Version = version ?? throw new ArgumentNullException(nameof(version)); + PackageDirectory = packageDirectory; } - public string PackageId { get; private set; } + public PackageId Id { get; private set; } - public string PackageVersion { get; private set; } + public NuGetVersion Version { get; private set; } public DirectoryPath PackageDirectory { get; private set; } @@ -53,13 +55,9 @@ namespace Microsoft.DotNet.ToolPackage { if (Directory.Exists(PackageDirectory.Value)) { - // Use the same staging directory for uninstall instead of temp + // Use the staging directory for uninstall // This prevents cross-device moves when temp is mounted to a different device - var tempPath = _store - .Root - .WithSubDirectories(ToolPackageInstaller.StagingDirectory) - .WithFile(Path.GetRandomFileName()) - .Value; + var tempPath = _store.GetRandomStagingDirectory().Value; Directory.Move(PackageDirectory.Value, tempPath); tempPackageDirectory = tempPath; } @@ -75,7 +73,7 @@ namespace Microsoft.DotNet.ToolPackage throw new ToolPackageException( string.Format( CommonLocalizableStrings.FailedToUninstallToolPackage, - PackageId, + Id, ex.Message), ex); } @@ -116,7 +114,7 @@ namespace Microsoft.DotNet.ToolPackage var toolConfigurationPath = PackageDirectory .WithSubDirectories( - PackageId, + Id.ToString(), library.Version.ToNormalizedString()) .WithFile(dotnetToolSettings.Path); @@ -138,7 +136,7 @@ namespace Microsoft.DotNet.ToolPackage "dotnet", PackageDirectory .WithSubDirectories( - PackageId, + Id.ToString(), library.Version.ToNormalizedString()) .WithFile(entryPointFromLockFile.Path))); @@ -158,7 +156,8 @@ namespace Microsoft.DotNet.ToolPackage { return lockFile ?.Targets?.SingleOrDefault(t => t.RuntimeIdentifier != null) - ?.Libraries?.SingleOrDefault(l => l.Name == PackageId); + ?.Libraries?.SingleOrDefault(l => + string.Compare(l.Name, Id.ToString(), StringComparison.CurrentCultureIgnoreCase) == 0); } private static LockFileItem FindItemInTargetLibrary(LockFileTargetLibrary library, string targetRelativeFilePath) diff --git a/src/dotnet/ToolPackage/ToolPackageStore.cs b/src/dotnet/ToolPackage/ToolPackageStore.cs index f9575a9cc..f424b6062 100644 --- a/src/dotnet/ToolPackage/ToolPackageStore.cs +++ b/src/dotnet/ToolPackage/ToolPackageStore.cs @@ -2,12 +2,16 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using Microsoft.DotNet.Tools; using Microsoft.Extensions.EnvironmentAbstractions; +using NuGet.Versioning; namespace Microsoft.DotNet.ToolPackage { internal class ToolPackageStore : IToolPackageStore { + public const string StagingDirectory = ".stage"; + public ToolPackageStore(DirectoryPath root) { Root = root; @@ -15,17 +19,45 @@ namespace Microsoft.DotNet.ToolPackage public DirectoryPath Root { get; private set; } - public IEnumerable GetInstalledPackages(string packageId = null) + public DirectoryPath GetRandomStagingDirectory() { - if (packageId != null) - { - return EnumerateVersions(packageId); - } - - return EnumerateAllPackages().SelectMany(p => p); + return Root.WithSubDirectories(StagingDirectory, Path.GetRandomFileName()); } - private IEnumerable> EnumerateAllPackages() + public NuGetVersion GetStagedPackageVersion(DirectoryPath stagingDirectory, PackageId packageId) + { + if (NuGetVersion.TryParse( + Path.GetFileName( + Directory.EnumerateDirectories( + stagingDirectory.WithSubDirectories(packageId.ToString()).Value).FirstOrDefault()), + out var version)) + { + return version; + } + + throw new ToolPackageException( + string.Format( + CommonLocalizableStrings.FailedToFindStagedToolPackage, + packageId)); + } + + public DirectoryPath GetRootPackageDirectory(PackageId packageId) + { + return Root.WithSubDirectories(packageId.ToString()); + } + + public DirectoryPath GetPackageDirectory(PackageId packageId, NuGetVersion version) + { + if (version == null) + { + throw new ArgumentNullException(nameof(version)); + } + + return GetRootPackageDirectory(packageId) + .WithSubDirectories(version.ToNormalizedString().ToLowerInvariant()); + } + + public IEnumerable EnumeratePackages() { if (!Directory.Exists(Root.Value)) { @@ -34,19 +66,25 @@ namespace Microsoft.DotNet.ToolPackage foreach (var subdirectory in Directory.EnumerateDirectories(Root.Value)) { - var packageId = Path.GetFileName(subdirectory); - if (packageId == ToolPackageInstaller.StagingDirectory) + var name = Path.GetFileName(subdirectory); + var packageId = new PackageId(name); + + // Ignore the staging directory and any directory that isn't the same as the package id + if (name == StagingDirectory || name != packageId.ToString()) { continue; } - yield return EnumerateVersions(packageId); + foreach (var package in EnumeratePackageVersions(packageId)) + { + yield return package; + } } } - private IEnumerable EnumerateVersions(string packageId) + public IEnumerable EnumeratePackageVersions(PackageId packageId) { - var packageRootDirectory = Root.WithSubDirectories(packageId); + var packageRootDirectory = Root.WithSubDirectories(packageId.ToString()); if (!Directory.Exists(packageRootDirectory.Value)) { yield break; @@ -54,13 +92,27 @@ namespace Microsoft.DotNet.ToolPackage foreach (var subdirectory in Directory.EnumerateDirectories(packageRootDirectory.Value)) { - var version = Path.GetFileName(subdirectory); yield return new ToolPackageInstance( this, packageId, - version, - packageRootDirectory.WithSubDirectories(version)); + NuGetVersion.Parse(Path.GetFileName(subdirectory)), + new DirectoryPath(subdirectory)); } } + + public IToolPackage GetPackage(PackageId packageId, NuGetVersion version) + { + if (version == null) + { + throw new ArgumentNullException(nameof(version)); + } + + var directory = GetPackageDirectory(packageId, version); + if (!Directory.Exists(directory.Value)) + { + return null; + } + return new ToolPackageInstance(this, packageId, version, directory); + } } } diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/InstallToolCommand.cs b/src/dotnet/commands/dotnet-install/dotnet-install-tool/InstallToolCommand.cs index 881f81491..8459c2b55 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/InstallToolCommand.cs +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/InstallToolCommand.cs @@ -13,6 +13,7 @@ using Microsoft.DotNet.Configurer; using Microsoft.DotNet.ShellShim; using Microsoft.DotNet.ToolPackage; using Microsoft.Extensions.EnvironmentAbstractions; +using NuGet.Versioning; namespace Microsoft.DotNet.Tools.Install.Tool { @@ -25,7 +26,7 @@ namespace Microsoft.DotNet.Tools.Install.Tool private readonly IReporter _reporter; private readonly IReporter _errorReporter; - private readonly string _packageId; + private readonly PackageId _packageId; private readonly string _packageVersion; private readonly string _configFilePath; private readonly string _framework; @@ -48,7 +49,7 @@ namespace Microsoft.DotNet.Tools.Install.Tool throw new ArgumentNullException(nameof(appliedCommand)); } - _packageId = appliedCommand.Arguments.Single(); + _packageId = new PackageId(appliedCommand.Arguments.Single()); _packageVersion = appliedCommand.ValueOrDefault("version"); _configFilePath = appliedCommand.ValueOrDefault("configfile"); _framework = appliedCommand.ValueOrDefault("framework"); @@ -91,8 +92,16 @@ namespace Microsoft.DotNet.Tools.Install.Tool Path.GetFullPath(_configFilePath))); } - // Prevent installation if any version of the package is installed - if (_toolPackageStore.GetInstalledPackages(_packageId).FirstOrDefault() != null) + VersionRange versionRange = null; + if (!string.IsNullOrEmpty(_packageVersion) && !VersionRange.TryParse(_packageVersion, out versionRange)) + { + throw new GracefulException( + string.Format( + LocalizableStrings.InvalidNuGetVersionRange, + _packageVersion)); + } + + if (_toolPackageStore.EnumeratePackageVersions(_packageId).FirstOrDefault() != null) { _errorReporter.WriteLine(string.Format(LocalizableStrings.ToolAlreadyInstalled, _packageId).Red()); return 1; @@ -113,7 +122,7 @@ namespace Microsoft.DotNet.Tools.Install.Tool { package = _toolPackageInstaller.InstallPackage( packageId: _packageId, - packageVersion: _packageVersion, + versionRange: versionRange, targetFramework: _framework, nugetConfig: configFile, source: _source, @@ -133,8 +142,8 @@ namespace Microsoft.DotNet.Tools.Install.Tool string.Format( LocalizableStrings.InstallationSucceeded, string.Join(", ", package.Commands.Select(c => c.Name)), - package.PackageId, - package.PackageVersion).Green()); + package.Id, + package.Version.ToNormalizedString()).Green()); return 0; } catch (ToolPackageException ex) diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/LocalizableStrings.resx b/src/dotnet/commands/dotnet-install/dotnet-install-tool/LocalizableStrings.resx index 8d366537c..2b463ae96 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/LocalizableStrings.resx +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/LocalizableStrings.resx @@ -178,4 +178,7 @@ Tool '{1}' (version '{2}') was successfully installed. Failed to create shell shim for tool '{0}': {1} + + Specified version '{0}' is not a valid NuGet version range. + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.cs.xlf b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.cs.xlf index eb8dae6d6..894f345b3 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.cs.xlf +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.cs.xlf @@ -104,6 +104,11 @@ Instalace byla úspěšná. Pokud nejsou další pokyny, můžete přímo do já Balíček nástroje nebylo možné obnovit. + + Specified version '{0}' is not a valid NuGet version range. + Specified version '{0}' is not a valid NuGet version range. + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.de.xlf b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.de.xlf index 941d48da4..2d551c8f0 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.de.xlf +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.de.xlf @@ -104,6 +104,11 @@ Die Installation war erfolgreich. Sofern keine weiteren Anweisungen vorliegen, k Das Toolpaket konnte nicht wiederhergestellt werden. + + Specified version '{0}' is not a valid NuGet version range. + Specified version '{0}' is not a valid NuGet version range. + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.es.xlf b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.es.xlf index 13656cbc9..1907042c2 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.es.xlf +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.es.xlf @@ -104,6 +104,11 @@ La instalación se completó correctamente. Si no hay más instrucciones, puede No se puede restaurar el paquete de la herramienta. + + Specified version '{0}' is not a valid NuGet version range. + Specified version '{0}' is not a valid NuGet version range. + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.fr.xlf b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.fr.xlf index 65a0f7bcd..217f901ca 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.fr.xlf +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.fr.xlf @@ -104,6 +104,11 @@ L'installation a réussi. En l'absence d'instructions supplémentaires, vous pou Impossible de restaurer le package de l'outil. + + Specified version '{0}' is not a valid NuGet version range. + Specified version '{0}' is not a valid NuGet version range. + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.it.xlf b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.it.xlf index 9ffb72dfb..69df9674e 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.it.xlf +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.it.xlf @@ -104,6 +104,11 @@ L'installazione è riuscita. Se non ci sono altre istruzioni, è possibile digit Non è stato possibile ripristinare il pacchetto dello strumento. + + Specified version '{0}' is not a valid NuGet version range. + Specified version '{0}' is not a valid NuGet version range. + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.ja.xlf b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.ja.xlf index dd81fbb48..eb86d3b58 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.ja.xlf +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.ja.xlf @@ -104,6 +104,11 @@ Tool '{1}' (version '{2}') was successfully installed. ツール パッケージを復元できませんでした。 + + Specified version '{0}' is not a valid NuGet version range. + Specified version '{0}' is not a valid NuGet version range. + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.ko.xlf b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.ko.xlf index 79acf23a0..41b63aff0 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.ko.xlf +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.ko.xlf @@ -104,6 +104,11 @@ Tool '{1}' (version '{2}') was successfully installed. 도구 패키지를 복원할 수 없습니다. + + Specified version '{0}' is not a valid NuGet version range. + Specified version '{0}' is not a valid NuGet version range. + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.pl.xlf b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.pl.xlf index 95e8b774f..c77c195ab 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.pl.xlf +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.pl.xlf @@ -104,6 +104,11 @@ Instalacja powiodła się. Jeśli nie ma dodatkowych instrukcji, możesz wpisać Nie można przywrócić pakietu narzędzia. + + Specified version '{0}' is not a valid NuGet version range. + Specified version '{0}' is not a valid NuGet version range. + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.pt-BR.xlf b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.pt-BR.xlf index d70b28da7..ab6c7b086 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.pt-BR.xlf +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.pt-BR.xlf @@ -104,6 +104,11 @@ A instalação foi bem-sucedida. Se não houver outras instruções, digite o se O pacote da ferramenta não pôde ser restaurado. + + Specified version '{0}' is not a valid NuGet version range. + Specified version '{0}' is not a valid NuGet version range. + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.ru.xlf b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.ru.xlf index a3705f15d..d4b0de225 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.ru.xlf +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.ru.xlf @@ -104,6 +104,11 @@ Tool '{1}' (version '{2}') was successfully installed. Не удалось восстановить пакет инструмента. + + Specified version '{0}' is not a valid NuGet version range. + Specified version '{0}' is not a valid NuGet version range. + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.tr.xlf b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.tr.xlf index a9dd17bb6..13ed942cf 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.tr.xlf +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.tr.xlf @@ -104,6 +104,11 @@ Yükleme başarılı oldu. Daha fazla yönerge yoksa, çağırmak için şu komu Araç paketi geri yüklenemedi. + + Specified version '{0}' is not a valid NuGet version range. + Specified version '{0}' is not a valid NuGet version range. + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.zh-Hans.xlf b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.zh-Hans.xlf index 840ebd25a..29f352687 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.zh-Hans.xlf +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.zh-Hans.xlf @@ -104,6 +104,11 @@ Tool '{1}' (version '{2}') was successfully installed. 无法还原工具包。 + + Specified version '{0}' is not a valid NuGet version range. + Specified version '{0}' is not a valid NuGet version range. + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.zh-Hant.xlf b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.zh-Hant.xlf index 1a75879a6..911527d54 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.zh-Hant.xlf +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.zh-Hant.xlf @@ -104,6 +104,11 @@ Tool '{1}' (version '{2}') was successfully installed. 此工具套件無法還原。 + + Specified version '{0}' is not a valid NuGet version range. + Specified version '{0}' is not a valid NuGet version range. + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-list/dotnet-list-tool/ListToolCommand.cs b/src/dotnet/commands/dotnet-list/dotnet-list-tool/ListToolCommand.cs index b732ba3a8..b567ac74d 100644 --- a/src/dotnet/commands/dotnet-list/dotnet-list-tool/ListToolCommand.cs +++ b/src/dotnet/commands/dotnet-list/dotnet-list-tool/ListToolCommand.cs @@ -46,10 +46,10 @@ namespace Microsoft.DotNet.Tools.List.Tool table.AddColumn( LocalizableStrings.PackageIdColumn, - p => p.PackageId); + p => p.Id.ToString()); table.AddColumn( LocalizableStrings.VersionColumn, - p => p.PackageVersion); + p => p.Version.ToNormalizedString()); table.AddColumn( LocalizableStrings.CommandsColumn, p => string.Join(CommandDelimiter, p.Commands.Select(c => c.Name))); @@ -60,9 +60,9 @@ namespace Microsoft.DotNet.Tools.List.Tool private IEnumerable GetPackages() { - return _toolPackageStore.GetInstalledPackages() + return _toolPackageStore.EnumeratePackages() .Where(PackageHasCommands) - .OrderBy(p => p.PackageId) + .OrderBy(p => p.Id) .ToArray(); } @@ -79,7 +79,7 @@ namespace Microsoft.DotNet.Tools.List.Tool _errorReporter.WriteLine( string.Format( LocalizableStrings.InvalidPackageWarning, - p.PackageId, + p.Id, ex.Message).Yellow()); return false; } diff --git a/src/dotnet/commands/dotnet-uninstall/tool/UninstallToolCommand.cs b/src/dotnet/commands/dotnet-uninstall/tool/UninstallToolCommand.cs index d362e3838..ca470f4a6 100644 --- a/src/dotnet/commands/dotnet-uninstall/tool/UninstallToolCommand.cs +++ b/src/dotnet/commands/dotnet-uninstall/tool/UninstallToolCommand.cs @@ -49,12 +49,11 @@ namespace Microsoft.DotNet.Tools.Uninstall.Tool throw new GracefulException(LocalizableStrings.UninstallToolCommandOnlySupportsGlobal); } - var packageId = _options.Arguments.Single(); + var packageId = new PackageId(_options.Arguments.Single()); IToolPackage package = null; - try { - package = _toolPackageStore.GetInstalledPackages(packageId).SingleOrDefault(); + package = _toolPackageStore.EnumeratePackageVersions(packageId).SingleOrDefault(); if (package == null) { _errorReporter.WriteLine( @@ -92,8 +91,8 @@ namespace Microsoft.DotNet.Tools.Uninstall.Tool _reporter.WriteLine( string.Format( LocalizableStrings.UninstallSucceeded, - package.PackageId, - package.PackageVersion).Green()); + package.Id, + package.Version.ToNormalizedString()).Green()); return 0; } catch (ToolPackageException ex) diff --git a/src/dotnet/xlf/CommonLocalizableStrings.cs.xlf b/src/dotnet/xlf/CommonLocalizableStrings.cs.xlf index 8f0e7c10c..70be5e60b 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.cs.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.cs.xlf @@ -853,6 +853,11 @@ setx PATH "%PATH%;{0}" Settings file 'DotnetToolSettings.xml' was not found in the package. + + Failed to find staged tool package '{0}'. + Failed to find staged tool package '{0}'. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.de.xlf b/src/dotnet/xlf/CommonLocalizableStrings.de.xlf index 3a93064c3..6ef10330e 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.de.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.de.xlf @@ -853,6 +853,11 @@ setx PATH "%PATH%;{0}" Settings file 'DotnetToolSettings.xml' was not found in the package. + + Failed to find staged tool package '{0}'. + Failed to find staged tool package '{0}'. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.es.xlf b/src/dotnet/xlf/CommonLocalizableStrings.es.xlf index f283122ee..c9d3df366 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.es.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.es.xlf @@ -853,6 +853,11 @@ setx PATH "%PATH%;{0}" Settings file 'DotnetToolSettings.xml' was not found in the package. + + Failed to find staged tool package '{0}'. + Failed to find staged tool package '{0}'. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.fr.xlf b/src/dotnet/xlf/CommonLocalizableStrings.fr.xlf index 3a668e77f..ab0d6ae1f 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.fr.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.fr.xlf @@ -853,6 +853,11 @@ setx PATH "%PATH%;{0}" Settings file 'DotnetToolSettings.xml' was not found in the package. + + Failed to find staged tool package '{0}'. + Failed to find staged tool package '{0}'. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.it.xlf b/src/dotnet/xlf/CommonLocalizableStrings.it.xlf index 89d2e6f1e..6210b184f 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.it.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.it.xlf @@ -853,6 +853,11 @@ setx PATH "%PATH%;{0}" Settings file 'DotnetToolSettings.xml' was not found in the package. + + Failed to find staged tool package '{0}'. + Failed to find staged tool package '{0}'. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.ja.xlf b/src/dotnet/xlf/CommonLocalizableStrings.ja.xlf index 5d42dbf93..4541550f0 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.ja.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.ja.xlf @@ -853,6 +853,11 @@ setx PATH "%PATH%;{0}" Settings file 'DotnetToolSettings.xml' was not found in the package. + + Failed to find staged tool package '{0}'. + Failed to find staged tool package '{0}'. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.ko.xlf b/src/dotnet/xlf/CommonLocalizableStrings.ko.xlf index e136f3d5c..c9d93cce8 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.ko.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.ko.xlf @@ -853,6 +853,11 @@ setx PATH "%PATH%;{0}" Settings file 'DotnetToolSettings.xml' was not found in the package. + + Failed to find staged tool package '{0}'. + Failed to find staged tool package '{0}'. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.pl.xlf b/src/dotnet/xlf/CommonLocalizableStrings.pl.xlf index 0a2d70abc..2b22b4c8c 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.pl.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.pl.xlf @@ -853,6 +853,11 @@ setx PATH "%PATH%;{0}" Settings file 'DotnetToolSettings.xml' was not found in the package. + + Failed to find staged tool package '{0}'. + Failed to find staged tool package '{0}'. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.pt-BR.xlf b/src/dotnet/xlf/CommonLocalizableStrings.pt-BR.xlf index 81b666a10..60b4b7863 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.pt-BR.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.pt-BR.xlf @@ -853,6 +853,11 @@ setx PATH "%PATH%;{0}" Settings file 'DotnetToolSettings.xml' was not found in the package. + + Failed to find staged tool package '{0}'. + Failed to find staged tool package '{0}'. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.ru.xlf b/src/dotnet/xlf/CommonLocalizableStrings.ru.xlf index 0926eee52..50ee839d2 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.ru.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.ru.xlf @@ -853,6 +853,11 @@ setx PATH "%PATH%;{0}" Settings file 'DotnetToolSettings.xml' was not found in the package. + + Failed to find staged tool package '{0}'. + Failed to find staged tool package '{0}'. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.tr.xlf b/src/dotnet/xlf/CommonLocalizableStrings.tr.xlf index 3d316c24f..a20c55ce0 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.tr.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.tr.xlf @@ -853,6 +853,11 @@ setx PATH "%PATH%;{0}" Settings file 'DotnetToolSettings.xml' was not found in the package. + + Failed to find staged tool package '{0}'. + Failed to find staged tool package '{0}'. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.zh-Hans.xlf b/src/dotnet/xlf/CommonLocalizableStrings.zh-Hans.xlf index b18d951b8..d26ed195d 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.zh-Hans.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.zh-Hans.xlf @@ -853,6 +853,11 @@ setx PATH "%PATH%;{0}" Settings file 'DotnetToolSettings.xml' was not found in the package. + + Failed to find staged tool package '{0}'. + Failed to find staged tool package '{0}'. + + \ No newline at end of file diff --git a/src/dotnet/xlf/CommonLocalizableStrings.zh-Hant.xlf b/src/dotnet/xlf/CommonLocalizableStrings.zh-Hant.xlf index 8c61b8d28..fc901551e 100644 --- a/src/dotnet/xlf/CommonLocalizableStrings.zh-Hant.xlf +++ b/src/dotnet/xlf/CommonLocalizableStrings.zh-Hant.xlf @@ -853,6 +853,11 @@ setx PATH "%PATH%;{0}" Settings file 'DotnetToolSettings.xml' was not found in the package. + + Failed to find staged tool package '{0}'. + Failed to find staged tool package '{0}'. + + \ No newline at end of file diff --git a/test/Microsoft.DotNet.ToolPackage.Tests/ToolPackageInstallerTests.cs b/test/Microsoft.DotNet.ToolPackage.Tests/ToolPackageInstallerTests.cs index 9c4bf61f5..46268c106 100644 --- a/test/Microsoft.DotNet.ToolPackage.Tests/ToolPackageInstallerTests.cs +++ b/test/Microsoft.DotNet.ToolPackage.Tests/ToolPackageInstallerTests.cs @@ -16,6 +16,7 @@ using Microsoft.DotNet.Tools.Install.Tool; using Microsoft.DotNet.Tools.Tests.ComponentMocks; using Microsoft.Extensions.DependencyModel.Tests; using Microsoft.Extensions.EnvironmentAbstractions; +using NuGet.Versioning; using Xunit; namespace Microsoft.DotNet.ToolPackage.Tests @@ -33,13 +34,13 @@ namespace Microsoft.DotNet.ToolPackage.Tests Action a = () => installer.InstallPackage( packageId: TestPackageId, - packageVersion: TestPackageVersion, + versionRange: VersionRange.Parse(TestPackageVersion), targetFramework: _testTargetframework); a.ShouldThrow().WithMessage(LocalizableStrings.ToolInstallationRestoreFailed); reporter.Lines.Count.Should().Be(1); - reporter.Lines[0].Should().Contain(TestPackageId); + reporter.Lines[0].Should().Contain(TestPackageId.ToString()); } [Theory] @@ -54,7 +55,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests var package = installer.InstallPackage( packageId: TestPackageId, - packageVersion: TestPackageVersion, + versionRange: VersionRange.Parse(TestPackageVersion), targetFramework: _testTargetframework); AssertPackageInstall(reporter, fileSystem, package, store); @@ -75,7 +76,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests var package = installer.InstallPackage( packageId: TestPackageId, - packageVersion: TestPackageVersion, + versionRange: VersionRange.Parse(TestPackageVersion), targetFramework: _testTargetframework, nugetConfig: nugetConfigPath); @@ -102,7 +103,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests { package = installer.InstallPackage( packageId: TestPackageId, - packageVersion: TestPackageVersion, + versionRange: VersionRange.Parse(TestPackageVersion), targetFramework: _testTargetframework, nugetConfig: nugetConfigPath); @@ -127,7 +128,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests var package = installer.InstallPackage( packageId: TestPackageId, - packageVersion: TestPackageVersion, + versionRange: VersionRange.Parse(TestPackageVersion), targetFramework: _testTargetframework, nugetConfig: nugetConfigPath); @@ -166,7 +167,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests var package = installer.InstallPackage( packageId: TestPackageId, - packageVersion: TestPackageVersion, + versionRange: VersionRange.Parse(TestPackageVersion), targetFramework: _testTargetframework); AssertPackageInstall(reporter, fileSystem, package, store); @@ -208,7 +209,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests var package = installer.InstallPackage( packageId: TestPackageId, - packageVersion: TestPackageVersion, + versionRange: VersionRange.Parse(TestPackageVersion), nugetConfig: nugetConfigPath); AssertPackageInstall(reporter, fileSystem, package, store); @@ -229,7 +230,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests var package = installer.InstallPackage( packageId: TestPackageId, - packageVersion: TestPackageVersion, + versionRange: VersionRange.Parse(TestPackageVersion), targetFramework: _testTargetframework, source: source); @@ -251,7 +252,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests TransactionScopeOption.Required, TimeSpan.Zero)) { - installer.InstallPackage("non.existent.package.id"); + installer.InstallPackage(new PackageId("non.existent.package.id")); t.Complete(); } @@ -282,7 +283,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests { installer.InstallPackage( packageId: TestPackageId, - packageVersion: TestPackageVersion, + versionRange: VersionRange.Parse(TestPackageVersion), targetFramework: _testTargetframework, source: source); @@ -314,7 +315,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests { Action first = () => installer.InstallPackage( packageId: TestPackageId, - packageVersion: TestPackageVersion, + versionRange: VersionRange.Parse(TestPackageVersion), targetFramework: _testTargetframework, source: source); @@ -322,7 +323,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests installer.InstallPackage( packageId: TestPackageId, - packageVersion: TestPackageVersion, + versionRange: VersionRange.Parse(TestPackageVersion), targetFramework: _testTargetframework, source: source); @@ -353,7 +354,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests var package = installer.InstallPackage( packageId: TestPackageId, - packageVersion: TestPackageVersion, + versionRange: VersionRange.Parse(TestPackageVersion), targetFramework: _testTargetframework, source: source); @@ -361,7 +362,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests Action secondCall = () => installer.InstallPackage( packageId: TestPackageId, - packageVersion: TestPackageVersion, + versionRange: VersionRange.Parse(TestPackageVersion), targetFramework: _testTargetframework, source: source); @@ -376,7 +377,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests fileSystem .Directory - .Exists(store.Root.WithSubDirectories(TestPackageId).Value) + .Exists(store.Root.WithSubDirectories(TestPackageId.ToString()).Value) .Should() .BeTrue(); @@ -384,7 +385,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests fileSystem .Directory - .EnumerateFileSystemEntries(store.Root.WithSubDirectories(".stage").Value) + .EnumerateFileSystemEntries(store.Root.WithSubDirectories(ToolPackageStore.StagingDirectory).Value) .Should() .BeEmpty(); } @@ -402,7 +403,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests var package = installer.InstallPackage( packageId: TestPackageId, - packageVersion: TestPackageVersion, + versionRange: VersionRange.Parse(TestPackageVersion), targetFramework: _testTargetframework, source: source); @@ -410,7 +411,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests package.Uninstall(); - store.GetInstalledPackages(TestPackageId).Should().BeEmpty(); + store.EnumeratePackages().Should().BeEmpty(); } [Theory] @@ -426,7 +427,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests var package = installer.InstallPackage( packageId: TestPackageId, - packageVersion: TestPackageVersion, + versionRange: VersionRange.Parse(TestPackageVersion), targetFramework: _testTargetframework, source: source); @@ -438,10 +439,10 @@ namespace Microsoft.DotNet.ToolPackage.Tests { package.Uninstall(); - store.GetInstalledPackages(TestPackageId).Should().BeEmpty(); + store.EnumeratePackages().Should().BeEmpty(); } - package = store.GetInstalledPackages(TestPackageId).First(); + package = store.EnumeratePackageVersions(TestPackageId).First(); AssertPackageInstall(reporter, fileSystem, package, store); } @@ -459,7 +460,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests var package = installer.InstallPackage( packageId: TestPackageId, - packageVersion: TestPackageVersion, + versionRange: VersionRange.Parse(TestPackageVersion), targetFramework: _testTargetframework, source: source); @@ -473,7 +474,28 @@ namespace Microsoft.DotNet.ToolPackage.Tests scope.Complete(); } - store.GetInstalledPackages(TestPackageId).Should().BeEmpty(); + store.EnumeratePackages().Should().BeEmpty(); + } + + [Theory] + [InlineData(false)] + [InlineData(true)] + public void GivenAPackageNameWithDifferentCaseItCanInstallThePackage(bool testMockBehaviorIsInSync) + { + var nugetConfigPath = WriteNugetConfigFileToPointToTheFeed(); + + var (store, installer, reporter, fileSystem) = Setup( + useMock: testMockBehaviorIsInSync, + feeds: GetMockFeedsForConfigFile(nugetConfigPath)); + + var package = installer.InstallPackage( + packageId: new PackageId("GlObAl.TooL.coNsoLe.DemO"), + targetFramework: _testTargetframework, + nugetConfig: nugetConfigPath); + + AssertPackageInstall(reporter, fileSystem, package, store); + + package.Uninstall(); } private static void AssertPackageInstall( @@ -484,11 +506,14 @@ namespace Microsoft.DotNet.ToolPackage.Tests { reporter.Lines.Should().BeEmpty(); - package.PackageId.Should().Be(TestPackageId); - package.PackageVersion.Should().Be(TestPackageVersion); + package.Id.Should().Be(TestPackageId); + package.Version.ToNormalizedString().Should().Be(TestPackageVersion); package.PackageDirectory.Value.Should().Contain(store.Root.Value); - store.GetInstalledPackages(TestPackageId).Select(p => p.PackageVersion).Should().Equal(TestPackageVersion); + store.EnumeratePackageVersions(TestPackageId) + .Select(p => p.Version.ToNormalizedString()) + .Should() + .Equal(TestPackageVersion); package.Commands.Count.Should().Be(1); fileSystem.File.Exists(package.Commands[0].Executable.Value).Should().BeTrue($"{package.Commands[0].Executable.Value} should exist"); @@ -506,11 +531,11 @@ namespace Microsoft.DotNet.ToolPackage.Tests .Directory .EnumerateFileSystemEntries(store.Root.Value) .Should() - .NotContain(e => Path.GetFileName(e) != ".stage"); + .NotContain(e => Path.GetFileName(e) != ToolPackageStore.StagingDirectory); fileSystem .Directory - .EnumerateFileSystemEntries(store.Root.WithSubDirectories(".stage").Value) + .EnumerateFileSystemEntries(store.Root.WithSubDirectories(ToolPackageStore.StagingDirectory).Value) .Should() .BeEmpty(); } @@ -536,7 +561,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests { new MockFeedPackage { - PackageId = TestPackageId, + PackageId = TestPackageId.ToString(), Version = TestPackageVersion } } @@ -556,7 +581,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests { new MockFeedPackage { - PackageId = TestPackageId, + PackageId = TestPackageId.ToString(), Version = TestPackageVersion } } @@ -576,7 +601,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests { new MockFeedPackage { - PackageId = TestPackageId, + PackageId = TestPackageId.ToString(), Version = TestPackageVersion } } @@ -642,6 +667,6 @@ namespace Microsoft.DotNet.ToolPackage.Tests private static string GetTestLocalFeedPath() => Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "TestAssetLocalNugetFeed"); private readonly string _testTargetframework = BundledTargetFramework.GetTargetFrameworkMoniker(); private const string TestPackageVersion = "1.0.4"; - private const string TestPackageId = "global.tool.console.demo"; + private static readonly PackageId TestPackageId = new PackageId("global.tool.console.demo"); } } diff --git a/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/ProjectRestorerMock.cs b/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/ProjectRestorerMock.cs index 2bdb35820..f4f280df5 100644 --- a/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/ProjectRestorerMock.cs +++ b/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/ProjectRestorerMock.cs @@ -11,6 +11,7 @@ using Microsoft.DotNet.ToolPackage; using Microsoft.DotNet.Tools; using Microsoft.DotNet.Tools.Install.Tool; using Microsoft.Extensions.EnvironmentAbstractions; +using NuGet.Versioning; namespace Microsoft.DotNet.Tools.Tests.ComponentMocks { @@ -63,7 +64,7 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks string verbosity = null) { string packageId; - string packageVersion; + VersionRange versionRange; string targetFramework; try @@ -77,7 +78,7 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks } packageId = tokens[0]; - packageVersion = tokens[1]; + versionRange = VersionRange.Parse(tokens[1]); targetFramework = tokens[2]; } catch (IOException) @@ -92,16 +93,16 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks var feedPackage = GetPackage( packageId, - packageVersion, + versionRange, nugetConfig, source); - packageVersion = feedPackage.Version; + var packageVersion = feedPackage.Version; targetFramework = string.IsNullOrEmpty(targetFramework) ? "targetFramework" : targetFramework; var fakeExecutableSubDirectory = Path.Combine( - packageId, - packageVersion, + packageId.ToLowerInvariant(), + packageVersion.ToLowerInvariant(), "tools", targetFramework, "any"); @@ -116,7 +117,7 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks private MockFeedPackage GetPackage( string packageId, - string packageVersion = null, + VersionRange versionRange = null, FilePath? nugetConfig = null, string source = null) { @@ -133,7 +134,7 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks return true; }) .SelectMany(f => f.Packages) - .Where(p => MatchPackageVersion(p, packageId, packageVersion)).OrderByDescending(p => p.Version) + .Where(p => MatchPackage(p, packageId, versionRange)).OrderByDescending(p => p.Version) .FirstOrDefault(); if (package == null) @@ -148,13 +149,15 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks return package; } - private static bool MatchPackageVersion(MockFeedPackage p, string packageId, string packageVersion) + private static bool MatchPackage(MockFeedPackage p, string packageId, VersionRange versionRange) { - if (string.IsNullOrEmpty(packageVersion)) + if (string.Compare(p.PackageId, packageId, StringComparison.CurrentCultureIgnoreCase) != 0) { - return p.PackageId == packageId; + return false; } - return p.PackageId == packageId && p.Version == packageVersion; + + return versionRange == null || + versionRange.FindBestMatch(new[] { NuGetVersion.Parse(p.Version) }) != null; } } } diff --git a/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/ToolPackageInstallerMock.cs b/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/ToolPackageInstallerMock.cs index cce1000f5..9966ddb6a 100644 --- a/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/ToolPackageInstallerMock.cs +++ b/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/ToolPackageInstallerMock.cs @@ -10,6 +10,7 @@ using Microsoft.DotNet.Cli; using Microsoft.DotNet.ToolPackage; using Microsoft.DotNet.Tools; using Microsoft.Extensions.EnvironmentAbstractions; +using NuGet.Versioning; namespace Microsoft.DotNet.Tools.Tests.ComponentMocks { @@ -35,19 +36,19 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks } public IToolPackage InstallPackage( - string packageId, - string packageVersion = null, + PackageId packageId, + VersionRange versionRange = null, string targetFramework = null, FilePath? nugetConfig = null, string source = null, string verbosity = null) { - var packageRootDirectory = _store.Root.WithSubDirectories(packageId); + var packageRootDirectory = _store.GetRootPackageDirectory(packageId); string rollbackDirectory = null; return TransactionalAction.Run( action: () => { - var stageDirectory = _store.Root.WithSubDirectories(".stage", Path.GetRandomFileName()); + var stageDirectory = _store.GetRandomStagingDirectory(); _fileSystem.Directory.CreateDirectory(stageDirectory.Value); rollbackDirectory = stageDirectory.Value; @@ -56,7 +57,7 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks // Write a fake project with the requested package id, version, and framework _fileSystem.File.WriteAllText( tempProject.Value, - $"{packageId}:{packageVersion}:{targetFramework}"); + $"{packageId}:{versionRange?.ToString("S", new VersionRangeFormatter()) ?? "*"}:{targetFramework}"); // Perform a restore on the fake project _projectRestorer.Restore( @@ -71,29 +72,22 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks _installCallback(); } - packageVersion = Path.GetFileName( - _fileSystem.Directory.EnumerateFileSystemEntries( - stageDirectory.WithSubDirectories(packageId).Value).Single()); - - var packageDirectory = packageRootDirectory.WithSubDirectories(packageVersion); + var version = _store.GetStagedPackageVersion(stageDirectory, packageId); + var packageDirectory = _store.GetPackageDirectory(packageId, version); if (_fileSystem.Directory.Exists(packageDirectory.Value)) { throw new ToolPackageException( string.Format( CommonLocalizableStrings.ToolPackageConflictPackageId, packageId, - packageVersion)); + version.ToNormalizedString())); } _fileSystem.Directory.CreateDirectory(packageRootDirectory.Value); _fileSystem.Directory.Move(stageDirectory.Value, packageDirectory.Value); rollbackDirectory = packageDirectory.Value; - return new ToolPackageMock( - _fileSystem, - packageId, - packageVersion, - packageDirectory); + return new ToolPackageMock(_fileSystem, packageId, version, packageDirectory); }, rollback: () => { if (rollbackDirectory != null && _fileSystem.Directory.Exists(rollbackDirectory)) diff --git a/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/ToolPackageMock.cs b/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/ToolPackageMock.cs index 5e968a288..6ad826441 100644 --- a/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/ToolPackageMock.cs +++ b/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/ToolPackageMock.cs @@ -8,6 +8,7 @@ using System.Linq; using Microsoft.DotNet.Cli; using Microsoft.DotNet.ToolPackage; using Microsoft.Extensions.EnvironmentAbstractions; +using NuGet.Versioning; namespace Microsoft.DotNet.Tools.Tests.ComponentMocks { @@ -19,22 +20,22 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks public ToolPackageMock( IFileSystem fileSystem, - string packageId, - string packageVersion, + PackageId id, + NuGetVersion version, DirectoryPath packageDirectory, Action uninstallCallback = null) { _fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem)); - PackageId = packageId ?? throw new ArgumentNullException(nameof(packageId)); - PackageVersion = packageVersion ?? throw new ArgumentNullException(nameof(packageVersion)); + Id = id; + Version = version ?? throw new ArgumentNullException(nameof(version)); PackageDirectory = packageDirectory; _commands = new Lazy>(GetCommands); _uninstallCallback = uninstallCallback; } - public string PackageId { get; private set; } + public PackageId Id { get; private set; } - public string PackageVersion { get; private set; } + public NuGetVersion Version { get; private set; } public DirectoryPath PackageDirectory { get; private set; } @@ -78,7 +79,7 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks throw new ToolPackageException( string.Format( CommonLocalizableStrings.FailedToUninstallToolPackage, - PackageId, + Id, ex.Message), ex); } @@ -118,7 +119,7 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks throw new ToolPackageException( string.Format( CommonLocalizableStrings.FailedToRetrieveToolConfiguration, - PackageId, + Id, ex.Message), ex); } diff --git a/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/ToolPackageStoreMock.cs b/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/ToolPackageStoreMock.cs index 4681d3123..e8219560c 100644 --- a/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/ToolPackageStoreMock.cs +++ b/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/ToolPackageStoreMock.cs @@ -8,6 +8,7 @@ using System.Linq; using Microsoft.DotNet.Cli; using Microsoft.DotNet.ToolPackage; using Microsoft.Extensions.EnvironmentAbstractions; +using NuGet.Versioning; namespace Microsoft.DotNet.Tools.Tests.ComponentMocks { @@ -28,9 +29,66 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks public DirectoryPath Root { get; private set; } - public IEnumerable GetInstalledPackages(string packageId) + public DirectoryPath GetRandomStagingDirectory() { - var packageRootDirectory = Root.WithSubDirectories(packageId); + return Root.WithSubDirectories(ToolPackageStore.StagingDirectory, Path.GetRandomFileName()); + } + + public NuGetVersion GetStagedPackageVersion(DirectoryPath stagingDirectory, PackageId packageId) + { + if (NuGetVersion.TryParse( + Path.GetFileName( + _fileSystem.Directory.EnumerateFileSystemEntries( + stagingDirectory.WithSubDirectories(packageId.ToString()).Value).FirstOrDefault()), + out var version)) + { + return version; + } + + throw new ToolPackageException( + string.Format( + CommonLocalizableStrings.FailedToFindStagedToolPackage, + packageId)); + } + + public DirectoryPath GetRootPackageDirectory(PackageId packageId) + { + return Root.WithSubDirectories(packageId.ToString()); + } + + public DirectoryPath GetPackageDirectory(PackageId packageId, NuGetVersion version) + { + return GetRootPackageDirectory(packageId) + .WithSubDirectories(version.ToNormalizedString().ToLowerInvariant()); + } + + public IEnumerable EnumeratePackages() + { + if (!_fileSystem.Directory.Exists(Root.Value)) + { + yield break; + } + + foreach (var subdirectory in _fileSystem.Directory.EnumerateFileSystemEntries(Root.Value)) + { + var name = Path.GetFileName(subdirectory); + var packageId = new PackageId(name); + + if (name == ToolPackageStore.StagingDirectory || name != packageId.ToString()) + { + continue; + } + + foreach (var package in EnumeratePackageVersions(packageId)) + { + yield return package; + } + } + } + + public IEnumerable EnumeratePackageVersions(PackageId packageId) + { + var packageRootDirectory = Root.WithSubDirectories(packageId.ToString()); if (!_fileSystem.Directory.Exists(packageRootDirectory.Value)) { yield break; @@ -38,14 +96,23 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks foreach (var subdirectory in _fileSystem.Directory.EnumerateFileSystemEntries(packageRootDirectory.Value)) { - var version = Path.GetFileName(subdirectory); yield return new ToolPackageMock( _fileSystem, packageId, - version, - packageRootDirectory.WithSubDirectories(version), + NuGetVersion.Parse(Path.GetFileName(subdirectory)), + new DirectoryPath(subdirectory), _uninstallCallback); } } + + public IToolPackage GetPackage(PackageId packageId, NuGetVersion version) + { + var directory = GetPackageDirectory(packageId, version); + if (!_fileSystem.Directory.Exists(directory.Value)) + { + return null; + } + return new ToolPackageMock(_fileSystem, packageId, version, directory, _uninstallCallback); + } } } diff --git a/test/dotnet.Tests/CommandTests/InstallToolCommandTests.cs b/test/dotnet.Tests/CommandTests/InstallToolCommandTests.cs index 1a1f140b0..15b626428 100644 --- a/test/dotnet.Tests/CommandTests/InstallToolCommandTests.cs +++ b/test/dotnet.Tests/CommandTests/InstallToolCommandTests.cs @@ -148,17 +148,12 @@ namespace Microsoft.DotNet.Tests.Commands installToolCommand.Execute().Should().Be(1); - _reporter.Lines.Count.Should().Be(2); - _reporter - .Lines[0] + .Lines .Should() - .Contain("Simulated error"); - - _reporter - .Lines[1] - .Should() - .Contain(string.Format(LocalizableStrings.ToolInstallationFailed, PackageId)); + .Equal( + "Simulated error".Red(), + string.Format(LocalizableStrings.ToolInstallationFailed, PackageId).Red()); _fileSystem.Directory.Exists(Path.Combine(PathToPlacePackages, PackageId)).Should().BeFalse(); } @@ -205,20 +200,14 @@ namespace Microsoft.DotNet.Tests.Commands installToolCommand.Execute().Should().Be(1); - _reporter.Lines.Count.Should().Be(2); - _reporter - .Lines[0] + .Lines .Should() - .Contain( + .Equal( string.Format( LocalizableStrings.InvalidToolConfiguration, - "Simulated error")); - - _reporter - .Lines[1] - .Should() - .Contain(string.Format(LocalizableStrings.ToolInstallationFailedContactAuthor, PackageId)); + "Simulated error").Red(), + string.Format(LocalizableStrings.ToolInstallationFailedContactAuthor, PackageId).Red()); } [Fact] @@ -237,13 +226,144 @@ namespace Microsoft.DotNet.Tests.Commands _reporter .Lines - .Single() .Should() - .Contain(string.Format( + .Equal(string.Format( LocalizableStrings.InstallationSucceeded, ProjectRestorerMock.FakeCommandName, PackageId, - PackageVersion)); + PackageVersion).Green()); + } + + [Fact] + public void WhenRunWithInvalidVersionItShouldThrow() + { + const string invalidVersion = "!NotValidVersion!"; + ParseResult result = Parser.Instance.Parse($"dotnet install tool -g {PackageId} --version {invalidVersion}"); + AppliedOption appliedCommand = result["dotnet"]["install"]["tool"]; + + var installToolCommand = new InstallToolCommand( + appliedCommand, + result, + _toolPackageStore, + CreateToolPackageInstaller(), + _shellShimRepositoryMock, + new EnvironmentPathInstructionMock(_reporter, PathToPlaceShim, true), + _reporter); + + Action action = () => installToolCommand.Execute(); + + action + .ShouldThrow() + .WithMessage(string.Format( + LocalizableStrings.InvalidNuGetVersionRange, + invalidVersion)); + } + + [Fact] + public void WhenRunWithExactVersionItShouldSucceed() + { + ParseResult result = Parser.Instance.Parse($"dotnet install tool -g {PackageId} --version {PackageVersion}"); + AppliedOption appliedCommand = result["dotnet"]["install"]["tool"]; + + var installToolCommand = new InstallToolCommand( + appliedCommand, + result, + _toolPackageStore, + CreateToolPackageInstaller(), + _shellShimRepositoryMock, + new EnvironmentPathInstructionMock(_reporter, PathToPlaceShim, true), + _reporter); + + installToolCommand.Execute().Should().Be(0); + + _reporter + .Lines + .Should() + .Equal(string.Format( + LocalizableStrings.InstallationSucceeded, + ProjectRestorerMock.FakeCommandName, + PackageId, + PackageVersion).Green()); + } + + [Fact] + public void WhenRunWithValidVersionRangeItShouldSucceed() + { + ParseResult result = Parser.Instance.Parse($"dotnet install tool -g {PackageId} --version [1.0,2.0]"); + AppliedOption appliedCommand = result["dotnet"]["install"]["tool"]; + + var installToolCommand = new InstallToolCommand( + appliedCommand, + result, + _toolPackageStore, + CreateToolPackageInstaller(), + _shellShimRepositoryMock, + new EnvironmentPathInstructionMock(_reporter, PathToPlaceShim, true), + _reporter); + + installToolCommand.Execute().Should().Be(0); + + _reporter + .Lines + .Should() + .Equal(string.Format( + LocalizableStrings.InstallationSucceeded, + ProjectRestorerMock.FakeCommandName, + PackageId, + PackageVersion).Green()); + } + + [Fact] + public void WhenRunWithoutAMatchingRangeItShouldFail() + { + ParseResult result = Parser.Instance.Parse($"dotnet install tool -g {PackageId} --version [5.0,10.0]"); + AppliedOption appliedCommand = result["dotnet"]["install"]["tool"]; + + var installToolCommand = new InstallToolCommand( + appliedCommand, + result, + _toolPackageStore, + CreateToolPackageInstaller(), + _shellShimRepositoryMock, + new EnvironmentPathInstructionMock(_reporter, PathToPlaceShim, true), + _reporter); + + installToolCommand.Execute().Should().Be(1); + + _reporter + .Lines + .Should() + .Equal( + $"Error: failed to restore package {PackageId}.", // From mock implementation, not localized + LocalizableStrings.ToolInstallationRestoreFailed.Red(), + string.Format(LocalizableStrings.ToolInstallationFailed, PackageId).Red()); + } + + [Fact] + public void WhenRunWithValidVersionWildcardItShouldSucceed() + { + ParseResult result = Parser.Instance.Parse($"dotnet install tool -g {PackageId} --version 1.0.*"); + AppliedOption appliedCommand = result["dotnet"]["install"]["tool"]; + + var installToolCommand = new InstallToolCommand( + appliedCommand, + result, + _toolPackageStore, + CreateToolPackageInstaller(), + _shellShimRepositoryMock, + new EnvironmentPathInstructionMock(_reporter, PathToPlaceShim, true), + _reporter); + + installToolCommand.Execute().Should().Be(0); + + _reporter + .Lines + .Should() + .Equal(string.Format( + LocalizableStrings.InstallationSucceeded, + ProjectRestorerMock.FakeCommandName, + PackageId, + PackageVersion).Green()); } private IToolPackageInstaller CreateToolPackageInstaller( From da90a08ada0e91992e6bb3ed060dffe780af6531 Mon Sep 17 00:00:00 2001 From: Peter Huene Date: Fri, 2 Mar 2018 14:35:23 -0800 Subject: [PATCH 6/6] Implement tests for the list tool command. This commit implements tests for the `list tool` command. --- src/dotnet/Properties/AssemblyInfo.cs | 1 + .../CommandTests/ListToolCommandTests.cs | 261 ++++++++++++++++++ test/dotnet.Tests/dotnet.Tests.csproj | 2 + 3 files changed, 264 insertions(+) create mode 100644 test/dotnet.Tests/CommandTests/ListToolCommandTests.cs diff --git a/src/dotnet/Properties/AssemblyInfo.cs b/src/dotnet/Properties/AssemblyInfo.cs index 25bd8cb8c..b5f0b8fe0 100644 --- a/src/dotnet/Properties/AssemblyInfo.cs +++ b/src/dotnet/Properties/AssemblyInfo.cs @@ -21,3 +21,4 @@ using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("Microsoft.DotNet.Tools.Tests.ComponentMocks, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.DotNet.ToolPackage.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.DotNet.ShellShim.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] diff --git a/test/dotnet.Tests/CommandTests/ListToolCommandTests.cs b/test/dotnet.Tests/CommandTests/ListToolCommandTests.cs new file mode 100644 index 000000000..3b764abb4 --- /dev/null +++ b/test/dotnet.Tests/CommandTests/ListToolCommandTests.cs @@ -0,0 +1,261 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using FluentAssertions; +using Microsoft.DotNet.Cli; +using Microsoft.DotNet.Cli.CommandLine; +using Microsoft.DotNet.Cli.Utils; +using Microsoft.DotNet.ToolPackage; +using Microsoft.DotNet.Tools; +using Microsoft.DotNet.Tools.List.Tool; +using Microsoft.DotNet.Tools.Test.Utilities; +using Microsoft.Extensions.DependencyModel.Tests; +using Microsoft.Extensions.EnvironmentAbstractions; +using Moq; +using NuGet.Versioning; +using Xunit; +using Parser = Microsoft.DotNet.Cli.Parser; +using LocalizableStrings = Microsoft.DotNet.Tools.List.Tool.LocalizableStrings; + +namespace Microsoft.DotNet.Tests.Commands +{ + public class ListToolCommandTests + { + private readonly BufferedReporter _reporter; + + public ListToolCommandTests() + { + _reporter = new BufferedReporter(); + } + + [Fact] + public void GivenAMissingGlobalOptionItErrors() + { + var store = new Mock(MockBehavior.Strict); + + var command = CreateCommand(store.Object); + + Action a = () => { + command.Execute(); + }; + + a.ShouldThrow() + .And + .Message + .Should() + .Be(LocalizableStrings.ListToolCommandOnlySupportsGlobal); + } + + [Fact] + public void GivenNoInstalledPackagesItPrintsEmptyTable() + { + var store = new Mock(MockBehavior.Strict); + store + .Setup(s => s.EnumeratePackages()) + .Returns(new IToolPackage[0]); + + var command = CreateCommand(store.Object, "-g"); + + command.Execute().Should().Be(0); + + _reporter.Lines.Should().Equal( + string.Format( + "{0} {1} {2}", + LocalizableStrings.PackageIdColumn, + LocalizableStrings.VersionColumn, + LocalizableStrings.CommandsColumn + ), + "-------------------------------------"); + } + + [Fact] + public void GivenASingleInstalledPackageItPrintsThePackage() + { + var store = new Mock(MockBehavior.Strict); + store + .Setup(s => s.EnumeratePackages()) + .Returns(new[] { + CreateMockToolPackage( + "test.tool", + "1.3.5-preview", + new[] { + new CommandSettings("foo", "dotnet", new FilePath("tool")) + } + ) + }); + + var command = CreateCommand(store.Object, "-g"); + + command.Execute().Should().Be(0); + + _reporter.Lines.Should().Equal( + string.Format( + "{0} {1} {2}", + LocalizableStrings.PackageIdColumn, + LocalizableStrings.VersionColumn, + LocalizableStrings.CommandsColumn + ), + "-------------------------------------------", + "test.tool 1.3.5-preview foo "); + } + + [Fact] + public void GivenMultipleInstalledPackagesItPrintsThePackages() + { + var store = new Mock(MockBehavior.Strict); + store + .Setup(s => s.EnumeratePackages()) + .Returns(new[] { + CreateMockToolPackage( + "test.tool", + "1.3.5-preview", + new[] { + new CommandSettings("foo", "dotnet", new FilePath("tool")) + } + ), + CreateMockToolPackage( + "another.tool", + "2.7.3", + new[] { + new CommandSettings("bar", "dotnet", new FilePath("tool")) + } + ), + CreateMockToolPackage( + "some.tool", + "1.0.0", + new[] { + new CommandSettings("fancy-foo", "dotnet", new FilePath("tool")) + } + ) + }); + + var command = CreateCommand(store.Object, "-g"); + + command.Execute().Should().Be(0); + + _reporter.Lines.Should().Equal( + string.Format( + "{0} {1} {2} ", + LocalizableStrings.PackageIdColumn, + LocalizableStrings.VersionColumn, + LocalizableStrings.CommandsColumn + ), + "----------------------------------------------", + "another.tool 2.7.3 bar ", + "some.tool 1.0.0 fancy-foo", + "test.tool 1.3.5-preview foo "); + } + + [Fact] + public void GivenAPackageWithMultipleCommandsItListsThem() + { + var store = new Mock(MockBehavior.Strict); + store + .Setup(s => s.EnumeratePackages()) + .Returns(new[] { + CreateMockToolPackage( + "test.tool", + "1.3.5-preview", + new[] { + new CommandSettings("foo", "dotnet", new FilePath("tool")), + new CommandSettings("bar", "dotnet", new FilePath("tool")), + new CommandSettings("baz", "dotnet", new FilePath("tool")) + } + ) + }); + + var command = CreateCommand(store.Object, "-g"); + + command.Execute().Should().Be(0); + + _reporter.Lines.Should().Equal( + string.Format( + "{0} {1} {2} ", + LocalizableStrings.PackageIdColumn, + LocalizableStrings.VersionColumn, + LocalizableStrings.CommandsColumn + ), + "------------------------------------------------", + "test.tool 1.3.5-preview foo, bar, baz"); + } + + [Fact] + public void GivenABrokenPackageItPrintsWarning() + { + var store = new Mock(MockBehavior.Strict); + store + .Setup(s => s.EnumeratePackages()) + .Returns(new[] { + CreateMockToolPackage( + "test.tool", + "1.3.5-preview", + new[] { + new CommandSettings("foo", "dotnet", new FilePath("tool")) + } + ), + CreateMockBrokenPackage("another.tool", "2.7.3"), + CreateMockToolPackage( + "some.tool", + "1.0.0", + new[] { + new CommandSettings("fancy-foo", "dotnet", new FilePath("tool")) + } + ) + }); + + var command = CreateCommand(store.Object, "-g"); + + command.Execute().Should().Be(0); + + _reporter.Lines.Should().Equal( + string.Format( + LocalizableStrings.InvalidPackageWarning, + "another.tool", + "broken" + ).Yellow(), + string.Format( + "{0} {1} {2} ", + LocalizableStrings.PackageIdColumn, + LocalizableStrings.VersionColumn, + LocalizableStrings.CommandsColumn + ), + "--------------------------------------------", + "some.tool 1.0.0 fancy-foo", + "test.tool 1.3.5-preview foo "); + } + + private IToolPackage CreateMockToolPackage(string id, string version, IReadOnlyList commands) + { + var package = new Mock(MockBehavior.Strict); + + package.SetupGet(p => p.Id).Returns(new PackageId(id)); + package.SetupGet(p => p.Version).Returns(NuGetVersion.Parse(version)); + package.SetupGet(p => p.Commands).Returns(commands); + return package.Object; + } + + private IToolPackage CreateMockBrokenPackage(string id, string version) + { + var package = new Mock(MockBehavior.Strict); + + package.SetupGet(p => p.Id).Returns(new PackageId(id)); + package.SetupGet(p => p.Version).Returns(NuGetVersion.Parse(version)); + package.SetupGet(p => p.Commands).Throws(new ToolConfigurationException("broken")); + return package.Object; + } + + private ListToolCommand CreateCommand(IToolPackageStore store, string options = "") + { + ParseResult result = Parser.Instance.Parse("dotnet list tool " + options); + return new ListToolCommand( + result["dotnet"]["list"]["tool"], + result, + store, + _reporter); + } + } +} diff --git a/test/dotnet.Tests/dotnet.Tests.csproj b/test/dotnet.Tests/dotnet.Tests.csproj index 561d03b72..7d080f445 100644 --- a/test/dotnet.Tests/dotnet.Tests.csproj +++ b/test/dotnet.Tests/dotnet.Tests.csproj @@ -81,7 +81,9 @@ + +