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
This commit is contained in:
parent
ea74bf1614
commit
55f62d9d64
55 changed files with 587 additions and 204 deletions
|
@ -0,0 +1,56 @@
|
|||
// 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;
|
||||
using Microsoft.DotNet.ToolPackage;
|
||||
using Microsoft.DotNet.PlatformAbstractions;
|
||||
using Microsoft.Extensions.EnvironmentAbstractions;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Install.Tool
|
||||
{
|
||||
internal class ProjectRestorer : IProjectRestorer
|
||||
{
|
||||
public void Restore(
|
||||
FilePath projectPath,
|
||||
DirectoryPath assetJsonOutput,
|
||||
FilePath? nugetconfig)
|
||||
{
|
||||
var argsToPassToRestore = new List<string>();
|
||||
|
||||
argsToPassToRestore.Add(projectPath.Value);
|
||||
if (nugetconfig != null)
|
||||
{
|
||||
argsToPassToRestore.Add("--configfile");
|
||||
argsToPassToRestore.Add(nugetconfig.Value.Value);
|
||||
}
|
||||
|
||||
argsToPassToRestore.AddRange(new List<string>
|
||||
{
|
||||
"--runtime",
|
||||
RuntimeEnvironment.GetRuntimeIdentifier(),
|
||||
$"/p:BaseIntermediateOutputPath={assetJsonOutput.ToQuotedString()}"
|
||||
});
|
||||
|
||||
var command = new DotNetCommandFactory(alwaysRunOutOfProc: true)
|
||||
.Create(
|
||||
"restore",
|
||||
argsToPassToRestore)
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr();
|
||||
|
||||
var result = command.Execute();
|
||||
if (result.ExitCode != 0)
|
||||
{
|
||||
throw new PackageObtainException("Failed to restore package. " +
|
||||
$"{Environment.NewLine}WorkingDirectory: " +
|
||||
result.StartInfo.WorkingDirectory +
|
||||
$"{Environment.NewLine}Arguments: " +
|
||||
result.StartInfo.Arguments +
|
||||
$"{Environment.NewLine}Output: " +
|
||||
result.StdErr + result.StdOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue