dotnet-installer/src/dotnet/ToolPackage/ToolConfiguration.cs
William Lee 55f62d9d64
Add install tool command (#8132)
* compose all the parts

* Fix on obtain and shim maker for better end to end experience
  * Fix error when there is space in the middle of path of nuget config
  * Fix path in profile.d is the tmp home path during install
  * better handle of ~home
  * remove profile.d file in uninstall script
  * Fix test since it looks up current directory
  * folder structure inside nupkg to tools/TFM/RID/mytool.dll
  * Add check for config file existence
  * Rename name space to Microsoft.DotNet.ShellShim
  * Rename name space to Microsoft.DotNet.ToolPackage
2017-12-04 14:13:24 -08:00

46 lines
1.6 KiB
C#

// 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.IO;
namespace Microsoft.DotNet.ToolPackage
{
internal class ToolConfiguration
{
public ToolConfiguration(
string commandName,
string toolAssemblyEntryPoint)
{
if (string.IsNullOrWhiteSpace(commandName))
{
throw new ArgumentNullException(nameof(commandName), "Cannot be null or whitespace");
}
EnsureNoInvalidFilenameCharacters(commandName, nameof(toolAssemblyEntryPoint));
if (string.IsNullOrWhiteSpace(toolAssemblyEntryPoint))
{
throw new ArgumentNullException(nameof(toolAssemblyEntryPoint), "Cannot be null or whitespace");
}
CommandName = commandName;
ToolAssemblyEntryPoint = toolAssemblyEntryPoint;
}
private void EnsureNoInvalidFilenameCharacters(string commandName, string nameOfParam)
{
char[] invalidCharactors = Path.GetInvalidFileNameChars();
if (commandName.IndexOfAny(invalidCharactors) != -1)
{
throw new ArgumentException(
paramName: nameof(nameOfParam),
message: "Contains one or more invalid characters: " + new string(invalidCharactors));
}
}
public string CommandName { get; }
public string ToolAssemblyEntryPoint { get; }
}
}