Merge branch 'release/2.1.3xx' into master

* release/2.1.3xx:
  Updating the WebSdk DependencyVersion to support local build
  Fix non-fatal null exception when no extra parameters are passed.
  Separate tool package and shim file location
  Updating the CLI branding and version to 2.1.300.

* Conflicts
  src/dotnet/commands/dotnet-install/dotnet-install-tool/InstallToolCommand.cs
  run-build.ps1
  build/Version.props
This commit is contained in:
Peter Huene 2018-01-30 16:15:05 -08:00
commit d8d600d44e
No known key found for this signature in database
GPG key ID: E1D265D820213D6A
7 changed files with 56 additions and 12 deletions

View file

@ -16,7 +16,7 @@
<MicrosoftNetCompilersNetcorePackageVersion>$(MicrosoftCodeAnalysisCSharpPackageVersion)</MicrosoftNetCompilersNetcorePackageVersion>
<MicrosoftNETSdkPackageVersion>2.1.0-preview1-62516-03</MicrosoftNETSdkPackageVersion>
<MicrosoftNETBuildExtensionsPackageVersion>$(MicrosoftNETSdkPackageVersion)</MicrosoftNETBuildExtensionsPackageVersion>
<MicrosoftNETSdkWebPackageVersion>2.0.0-rel-20171110-671</MicrosoftNETSdkWebPackageVersion>
<MicrosoftNETSdkWebPackageVersion>2.1.0-release21-20180126-1326543</MicrosoftNETSdkWebPackageVersion>
<MicrosoftNETSdkPublishPackageVersion>$(MicrosoftNETSdkWebPackageVersion)</MicrosoftNETSdkPublishPackageVersion>
<MicrosoftNETSdkWebProjectSystemPackageVersion>$(MicrosoftNETSdkWebPackageVersion)</MicrosoftNETSdkWebProjectSystemPackageVersion>
<MicrosoftDotNetCommonItemTemplatesPackageVersion>1.0.1-beta3-20180104-1263555</MicrosoftDotNetCommonItemTemplatesPackageVersion>

View file

