コード例 #1
0
        public Assembly GetEntryPoint(string applicationName)
        {
            var sw = Stopwatch.StartNew();

            if (Project == null)
            {
                return(null);
            }

            if (!_applicationHostContext.MainProject.Resolved)
            {
                var    targetFrameworkShortName = VersionUtility.GetShortFrameworkName(_targetFramework);
                var    runtimeFrameworkInfo     = $@"Current runtime target framework: '{_targetFramework} ({targetFrameworkShortName})'
{_runtimeEnvironment.GetFullVersion()}";
                string exceptionMsg;

                // If the main project cannot be resolved, it means the app doesn't support current target framework
                // (i.e. project.json doesn't contain a framework that is compatible with target framework of current runtime)

                exceptionMsg = $@"The current runtime target framework is not compatible with '{Project.Name}'.
{runtimeFrameworkInfo}
Please make sure the runtime matches a framework specified in {Project.ProjectFileName}";
                throw new InvalidOperationException(exceptionMsg);
            }

            return(_loadContextAccessor.Default.Load(applicationName));
        }
コード例 #2
0
ファイル: DefaultHost.cs プロジェクト: cemoses/aspnet
        public Assembly GetEntryPoint(string applicationName)
        {
            var sw = Stopwatch.StartNew();

            if (Project == null)
            {
                return(null);
            }

            AddBreadcrumbs();

            var unresolvedLibs = _libraryManager.GetLibraryDescriptions().Where(l => !l.Resolved);

            // If there's any unresolved dependencies then complain
            if (unresolvedLibs.Any())
            {
                var    targetFrameworkShortName = VersionUtility.GetShortFrameworkName(_targetFramework);
                var    runtimeFrameworkInfo     = $@"Current runtime target framework: '{_targetFramework} ({targetFrameworkShortName})'
{_runtimeEnvironment.GetFullVersion()}";
                string exceptionMsg;

                // If the main project cannot be resolved, it means the app doesn't support current target framework
                // (i.e. project.json doesn't contain a framework that is compatible with target framework of current runtime)
                if (unresolvedLibs.Any(l => string.Equals(l.Identity.Name, Project.Name)))
                {
                    exceptionMsg = $@"The current runtime target framework is not compatible with '{Project.Name}'.

{runtimeFrameworkInfo}
Please make sure the runtime matches a framework specified in {Project.ProjectFileName}";
                }
                else
                {
                    var globalDiagnosticsErrorMessage = string.Join(string.Empty,
                                                                    _libraryManager.GetGlobalDiagnostics().Select(x => $"{Environment.NewLine}{x.FormattedMessage}"));
                    exceptionMsg = $@"{_libraryManager.GetMissingDependenciesWarning(_targetFramework)}{globalDiagnosticsErrorMessage}
{runtimeFrameworkInfo}";
                }

                throw new InvalidOperationException(exceptionMsg);
            }

            return(_loadContextAccessor.Default.Load(applicationName));
        }
コード例 #3
0
        public int Main(string[] args)
        {
#if DEBUG
            // Add our own debug helper because DNU is usually run from a wrapper script,
            // making it too late to use the DNX one. Technically it's possible to use
            // the DNX_OPTIONS environment variable, but that's difficult to do per-command
            // on Windows
            if (args.Any(a => string.Equals(a, "--debug", StringComparison.OrdinalIgnoreCase)))
            {
                args = args.Where(a => !string.Equals(a, "--debug", StringComparison.OrdinalIgnoreCase)).ToArray();
                Console.WriteLine($"Process Id: {Process.GetCurrentProcess().Id}");
                Console.WriteLine("Waiting for Debugger to attach...");
                SpinWait.SpinUntil(() => Debugger.IsAttached);
            }
#endif
            var app = new CommandLineApplication();
            app.Name     = "dnu";
            app.FullName = "Microsoft .NET Development Utility";

            var optionVerbose = app.Option("-v|--verbose", "Show verbose output", CommandOptionType.NoValue);
            app.HelpOption("-?|-h|--help");
            app.VersionOption("--version", () => _runtimeEnv.GetShortVersion(), () => _runtimeEnv.GetFullVersion());

            // Show help information if no subcommand/option was specified
            app.OnExecute(() =>
            {
                app.ShowHelp();
                return(2);
            });

            var reportsFactory = new ReportsFactory(_runtimeEnv, optionVerbose.HasValue());

            BuildConsoleCommand.Register(app, reportsFactory, _hostServices);
            CommandsConsoleCommand.Register(app, reportsFactory, _environment);
            InstallConsoleCommand.Register(app, reportsFactory, _environment);
            ListConsoleCommand.Register(app, reportsFactory, _environment);
            PackConsoleCommand.Register(app, reportsFactory, _hostServices);
            PackagesConsoleCommand.Register(app, reportsFactory);
            PublishConsoleCommand.Register(app, reportsFactory, _environment, _hostServices);
            RestoreConsoleCommand.Register(app, reportsFactory, _environment);
            SourcesConsoleCommand.Register(app, reportsFactory);
            WrapConsoleCommand.Register(app, reportsFactory);
            FeedsConsoleCommand.Register(app, reportsFactory);

            return(app.Execute(args));
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: YoloDev/srclib-csharp
        public int Main(string[] args)
        {
            var app = new CommandLineApplication(throwOnUnexpectedArg: true);

            app.Name     = "srclib-csharp";
            app.FullName = "Scrlib C# toolchain";

            app.HelpOption("-?|-h|--help");
            app.VersionOption("--version", () => _runtimeEnv.GetShortVersion(), () => _runtimeEnv.GetFullVersion());

            // Show help information if no subcommand/option was specified
            app.OnExecute(() =>
            {
                app.ShowHelp();
                return(2);
            });

            ScanConsoleCommand.Register(app, _env);
            GraphConsoleCommand.Register(app, _env, _loadContextAccessor, _runtimeEnv);
            DepresolveConsoleCommand.Register(app, _env, _runtimeEnv);

            return(app.Execute(args));
        }