private CommandSpec CreatePackageCommandSpecUsingMuxer( string commandPath, IEnumerable <string> commandArguments, CommandResolutionStrategy commandResolutionStrategy) { var arguments = new List <string>(); var muxer = new Muxer(); var host = muxer.MuxerPath; if (host == null) { throw new Exception(LocalizableStrings.UnableToLocateDotnetMultiplexer); } arguments.Add(commandPath); if (commandArguments != null) { arguments.AddRange(commandArguments); } return(CreateCommandSpec(host, arguments, commandResolutionStrategy)); }
private CommandSpec CreatePackageCommandSpecUsingMuxer( string commandPath, IEnumerable <string> commandArguments, string depsFilePath, CommandResolutionStrategy commandResolutionStrategy, IEnumerable <string> packageFolders, string runtimeConfigPath) { var host = string.Empty; var arguments = new List <string>(); var muxer = new Muxer(); host = muxer.MuxerPath; if (host == null) { throw new Exception(LocalizableStrings.UnableToLocateDotnetMultiplexer); } arguments.Add("exec"); if (runtimeConfigPath != null) { arguments.Add("--runtimeconfig"); arguments.Add(runtimeConfigPath); } if (depsFilePath != null) { arguments.Add("--depsfile"); arguments.Add(depsFilePath); } foreach (var packageFolder in packageFolders) { arguments.Add("--additionalprobingpath"); arguments.Add(packageFolder); } if (_addAdditionalArguments != null) { _addAdditionalArguments(commandPath, arguments); } arguments.Add(commandPath); arguments.AddRange(commandArguments); return(CreateCommandSpec(host, arguments, commandResolutionStrategy)); }
private CommandSpec CreatePackageCommandSpecUsingCorehost( string commandPath, IEnumerable <string> commandArguments, string depsFilePath, CommandResolutionStrategy commandResolutionStrategy, string nugetPackagesRoot, bool isPortable, string runtimeConfigPath) { var host = string.Empty; var arguments = new List <string>(); if (isPortable) { var muxer = new Muxer(); host = muxer.MuxerPath; if (host == null) { throw new Exception("Unable to locate dotnet multiplexer"); } arguments.Add("exec"); } else { host = CoreHost.HostExePath; } if (runtimeConfigPath != null) { arguments.Add("--runtimeconfig"); arguments.Add(runtimeConfigPath); } if (depsFilePath != null) { arguments.Add("--depsfile"); arguments.Add(depsFilePath); } arguments.Add("--additionalprobingpath"); arguments.Add(nugetPackagesRoot); arguments.Add(commandPath); arguments.AddRange(commandArguments); return(CreateCommandSpec(host, arguments, commandResolutionStrategy)); }
private CommandSpec CreatePackageCommandSpecUsingMuxer( string commandPath, IEnumerable <string> commandArguments, string depsFilePath, CommandResolutionStrategy commandResolutionStrategy, string runtimeConfigPath) { var arguments = new List <string>(); var muxer = new Muxer(); var host = muxer.MuxerPath; if (host == null) { throw new Exception("Unable to locate dotnet multiplexer"); } arguments.Add("exec"); if (runtimeConfigPath != null) { arguments.Add("--runtimeconfig"); arguments.Add(runtimeConfigPath); } if (depsFilePath != null) { arguments.Add("--depsfile"); arguments.Add(depsFilePath); } arguments.Add(commandPath); arguments.AddRange(commandArguments); return(CreateCommandSpec(host, arguments, commandResolutionStrategy)); }
private static void AddAdditionalParameters(string commandPath, IList <string> arguments) { if (PrefersCliRuntime(commandPath)) { var runtimeConfigFile = Path.ChangeExtension(commandPath, FileNameSuffixes.RuntimeConfigJson); if (!File.Exists(runtimeConfigFile)) { throw new GracefulException(string.Format(LocalizableStrings.CouldNotFindToolRuntimeConfigFile, nameof(PackagedCommandSpecFactory), Path.GetFileName(commandPath))); } var runtimeConfig = new RuntimeConfig(runtimeConfigFile); var muxer = new Muxer(); Version currentFrameworkSimpleVersion = GetVersionWithoutPrerelease(muxer.SharedFxVersion); Version toolFrameworkSimpleVersion = GetVersionWithoutPrerelease(runtimeConfig.Framework.Version); if (currentFrameworkSimpleVersion.Major != toolFrameworkSimpleVersion.Major) { Reporter.Verbose.WriteLine( string.Format( LocalizableStrings.IgnoringPreferCLIRuntimeFile, nameof(PackagedCommandSpecFactory), runtimeConfig.Framework.Version, muxer.SharedFxVersion)); } else { arguments.Add("--fx-version"); arguments.Add(muxer.SharedFxVersion); } } }
private CommandSpec CreatePackageCommandSpecUsingMuxer( string commandPath, IEnumerable <string> commandArguments, string depsFilePath, string runtimeConfigPath) { var arguments = new List <string>(); var muxer = new Muxer(); var host = muxer.MuxerPath; if (host == null) { throw new Exception(LocalizableStrings.UnableToLocateDotnetMultiplexer); } arguments.Add("exec"); if (runtimeConfigPath != null) { arguments.Add("--runtimeconfig"); arguments.Add(runtimeConfigPath); } if (depsFilePath != null) { arguments.Add("--depsfile"); arguments.Add(depsFilePath); } arguments.Add(commandPath); arguments.AddRange(commandArguments); return(CreateCommandSpec(host, arguments)); }
public FrameworkDependencyFile() { _depsFilePath = Muxer.GetDataFromAppDomain("FX_DEPS_FILE"); }
public DepsJsonCommandResolver(Muxer muxer, string nugetPackageRoot) { _muxer = muxer; _nugetPackageRoot = nugetPackageRoot; }
private static Command RunFsc(List<string> fscArgs, string temp) { var fscEnvExe = Environment.GetEnvironmentVariable("DOTNET_FSC_PATH"); var exec = Environment.GetEnvironmentVariable("DOTNET_FSC_EXEC")?.ToUpper() ?? "COREHOST"; var muxer = new Muxer(); if (fscEnvExe != null) { switch (exec) { case "RUN": return Command.Create(fscEnvExe, fscArgs.ToArray()); case "COREHOST": default: var host = muxer.MuxerPath; return Command.Create(host, new[] { fscEnvExe }.Concat(fscArgs).ToArray()); } } else { var fscCommandSpec = ResolveFsc(fscArgs, temp)?.Spec; return Command.Create(fscCommandSpec); } }
private int RunExecutable() { CalculateDefaultsForNonAssigned(); // Compile to that directory var result = Build.BuildCommand.Run(new[] { $"--framework", $"{_context.TargetFramework}", $"--configuration", Configuration, $"{_context.ProjectFile.ProjectDirectory}" }); if (result != 0) { return result; } if (!_context.TargetFramework.IsDesktop()) { // Add Nuget Packages Probing Path var nugetPackagesRoot = _context.PackagesDirectory; var probingPathArg = "--additionalprobingpath"; _args.Insert(0, nugetPackagesRoot); _args.Insert(0, probingPathArg); } // Now launch the output and give it the results var outputPaths = _context.GetOutputPaths(Configuration); var outputName = outputPaths.RuntimeFiles.Executable; if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { if (_context.TargetFramework.IsDesktop()) { // Run mono if we're running a desktop target on non windows _args.Insert(0, outputName); if (string.Equals(Configuration, "Debug", StringComparison.OrdinalIgnoreCase)) { // If we're compiling for the debug configuration then add the --debug flag // other options may be passed using the MONO_OPTIONS env var _args.Insert(0, "--debug"); } outputName = "mono"; } } Command command; if (outputName.EndsWith(FileNameSuffixes.DotNet.DynamicLib, StringComparison.OrdinalIgnoreCase)) { // The executable is a ".dll", we need to call it through dotnet.exe var muxer = new Muxer(); command = Command.Create(muxer.MuxerPath, Enumerable.Concat(new[] { "exec", outputName }, _args)); } else { command = Command.Create(outputName, _args); } result = command .ForwardStdOut() .ForwardStdErr() .Execute() .ExitCode; return result; }
public FrameworkDependencyFile() { _depsFilePath = Muxer.GetDataFromAppDomain("FX_DEPS_FILE"); _dependencyContext = new Lazy <DependencyContext>(CreateDependencyContext); }
protected void TestExecutable(string outputDir, string executableName, string expectedOutput) { var executablePath = Path.Combine(outputDir, executableName); var args = new List<string>(); if (IsPortable(executablePath)) { args.Add("exec"); args.Add(ArgumentEscaper.EscapeSingleArg(executablePath)); var muxer = new Muxer(); executablePath = muxer.MuxerPath; } var executableCommand = new TestCommand(executablePath); var result = executableCommand.ExecuteWithCapturedOutput(string.Join(" ", args)); result.Should().HaveStdOut(expectedOutput); result.Should().NotHaveStdErr(); result.Should().Pass(); }
private CommandSpec CreatePackageCommandSpecUsingCorehost( string commandPath, IEnumerable<string> commandArguments, string depsFilePath, CommandResolutionStrategy commandResolutionStrategy, string nugetPackagesRoot, bool isPortable) { var host = string.Empty; var arguments = new List<string>(); if (isPortable) { var muxer = new Muxer(); host = muxer.MuxerPath; if (host == null) { throw new Exception("Unable to locate dotnet multiplexer"); } arguments.Add("exec"); } else { host = CoreHost.HostExePath; } arguments.Add(commandPath); if (depsFilePath != null) { arguments.Add("--depsfile"); arguments.Add(depsFilePath); } arguments.Add("--additionalprobingpath"); arguments.Add(nugetPackagesRoot); arguments.AddRange(commandArguments); return CreateCommandSpec(host, arguments, commandResolutionStrategy); }