コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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);
                }
            }
        }
コード例 #6
0
        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));
        }
コード例 #7
0
 public FrameworkDependencyFile()
 {
     _depsFilePath = Muxer.GetDataFromAppDomain("FX_DEPS_FILE");
 }
コード例 #8
0
 public DepsJsonCommandResolver(Muxer muxer, string nugetPackageRoot)
 {
     _muxer            = muxer;
     _nugetPackageRoot = nugetPackageRoot;
 }
コード例 #9
0
ファイル: Program.cs プロジェクト: krytarowski/cli
        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);
            }
        }
コード例 #10
0
ファイル: RunCommand.cs プロジェクト: krytarowski/cli
        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;
        }
コード例 #11
0
ファイル: FrameworkDependencyFile.cs プロジェクト: 3F/IeXod
 public FrameworkDependencyFile()
 {
     _depsFilePath      = Muxer.GetDataFromAppDomain("FX_DEPS_FILE");
     _dependencyContext = new Lazy <DependencyContext>(CreateDependencyContext);
 }
コード例 #12
0
ファイル: TestBase.cs プロジェクト: krytarowski/cli
        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();
        }
コード例 #13
0
        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);
        }
コード例 #14
0
 public DepsJsonCommandResolver(Muxer muxer, string nugetPackageRoot)
 {
     _muxer = muxer;
     _nugetPackageRoot = nugetPackageRoot;
 }