@ -12,20 +12,23 @@ namespace Microsoft.DotNet.Configurer
{
public class CliFolderPathCalculator
{
private const string ToolsFolderName = "tools";
// ToolsShimFolderName ToolPackageFolderName cannot be the same
// or if the PackageId is the same as CommandName, they will conflict on unix.
private const string ToolsShimFolderName = "tools";
private const string ToolPackageFolderName = "toolspkgs";
private const string DotnetProfileDirectoryName = ".dotnet";
public string CliFallbackFolderPath => Environment.GetEnvironmentVariable("DOTNET_CLI_TEST_FALLBACKFOLDER") ??
Path.Combine(new DirectoryInfo(AppContext.BaseDirectory).Parent.FullName, "NuGetFallbackFolder");
public string ExecutablePackagesPath => Path.Combine(DotnetUserProfileFolderPath, ToolsFolderName);
public BashPathUnderHomeDirectory ExecutablePackagesPathInUnix
public string ToolsShimPath => Path.Combine(DotnetUserProfileFolderPath, ToolsShimFolderName);
public string ToolsPackagePath => Path.Combine(DotnetUserProfileFolderPath, ToolPackageFolderName);
public BashPathUnderHomeDirectory ToolsShimPathInUnix
{
get
{
return new BashPathUnderHomeDirectory(Environment.GetEnvironmentVariable("HOME"),
Path.Combine(DotnetProfileDirectoryName, ToolsFolderName));
Path.Combine(DotnetProfileDirectoryName, ToolsShimFolderName));
}
}

View file

@ -32,20 +32,20 @@ namespace Microsoft.DotNet.ShellShim
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
environmentPath = new WindowsEnvironmentPath(
cliFolderPathCalculator.ExecutablePackagesPath,
cliFolderPathCalculator.ToolsShimPath,
Reporter.Output);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && hasSuperUserAccess)
{
environmentPath = new LinuxEnvironmentPath(
cliFolderPathCalculator.ExecutablePackagesPathInUnix,
cliFolderPathCalculator.ToolsShimPathInUnix,
Reporter.Output,
environmentProvider, new FileWrapper());
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && hasSuperUserAccess)
{
environmentPath = new OSXEnvironmentPath(
executablePath: cliFolderPathCalculator.ExecutablePackagesPathInUnix,
executablePath: cliFolderPathCalculator.ToolsShimPathInUnix,
reporter: Reporter.Output,
environmentProvider: environmentProvider,
fileSystem: new FileWrapper());

View file

@ -30,6 +30,11 @@ namespace Microsoft.DotNet.ShellShim
{
FilePath shimPath = GetShimPath(shellCommandName);
if (!Directory.Exists(shimPath.GetDirectoryPath().Value))
{
Directory.CreateDirectory(shimPath.GetDirectoryPath().Value);
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
CreateConfigFile(shimPath.Value + ".config", entryPoint: packageExecutable, runner: "dotnet");

View file

@ -50,10 +50,9 @@ namespace Microsoft.DotNet.Tools.Install.Tool
_global = appliedCommand.ValueOrDefault<bool>("global");
var cliFolderPathCalculator = new CliFolderPathCalculator();
var executablePackagePath = new DirectoryPath(cliFolderPathCalculator.ExecutablePackagesPath);
var offlineFeedPath = new DirectoryPath(cliFolderPathCalculator.CliFallbackFolderPath);
_toolPackageObtainer = toolPackageObtainer ?? new ToolPackageObtainer(
executablePackagePath,
new DirectoryPath(cliFolderPathCalculator.ToolsPackagePath),
offlineFeedPath,
() => new DirectoryPath(Path.GetTempPath())
.WithSubDirectories(Path.GetRandomFileName())
@ -65,7 +64,7 @@ namespace Microsoft.DotNet.Tools.Install.Tool
?? EnvironmentPathFactory
.CreateEnvironmentPathInstruction();
_shellShimMaker = shellShimMaker ?? new ShellShimMaker(executablePackagePath.Value);
_shellShimMaker = shellShimMaker ?? new ShellShimMaker(cliFolderPathCalculator.ToolsShimPath);
_reporter = reporter ?? Reporter.Output;
}

View file

@ -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 System;
using System.Collections.Generic;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools.Test.Utilities;
using FluentAssertions;
namespace Microsoft.DotNet.Configurer.UnitTests
{
public class GivenAPathCalculator
{
[NonWindowsOnlyFact]
public void It_does_not_return_same_path_for_tools_package_and_tool_shim()
{
// shim name will conflict with the folder that is PackageId, if commandName and packageId are the same.
var cliFolderPathCalculator = new CliFolderPathCalculator();
cliFolderPathCalculator.ToolsPackagePath.Should().NotBe(cliFolderPathCalculator.ToolsShimPath);
cliFolderPathCalculator.ToolsPackagePath.Should().NotBe(cliFolderPathCalculator.ToolsShimPathInUnix.Path);
}
}
}

View file

@ -72,6 +72,20 @@ namespace Microsoft.DotNet.ShellShim.Tests
stdOut.Should().Contain("Hello World");
}
[Fact]
public void GivenAnExecutablePathDirectoryThatDoesNotExistItCanGenerateShimFile()
{
var outputDll = MakeHelloWorldExecutableDll();
var extraNonExistDirectory = Path.GetRandomFileName();
var shellShimMaker = new ShellShimMaker(Path.Combine(TempRoot.Root, extraNonExistDirectory));
var shellCommandName = nameof(ShellShimMakerTests) + Path.GetRandomFileName();
Action a = () => shellShimMaker.CreateShim(
new FilePath(outputDll.FullName),
shellCommandName);
a.ShouldNotThrow<DirectoryNotFoundException>();
}
[Theory]
[InlineData("arg1 arg2", new[] { "arg1", "arg2" })]
[InlineData(" \"arg1 with space\" arg2", new[] { "arg1 with space", "arg2" })]