当前位置: 首页>>代码示例>>C#>>正文


C# IRuntimeEnvironment.GetDefaultRestoreRuntimes方法代码示例

本文整理汇总了C#中IRuntimeEnvironment.GetDefaultRestoreRuntimes方法的典型用法代码示例。如果您正苦于以下问题:C# IRuntimeEnvironment.GetDefaultRestoreRuntimes方法的具体用法?C# IRuntimeEnvironment.GetDefaultRestoreRuntimes怎么用?C# IRuntimeEnvironment.GetDefaultRestoreRuntimes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IRuntimeEnvironment的用法示例。


在下文中一共展示了IRuntimeEnvironment.GetDefaultRestoreRuntimes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Register

        public static void Register(CommandLineApplication cmdApp, ReportsFactory reportsFactory, IApplicationEnvironment applicationEnvironment, IRuntimeEnvironment runtimeEnvironment)
        {
            cmdApp.Command("restore", c =>
            {
                c.Description = "Restore packages";

                var argRoot = c.Argument("[root]",
                    "List of projects and project folders to restore. Each value can be: a path to a project.json or global.json file, or a folder to recursively search for project.json files.",
                    multipleValues: true);
                var feedCommandLineOptions = FeedCommandLineOptions.Add(c);
                var optLock = c.Option("--lock",
                    "Creates dependencies file with locked property set to true. Overwrites file if it exists.",
                    CommandOptionType.NoValue);
                var optUnlock = c.Option("--unlock",
                    "Creates dependencies file with locked property set to false. Overwrites file if it exists.",
                    CommandOptionType.NoValue);
                var optRuntimes = c.Option("--runtime <RID>",
                    "List of runtime identifiers to restore for",
                    CommandOptionType.MultipleValue);

                c.HelpOption("-?|-h|--help");

                c.OnExecute(async () =>
                {
                    c.ShowRootCommandFullNameAndVersion();

                    var feedOptions = feedCommandLineOptions.GetOptions();
                    var command = new RestoreCommand(applicationEnvironment);
                    command.Reports = reportsFactory.CreateReports(feedOptions.Quiet);
                    command.RestoreDirectories.AddRange(argRoot.Values);
                    command.FeedOptions = feedOptions;
                    command.Lock = optLock.HasValue();
                    command.Unlock = optUnlock.HasValue();
                    command.RequestedRuntimes = optRuntimes.Values;
                    command.FallbackRuntimes = runtimeEnvironment.GetDefaultRestoreRuntimes();

                    if (!string.IsNullOrEmpty(feedOptions.Proxy))
                    {
                        Environment.SetEnvironmentVariable("http_proxy", feedOptions.Proxy);
                    }

                    var success = await command.Execute();

                    return success ? 0 : 1;
                });
            });
        }
开发者ID:leloulight,项目名称:dnx,代码行数:47,代码来源:RestoreConsoleCommand.cs


注:本文中的IRuntimeEnvironment.GetDefaultRestoreRuntimes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。