7ebfdde749
This commit adds the `--verbosity` option to the `install tool` command. MSBuild/NuGet output is now controllable by the user and defaults to being "quiet". This enables users to see warnings from NuGet that otherwise would be swallowed unless NuGet returned a non-zero exit code. As a byproduct of this change, the exception handling and error messages related to obtaining tool packages was retooled. We no longer display `install tool` command line help for installation failures, as it should only be displayed for command line syntax errors. Fixes #8465.
82 lines
3 KiB
C#
82 lines
3 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.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Runtime.InteropServices;
|
|
using FluentAssertions;
|
|
using Microsoft.DotNet.Configurer;
|
|
using Microsoft.DotNet.Tools;
|
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
|
using Microsoft.Extensions.DependencyModel.Tests;
|
|
using Xunit;
|
|
|
|
namespace Microsoft.DotNet.ShellShim.Tests
|
|
{
|
|
public class LinuxEnvironmentPathTests
|
|
{
|
|
[Fact]
|
|
public void GivenEnvironmentAndReporterItCanPrintOutInstructionToAddPath()
|
|
{
|
|
var reporter = new BufferedReporter();
|
|
var linuxEnvironmentPath = new LinuxEnvironmentPath(
|
|
new BashPathUnderHomeDirectory("/myhome", "executable/path"),
|
|
reporter,
|
|
new FakeEnvironmentProvider(
|
|
new Dictionary<string, string>
|
|
{
|
|
{"PATH", ""}
|
|
}),
|
|
FakeFile.Empty);
|
|
|
|
linuxEnvironmentPath.PrintAddPathInstructionIfPathDoesNotExist();
|
|
|
|
// similar to https://code.visualstudio.com/docs/setup/mac
|
|
reporter.Lines.Should().Equal(
|
|
string.Format(
|
|
CommonLocalizableStrings.EnvironmentPathLinuxManualInstruction,
|
|
"/myhome/executable/path", "/myhome/executable/path"));
|
|
}
|
|
|
|
[Fact]
|
|
public void GivenEnvironmentAndReporterItPrintsNothingWhenenvironmentExists()
|
|
{
|
|
var reporter = new BufferedReporter();
|
|
var linuxEnvironmentPath = new LinuxEnvironmentPath(
|
|
new BashPathUnderHomeDirectory("/myhome", "executable/path"),
|
|
reporter,
|
|
new FakeEnvironmentProvider(
|
|
new Dictionary<string, string>
|
|
{
|
|
{"PATH", @"/myhome/executable/path"}
|
|
}),
|
|
FakeFile.Empty);
|
|
|
|
linuxEnvironmentPath.PrintAddPathInstructionIfPathDoesNotExist();
|
|
|
|
reporter.Lines.Should().BeEmpty();
|
|
}
|
|
|
|
[Fact]
|
|
public void GivenAddPackageExecutablePathToUserPathJustRunItPrintsInstructionToLogout()
|
|
{
|
|
var reporter = new BufferedReporter();
|
|
var linuxEnvironmentPath = new LinuxEnvironmentPath(
|
|
new BashPathUnderHomeDirectory("/myhome", "executable/path"),
|
|
reporter,
|
|
new FakeEnvironmentProvider(
|
|
new Dictionary<string, string>
|
|
{
|
|
{"PATH", @""}
|
|
}),
|
|
FakeFile.Empty);
|
|
linuxEnvironmentPath.AddPackageExecutablePathToUserPath();
|
|
|
|
linuxEnvironmentPath.PrintAddPathInstructionIfPathDoesNotExist();
|
|
|
|
reporter.Lines.Should()
|
|
.Equal(CommonLocalizableStrings.EnvironmentPathLinuxNeedLogout);
|
|
}
|
|
}
|
|
}
|