Tools shim maker and env path handling (#8085)
* Tools shim maker and env path handling Includes component: * Given executable, create shim (all three OSs) * Add executable path to Env PATH during first run * including manual instruction when there is no access
This commit is contained in:
parent
c17ffbf7e8
commit
cc80ed43e0
35 changed files with 1149 additions and 79 deletions
|
@ -4,15 +4,19 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using Microsoft.DotNet.Cli.CommandLine;
|
||||
using Microsoft.DotNet.Cli.Telemetry;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.Configurer;
|
||||
using Microsoft.DotNet.PlatformAbstractions;
|
||||
using Microsoft.DotNet.ShellShimMaker;
|
||||
using Microsoft.DotNet.Tools.Help;
|
||||
using Microsoft.Extensions.EnvironmentAbstractions;
|
||||
using NuGet.Frameworks;
|
||||
using Command = Microsoft.DotNet.Cli.Utils.Command;
|
||||
using RuntimeEnvironment = Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment;
|
||||
|
||||
namespace Microsoft.DotNet.Cli
|
||||
{
|
||||
|
@ -80,8 +84,9 @@ namespace Microsoft.DotNet.Cli
|
|||
var success = true;
|
||||
var command = string.Empty;
|
||||
var lastArg = 0;
|
||||
var cliFallbackFolderPathCalculator = new CliFallbackFolderPathCalculator();
|
||||
var cliFallbackFolderPathCalculator = new CliFolderPathCalculator();
|
||||
TopLevelCommandParserResult topLevelCommandParserResult = TopLevelCommandParserResult.Empty;
|
||||
|
||||
using (INuGetCacheSentinel nugetCacheSentinel = new NuGetCacheSentinel(cliFallbackFolderPathCalculator))
|
||||
using (IFirstTimeUseNoticeSentinel disposableFirstTimeUseNoticeSentinel =
|
||||
new FirstTimeUseNoticeSentinel(cliFallbackFolderPathCalculator))
|
||||
|
@ -120,22 +125,24 @@ namespace Microsoft.DotNet.Cli
|
|||
{
|
||||
// It's the command, and we're done!
|
||||
command = args[lastArg];
|
||||
|
||||
if (string.IsNullOrEmpty(command))
|
||||
{
|
||||
command = "help";
|
||||
}
|
||||
|
||||
topLevelCommandParserResult = new TopLevelCommandParserResult(args[lastArg]);
|
||||
topLevelCommandParserResult = new TopLevelCommandParserResult(command);
|
||||
var hasSuperUserAccess = false;
|
||||
if (IsDotnetBeingInvokedFromNativeInstaller(topLevelCommandParserResult))
|
||||
{
|
||||
firstTimeUseNoticeSentinel = new NoOpFirstTimeUseNoticeSentinel();
|
||||
hasSuperUserAccess = true;
|
||||
}
|
||||
|
||||
ConfigureDotNetForFirstTimeUse(
|
||||
nugetCacheSentinel,
|
||||
firstTimeUseNoticeSentinel,
|
||||
cliFallbackFolderPathCalculator);
|
||||
cliFallbackFolderPathCalculator,
|
||||
hasSuperUserAccess);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -197,24 +204,29 @@ namespace Microsoft.DotNet.Cli
|
|||
private static void ConfigureDotNetForFirstTimeUse(
|
||||
INuGetCacheSentinel nugetCacheSentinel,
|
||||
IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel,
|
||||
CliFallbackFolderPathCalculator cliFallbackFolderPathCalculator)
|
||||
CliFolderPathCalculator cliFolderPathCalculator,
|
||||
bool hasSuperUserAccess)
|
||||
{
|
||||
var environmentProvider = new EnvironmentProvider();
|
||||
|
||||
using (PerfTrace.Current.CaptureTiming())
|
||||
{
|
||||
var nugetPackagesArchiver = new NuGetPackagesArchiver();
|
||||
var environmentProvider = new EnvironmentProvider();
|
||||
var environmentPath =
|
||||
EnvironmentPathFactory.CreateEnvironmentPath(cliFolderPathCalculator, hasSuperUserAccess, environmentProvider);
|
||||
var commandFactory = new DotNetCommandFactory(alwaysRunOutOfProc: true);
|
||||
var nugetCachePrimer = new NuGetCachePrimer(
|
||||
nugetPackagesArchiver,
|
||||
nugetCacheSentinel,
|
||||
cliFallbackFolderPathCalculator);
|
||||
cliFolderPathCalculator);
|
||||
var dotnetConfigurer = new DotnetFirstTimeUseConfigurer(
|
||||
nugetCachePrimer,
|
||||
nugetCacheSentinel,
|
||||
firstTimeUseNoticeSentinel,
|
||||
environmentProvider,
|
||||
Reporter.Output,
|
||||
cliFallbackFolderPathCalculator.CliFallbackFolderPath);
|
||||
cliFolderPathCalculator.CliFallbackFolderPath,
|
||||
environmentPath);
|
||||
|
||||
dotnetConfigurer.Configure();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue