Add xml setting version warning (#8860)
This commit is contained in:
parent
b5a163c7c1
commit
76d4824c39
29 changed files with 412 additions and 47 deletions
|
@ -628,4 +628,13 @@ setx PATH "%PATH%;{0}"
|
|||
<data name="ToolSettingsInvalidLeadingDotCommandName" xml:space="preserve">
|
||||
<value>The command name '{0}' cannot begin with a leading dot (.).</value>
|
||||
</data>
|
||||
<data name="FormatVersionIsHigher" xml:space="preserve">
|
||||
<value>Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</value>
|
||||
</data>
|
||||
<data name="FormatVersionIsMalformed" xml:space="preserve">
|
||||
<value>Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</value>
|
||||
</data>
|
||||
<data name="FormatVersionIsMissing" xml:space="preserve">
|
||||
<value>Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
|
@ -18,6 +18,8 @@ namespace Microsoft.DotNet.ToolPackage
|
|||
|
||||
IReadOnlyList<CommandSettings> Commands { get; }
|
||||
|
||||
IEnumerable<string> Warnings { get; }
|
||||
|
||||
void Uninstall();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// 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 Microsoft.DotNet.Tools;
|
||||
|
@ -12,7 +13,8 @@ namespace Microsoft.DotNet.ToolPackage
|
|||
{
|
||||
public ToolConfiguration(
|
||||
string commandName,
|
||||
string toolAssemblyEntryPoint)
|
||||
string toolAssemblyEntryPoint,
|
||||
IEnumerable<string> warnings = null)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(commandName))
|
||||
{
|
||||
|
@ -32,6 +34,7 @@ namespace Microsoft.DotNet.ToolPackage
|
|||
|
||||
CommandName = commandName;
|
||||
ToolAssemblyEntryPoint = toolAssemblyEntryPoint;
|
||||
Warnings = warnings ?? new List<string>();
|
||||
}
|
||||
|
||||
private void EnsureNoInvalidFilenameCharacters(string commandName)
|
||||
|
@ -60,5 +63,6 @@ namespace Microsoft.DotNet.ToolPackage
|
|||
|
||||
public string CommandName { get; }
|
||||
public string ToolAssemblyEntryPoint { get; }
|
||||
public IEnumerable<string> Warnings { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,5 +9,8 @@ namespace Microsoft.DotNet.ToolPackage.ToolConfigurationDeserialization
|
|||
{
|
||||
[XmlArrayItem("Command", IsNullable = false)]
|
||||
public DotNetCliToolCommand[] Commands { get; set; }
|
||||
|
||||
[XmlAttribute(AttributeName = "Version")]
|
||||
public string Version { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// 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.Xml;
|
||||
using System.Xml.Serialization;
|
||||
|
@ -12,6 +13,10 @@ namespace Microsoft.DotNet.ToolPackage
|
|||
{
|
||||
internal static class ToolConfigurationDeserializer
|
||||
{
|
||||
// The supported tool configuration schema version.
|
||||
// This should match the schema version in the GenerateToolsSettingsFile task from the SDK.
|
||||
private const int SupportedVersion = 1;
|
||||
|
||||
public static ToolConfiguration Deserialize(string pathToXml)
|
||||
{
|
||||
var serializer = new XmlSerializer(typeof(DotNetCliTool));
|
||||
|
@ -43,6 +48,8 @@ namespace Microsoft.DotNet.ToolPackage
|
|||
ex);
|
||||
}
|
||||
|
||||
List<string> warnings = GenerateWarningAccordingToVersionAttribute(dotNetCliTool);
|
||||
|
||||
if (dotNetCliTool.Commands.Length != 1)
|
||||
{
|
||||
throw new ToolConfigurationException(CommonLocalizableStrings.ToolSettingsMoreThanOneCommand);
|
||||
|
@ -59,7 +66,33 @@ namespace Microsoft.DotNet.ToolPackage
|
|||
|
||||
return new ToolConfiguration(
|
||||
dotNetCliTool.Commands[0].Name,
|
||||
dotNetCliTool.Commands[0].EntryPoint);
|
||||
dotNetCliTool.Commands[0].EntryPoint,
|
||||
warnings);
|
||||
}
|
||||
|
||||
private static List<string> GenerateWarningAccordingToVersionAttribute(DotNetCliTool dotNetCliTool)
|
||||
{
|
||||
List<string> warnings = new List<string>();
|
||||
if (string.IsNullOrWhiteSpace(dotNetCliTool.Version))
|
||||
{
|
||||
warnings.Add(CommonLocalizableStrings.FormatVersionIsMissing);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!int.TryParse(dotNetCliTool.Version, out int version))
|
||||
{
|
||||
warnings.Add(CommonLocalizableStrings.FormatVersionIsMalformed);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (version > SupportedVersion)
|
||||
{
|
||||
warnings.Add(CommonLocalizableStrings.FormatVersionIsHigher);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return warnings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,23 +13,7 @@ namespace Microsoft.DotNet.ToolPackage
|
|||
// This is named "ToolPackageInstance" because "ToolPackage" would conflict with the namespace
|
||||
internal class ToolPackageInstance : IToolPackage
|
||||
{
|
||||
private IToolPackageStore _store;
|
||||
private Lazy<IReadOnlyList<CommandSettings>> _commands;
|
||||
|
||||
public ToolPackageInstance(
|
||||
IToolPackageStore store,
|
||||
PackageId id,
|
||||
NuGetVersion version,
|
||||
DirectoryPath packageDirectory)
|
||||
{
|
||||
_store = store ?? throw new ArgumentNullException(nameof(store));
|
||||
_commands = new Lazy<IReadOnlyList<CommandSettings>>(GetCommands);
|
||||
|
||||
Id = id;
|
||||
Version = version ?? throw new ArgumentNullException(nameof(version));
|
||||
PackageDirectory = packageDirectory;
|
||||
}
|
||||
|
||||
public IEnumerable<string> Warnings => _toolConfiguration.Value.Warnings;
|
||||
public PackageId Id { get; private set; }
|
||||
|
||||
public NuGetVersion Version { get; private set; }
|
||||
|
@ -44,13 +28,36 @@ namespace Microsoft.DotNet.ToolPackage
|
|||
}
|
||||
}
|
||||
|
||||
private const string AssetsFileName = "project.assets.json";
|
||||
private const string ToolSettingsFileName = "DotnetToolSettings.xml";
|
||||
|
||||
private IToolPackageStore _store;
|
||||
private Lazy<IReadOnlyList<CommandSettings>> _commands;
|
||||
private Lazy<ToolConfiguration> _toolConfiguration;
|
||||
|
||||
public ToolPackageInstance(
|
||||
IToolPackageStore store,
|
||||
PackageId id,
|
||||
NuGetVersion version,
|
||||
DirectoryPath packageDirectory)
|
||||
{
|
||||
_store = store ?? throw new ArgumentNullException(nameof(store));
|
||||
_commands = new Lazy<IReadOnlyList<CommandSettings>>(GetCommands);
|
||||
|
||||
Id = id;
|
||||
Version = version ?? throw new ArgumentNullException(nameof(version));
|
||||
PackageDirectory = packageDirectory;
|
||||
_toolConfiguration = new Lazy<ToolConfiguration>(GetToolConfiguration);
|
||||
}
|
||||
|
||||
public void Uninstall()
|
||||
{
|
||||
var rootDirectory = PackageDirectory.GetParentPath();
|
||||
string tempPackageDirectory = null;
|
||||
|
||||
TransactionalAction.Run(
|
||||
action: () => {
|
||||
action: () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Directory.Exists(PackageDirectory.Value))
|
||||
|
@ -78,13 +85,15 @@ namespace Microsoft.DotNet.ToolPackage
|
|||
ex);
|
||||
}
|
||||
},
|
||||
commit: () => {
|
||||
commit: () =>
|
||||
{
|
||||
if (tempPackageDirectory != null)
|
||||
{
|
||||
Directory.Delete(tempPackageDirectory, true);
|
||||
}
|
||||
},
|
||||
rollback: () => {
|
||||
rollback: () =>
|
||||
{
|
||||
if (tempPackageDirectory != null)
|
||||
{
|
||||
Directory.CreateDirectory(rootDirectory.Value);
|
||||
|
@ -95,31 +104,13 @@ namespace Microsoft.DotNet.ToolPackage
|
|||
|
||||
private IReadOnlyList<CommandSettings> GetCommands()
|
||||
{
|
||||
const string AssetsFileName = "project.assets.json";
|
||||
const string ToolSettingsFileName = "DotnetToolSettings.xml";
|
||||
|
||||
try
|
||||
{
|
||||
var commands = new List<CommandSettings>();
|
||||
var lockFile = new LockFileFormat().Read(PackageDirectory.WithFile(AssetsFileName).Value);
|
||||
|
||||
var library = FindLibraryInLockFile(lockFile);
|
||||
var dotnetToolSettings = FindItemInTargetLibrary(library, ToolSettingsFileName);
|
||||
if (dotnetToolSettings == null)
|
||||
{
|
||||
throw new ToolConfigurationException(
|
||||
CommonLocalizableStrings.MissingToolSettingsFile);
|
||||
}
|
||||
|
||||
var toolConfigurationPath =
|
||||
PackageDirectory
|
||||
.WithSubDirectories(
|
||||
Id.ToString(),
|
||||
library.Version.ToNormalizedString())
|
||||
.WithFile(dotnetToolSettings.Path);
|
||||
|
||||
var configuration = ToolConfigurationDeserializer.Deserialize(toolConfigurationPath.Value);
|
||||
|
||||
ToolConfiguration configuration = _toolConfiguration.Value;
|
||||
var entryPointFromLockFile = FindItemInTargetLibrary(library, configuration.ToolAssemblyEntryPoint);
|
||||
if (entryPointFromLockFile == null)
|
||||
{
|
||||
|
@ -152,6 +143,44 @@ namespace Microsoft.DotNet.ToolPackage
|
|||
}
|
||||
}
|
||||
|
||||
private ToolConfiguration GetToolConfiguration()
|
||||
{
|
||||
try
|
||||
{
|
||||
var lockFile = new LockFileFormat().Read(PackageDirectory.WithFile(AssetsFileName).Value);
|
||||
var library = FindLibraryInLockFile(lockFile);
|
||||
return DeserializeToolConfiguration(ToolSettingsFileName, library);
|
||||
}
|
||||
catch (Exception ex) when (ex is UnauthorizedAccessException || ex is IOException)
|
||||
{
|
||||
throw new ToolConfigurationException(
|
||||
string.Format(
|
||||
CommonLocalizableStrings.FailedToRetrieveToolConfiguration,
|
||||
ex.Message),
|
||||
ex);
|
||||
}
|
||||
}
|
||||
|
||||
private ToolConfiguration DeserializeToolConfiguration(string ToolSettingsFileName, LockFileTargetLibrary library)
|
||||
{
|
||||
var dotnetToolSettings = FindItemInTargetLibrary(library, ToolSettingsFileName);
|
||||
if (dotnetToolSettings == null)
|
||||
{
|
||||
throw new ToolConfigurationException(
|
||||
CommonLocalizableStrings.MissingToolSettingsFile);
|
||||
}
|
||||
|
||||
var toolConfigurationPath =
|
||||
PackageDirectory
|
||||
.WithSubDirectories(
|
||||
Id.ToString(),
|
||||
library.Version.ToNormalizedString())
|
||||
.WithFile(dotnetToolSettings.Path);
|
||||
|
||||
var configuration = ToolConfigurationDeserializer.Deserialize(toolConfigurationPath.Value);
|
||||
return configuration;
|
||||
}
|
||||
|
||||
private LockFileTargetLibrary FindLibraryInLockFile(LockFile lockFile)
|
||||
{
|
||||
return lockFile
|
||||
|
@ -166,5 +195,6 @@ namespace Microsoft.DotNet.ToolPackage
|
|||
?.ToolsAssemblies
|
||||
?.SingleOrDefault(t => LockFileMatcher.MatchesFile(t, targetRelativeFilePath));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,6 +148,11 @@ namespace Microsoft.DotNet.Tools.Tool.Install
|
|||
scope.Complete();
|
||||
}
|
||||
|
||||
foreach (string w in package.Warnings)
|
||||
{
|
||||
_reporter.WriteLine(w.Yellow());
|
||||
}
|
||||
|
||||
if (_global)
|
||||
{
|
||||
_environmentPathInstruction.PrintAddPathInstructionIfPathDoesNotExist();
|
||||
|
|
|
@ -863,6 +863,21 @@ setx PATH "%PATH%;{0}"
|
|||
<target state="needs-review-translation">Příkaz {0} obsahuje úvodní tečku.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsHigher">
|
||||
<source>Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</source>
|
||||
<target state="new">Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsMalformed">
|
||||
<source>Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</source>
|
||||
<target state="new">Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsMissing">
|
||||
<source>Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</source>
|
||||
<target state="new">Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -863,6 +863,21 @@ setx PATH "%PATH%;{0}"
|
|||
<target state="needs-review-translation">Der Befehl "{0}" weist einen vorangestellten Punkt auf.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsHigher">
|
||||
<source>Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</source>
|
||||
<target state="new">Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsMalformed">
|
||||
<source>Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</source>
|
||||
<target state="new">Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsMissing">
|
||||
<source>Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</source>
|
||||
<target state="new">Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -863,6 +863,21 @@ setx PATH "%PATH%;{0}"
|
|||
<target state="needs-review-translation">El comando "{0}" tiene un punto al principio.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsHigher">
|
||||
<source>Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</source>
|
||||
<target state="new">Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsMalformed">
|
||||
<source>Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</source>
|
||||
<target state="new">Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsMissing">
|
||||
<source>Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</source>
|
||||
<target state="new">Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -863,6 +863,21 @@ setx PATH "%PATH%;{0}"
|
|||
<target state="needs-review-translation">La commande '{0}' commence par un point.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsHigher">
|
||||
<source>Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</source>
|
||||
<target state="new">Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsMalformed">
|
||||
<source>Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</source>
|
||||
<target state="new">Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsMissing">
|
||||
<source>Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</source>
|
||||
<target state="new">Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -863,6 +863,21 @@ setx PATH "%PATH%;{0}"
|
|||
<target state="needs-review-translation">Il comando '{0}' presenta un punto iniziale.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsHigher">
|
||||
<source>Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</source>
|
||||
<target state="new">Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsMalformed">
|
||||
<source>Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</source>
|
||||
<target state="new">Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsMissing">
|
||||
<source>Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</source>
|
||||
<target state="new">Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -863,6 +863,21 @@ setx PATH "%PATH%;{0}"
|
|||
<target state="needs-review-translation">コマンド '{0}' の先頭にドットがあります。</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsHigher">
|
||||
<source>Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</source>
|
||||
<target state="new">Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsMalformed">
|
||||
<source>Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</source>
|
||||
<target state="new">Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsMissing">
|
||||
<source>Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</source>
|
||||
<target state="new">Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -863,6 +863,21 @@ setx PATH "%PATH%;{0}"
|
|||
<target state="needs-review-translation">명령 '{0}' 앞에 점이 있습니다.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsHigher">
|
||||
<source>Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</source>
|
||||
<target state="new">Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsMalformed">
|
||||
<source>Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</source>
|
||||
<target state="new">Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsMissing">
|
||||
<source>Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</source>
|
||||
<target state="new">Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -863,6 +863,21 @@ setx PATH "%PATH%;{0}"
|
|||
<target state="needs-review-translation">Polecenie „{0}” zawiera kropkę na początku.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsHigher">
|
||||
<source>Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</source>
|
||||
<target state="new">Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsMalformed">
|
||||
<source>Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</source>
|
||||
<target state="new">Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsMissing">
|
||||
<source>Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</source>
|
||||
<target state="new">Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -863,6 +863,21 @@ setx PATH "%PATH%;{0}"
|
|||
<target state="needs-review-translation">O comando '{0}' tem um ponto à esquerda.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsHigher">
|
||||
<source>Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</source>
|
||||
<target state="new">Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsMalformed">
|
||||
<source>Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</source>
|
||||
<target state="new">Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsMissing">
|
||||
<source>Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</source>
|
||||
<target state="new">Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -863,6 +863,21 @@ setx PATH "%PATH%;{0}"
|
|||
<target state="needs-review-translation">В начале команды "{0}" стоит точка.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsHigher">
|
||||
<source>Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</source>
|
||||
<target state="new">Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsMalformed">
|
||||
<source>Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</source>
|
||||
<target state="new">Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsMissing">
|
||||
<source>Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</source>
|
||||
<target state="new">Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -863,6 +863,21 @@ setx PATH "%PATH%;{0}"
|
|||
<target state="needs-review-translation">'{0}' komutunun başında nokta var.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsHigher">
|
||||
<source>Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</source>
|
||||
<target state="new">Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsMalformed">
|
||||
<source>Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</source>
|
||||
<target state="new">Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsMissing">
|
||||
<source>Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</source>
|
||||
<target state="new">Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -863,6 +863,21 @@ setx PATH "%PATH%;{0}"
|
|||
<target state="needs-review-translation">命令“{0}”有一个前导点。</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsHigher">
|
||||
<source>Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</source>
|
||||
<target state="new">Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsMalformed">
|
||||
<source>Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</source>
|
||||
<target state="new">Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsMissing">
|
||||
<source>Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</source>
|
||||
<target state="new">Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -863,6 +863,21 @@ setx PATH "%PATH%;{0}"
|
|||
<target state="needs-review-translation">命令 '{0}' 的開頭有一個點 (.)。</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsHigher">
|
||||
<source>Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</source>
|
||||
<target state="new">Format version is higher than supported. This tool may not be supported in this SDK version. Please update your SDK.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsMalformed">
|
||||
<source>Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</source>
|
||||
<target state="new">Format version is malformed. This tool may not be supported in this SDK version. Please contact the author of the tool.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="FormatVersionIsMissing">
|
||||
<source>Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</source>
|
||||
<target state="new">Format version is missing. This tool may not be supported in this SDK version. Please contact the author of the tool.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<DotNetCliTool>
|
||||
<DotNetCliTool Version="1" >
|
||||
<Commands>
|
||||
<Command Name="sayhello" EntryPoint="console.dll" Runner="dotnet" />
|
||||
</Commands>
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<DotNetCliTool Version="2">
|
||||
<Commands>
|
||||
<Command Name="sayhello" EntryPoint="console.dll" Runner="dotnet" />
|
||||
</Commands>
|
||||
</DotNetCliTool>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<DotNetCliTool>
|
||||
<Commands>
|
||||
<Command Name="sayhello" EntryPoint="console.dll" Runner="dotnet" />
|
||||
</Commands>
|
||||
</DotNetCliTool>
|
|
@ -34,6 +34,12 @@
|
|||
<None Update="DotnetToolSettingsGolden.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="DotnetToolSettingsMissingVersion.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="DotnetToolSettingsMajorHigherVersion.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
|
||||
<Compile Remove="SampleGlobalTool/**" />
|
||||
<Content Remove="SampleGlobalTool/**" />
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<DotNetCliTool>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<DotNetCliTool Version="1" >
|
||||
<Commands>
|
||||
<Command Name="demo" EntryPoint="consoledemo.dll" Runner="dotnet" />
|
||||
</Commands>
|
||||
|
|
|
@ -41,6 +41,30 @@ namespace Microsoft.DotNet.ToolPackage.Tests
|
|||
.Contain(CommonLocalizableStrings.ToolSettingsMissingCommandName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GivenMissingVersionItHasWarningReflectIt()
|
||||
{
|
||||
ToolConfiguration toolConfiguration = ToolConfigurationDeserializer.Deserialize("DotnetToolSettingsMissingVersion.xml");
|
||||
|
||||
toolConfiguration.Warnings.First().Should().Be(CommonLocalizableStrings.FormatVersionIsMissing);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GivenMajorHigherVersionItHasWarningReflectIt()
|
||||
{
|
||||
ToolConfiguration toolConfiguration = ToolConfigurationDeserializer.Deserialize("DotnetToolSettingsMajorHigherVersion.xml");
|
||||
|
||||
toolConfiguration.Warnings.First().Should().Be(CommonLocalizableStrings.FormatVersionIsHigher);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GivenMinorHigherVersionItHasNoWarning()
|
||||
{
|
||||
ToolConfiguration toolConfiguration = ToolConfigurationDeserializer.Deserialize("DotnetToolSettingsGolden.xml");
|
||||
|
||||
toolConfiguration.Warnings.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GivenInvalidCharAsFileNameItThrows()
|
||||
{
|
||||
|
|
|
@ -22,17 +22,20 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks
|
|||
private readonly IProjectRestorer _projectRestorer;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly Action _installCallback;
|
||||
private readonly Dictionary<PackageId, IEnumerable<string>> _warningsMap;
|
||||
|
||||
public ToolPackageInstallerMock(
|
||||
IFileSystem fileSystem,
|
||||
IToolPackageStore store,
|
||||
IProjectRestorer projectRestorer,
|
||||
Action installCallback = null)
|
||||
Action installCallback = null,
|
||||
Dictionary<PackageId, IEnumerable<string>> warningsMap = null)
|
||||
{
|
||||
_fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
|
||||
_store = store ?? throw new ArgumentNullException(nameof(store));
|
||||
_projectRestorer = projectRestorer ?? throw new ArgumentNullException(nameof(projectRestorer));
|
||||
_installCallback = installCallback;
|
||||
_warningsMap = warningsMap ?? new Dictionary<PackageId, IEnumerable<string>>();
|
||||
}
|
||||
|
||||
public IToolPackage InstallPackage(PackageId packageId,
|
||||
|
@ -86,7 +89,10 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks
|
|||
_fileSystem.Directory.Move(stageDirectory.Value, packageDirectory.Value);
|
||||
rollbackDirectory = packageDirectory.Value;
|
||||
|
||||
return new ToolPackageMock(_fileSystem, packageId, version, packageDirectory);
|
||||
IEnumerable<string> warnings = null;
|
||||
_warningsMap.TryGetValue(packageId, out warnings);
|
||||
|
||||
return new ToolPackageMock(_fileSystem, packageId, version, packageDirectory, warnings: warnings);
|
||||
},
|
||||
rollback: () => {
|
||||
if (rollbackDirectory != null && _fileSystem.Directory.Exists(rollbackDirectory))
|
||||
|
|
|
@ -17,13 +17,15 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks
|
|||
private IFileSystem _fileSystem;
|
||||
private Lazy<IReadOnlyList<CommandSettings>> _commands;
|
||||
private Action _uninstallCallback;
|
||||
private IEnumerable<string> _warnings;
|
||||
|
||||
public ToolPackageMock(
|
||||
IFileSystem fileSystem,
|
||||
PackageId id,
|
||||
NuGetVersion version,
|
||||
DirectoryPath packageDirectory,
|
||||
Action uninstallCallback = null)
|
||||
Action uninstallCallback = null,
|
||||
IEnumerable<string> warnings = null)
|
||||
{
|
||||
_fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
|
||||
Id = id;
|
||||
|
@ -31,6 +33,7 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks
|
|||
PackageDirectory = packageDirectory;
|
||||
_commands = new Lazy<IReadOnlyList<CommandSettings>>(GetCommands);
|
||||
_uninstallCallback = uninstallCallback;
|
||||
_warnings = warnings ?? new List<string>();
|
||||
}
|
||||
|
||||
public PackageId Id { get; private set; }
|
||||
|
@ -47,6 +50,8 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks
|
|||
}
|
||||
}
|
||||
|
||||
public IEnumerable<string> Warnings => _warnings;
|
||||
|
||||
public void Uninstall()
|
||||
{
|
||||
var rootDirectory = PackageDirectory.GetParentPath();
|
||||
|
|
|
@ -137,6 +137,37 @@ namespace Microsoft.DotNet.Tests.Commands
|
|||
_reporter.Lines.First().Should().Be(EnvironmentPathInstructionMock.MockInstructionText);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenRunWithPackageIdPackageFormatIsNotFullySupportedItShouldShowPathInstruction()
|
||||
{
|
||||
const string Warning = "WARNING";
|
||||
var injectedWarnings = new Dictionary<PackageId, IEnumerable<string>>()
|
||||
{
|
||||
[new PackageId(PackageId)] = new List<string>() { Warning }
|
||||
};
|
||||
|
||||
var toolPackageInstaller = new ToolPackageInstallerMock(
|
||||
fileSystem: _fileSystem,
|
||||
store: _toolPackageStore,
|
||||
projectRestorer: new ProjectRestorerMock(
|
||||
fileSystem: _fileSystem,
|
||||
reporter: _reporter),
|
||||
warningsMap: injectedWarnings);
|
||||
|
||||
var installToolCommand = new ToolInstallCommand(
|
||||
_appliedCommand,
|
||||
_parseResult,
|
||||
(_) => (_toolPackageStore, toolPackageInstaller),
|
||||
_createShellShimRepository,
|
||||
_environmentPathInstructionMock,
|
||||
_reporter);
|
||||
|
||||
installToolCommand.Execute().Should().Be(0);
|
||||
|
||||
_reporter.Lines.First().Should().Be(Warning.Yellow());
|
||||
_reporter.Lines.Skip(1).First().Should().Be(EnvironmentPathInstructionMock.MockInstructionText);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GivenFailedPackageInstallWhenRunWithPackageIdItShouldFail()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue