@@ -26,7 +26,6 @@ internal class ToolRunCommand(
26
26
private readonly ToolManifestFinder _toolManifest = toolManifest ?? new ToolManifestFinder ( new DirectoryPath ( Directory . GetCurrentDirectory ( ) ) ) ;
27
27
private readonly bool _fromSource = result . GetValue ( ToolRunCommandParser . FromSourceOption ) ;
28
28
29
- private readonly ToolInstallLocalInstaller _toolInstaller = new ( result ) ;
30
29
private readonly IToolManifestEditor _toolManifestEditor = new ToolManifestEditor ( ) ;
31
30
private readonly ILocalToolsResolverCache _localToolsResolverCache = new LocalToolsResolverCache ( ) ;
32
31
public override int Execute ( )
@@ -41,7 +40,7 @@ public override int Execute()
41
40
42
41
if ( commandspec == null && _fromSource )
43
42
{
44
- commandspec = GetRemoteCommandSpec ( ) ;
43
+ return ExecuteFromSource ( ) ;
45
44
}
46
45
47
46
if ( commandspec == null )
@@ -53,11 +52,15 @@ public override int Execute()
53
52
return result . ExitCode ;
54
53
}
55
54
56
- public CommandSpec GetRemoteCommandSpec ( )
55
+ public int ExecuteFromSource ( )
57
56
{
57
+ string tempDirectory = PathUtilities . CreateTempSubdirectory ( ) ;
58
58
FilePath manifestFile = _toolManifest . FindFirst ( true ) ;
59
59
PackageId packageId = new ( _toolCommandName ) ;
60
60
61
+ ToolInstallLocalInstaller _toolInstaller = new ( _parseResult , new ToolPackageDownloader (
62
+ store : new ToolPackageStoreAndQuery ( new DirectoryPath ( tempDirectory ) ) ) ) ;
63
+
61
64
IToolPackage toolPackage = _toolInstaller . Install ( manifestFile , packageId ) ;
62
65
63
66
_toolManifestEditor . Add (
@@ -71,10 +74,21 @@ public CommandSpec GetRemoteCommandSpec()
71
74
toolPackage ,
72
75
_toolInstaller . TargetFrameworkToInstall ) ;
73
76
74
- return _localToolsCommandResolver . ResolveStrict ( new CommandResolverArguments ( )
77
+ CommandSpec commandSpec = _localToolsCommandResolver . ResolveStrict ( new CommandResolverArguments ( )
75
78
{
76
79
CommandName = $ "dotnet-{ toolPackage . Command . Name } ",
77
80
CommandArguments = _forwardArgument ,
78
81
} , _allowRollForward ) ;
82
+
83
+ if ( commandSpec == null )
84
+ {
85
+ throw new GracefulException ( [ string . Format ( CliCommandStrings . CannotFindCommandName , _toolCommandName ) ] , isUserError : false ) ;
86
+ }
87
+
88
+ var result = CommandFactoryUsingResolver . Create ( commandSpec ) . Execute ( ) ;
89
+
90
+ _toolManifestEditor . Remove ( manifestFile , toolPackage . Id ) ;
91
+
92
+ return result . ExitCode ;
79
93
}
80
94
}
0 commit comments