Exemple #1
0
        internal async Task RestorePackagesAsync(bool reloadScriptOnSuccess = true)
        {
            LogOnPrimaryHost("Restoring packages.", LogLevel.Information);

            try
            {
                PackageRestoreResult result = await _metadataResolver.RestorePackagesAsync();

                LogOnPrimaryHost("Packages restored.", LogLevel.Information);

                if (reloadScriptOnSuccess)
                {
                    if (!result.IsInitialInstall && result.ReferencesChanged)
                    {
                        LogOnPrimaryHost("Package references have changed.", LogLevel.Information);

                        // If this is not the initial package install and references changed,
                        // shutdown the host, which will cause it to have a clean start and load the new
                        // assembly references
                        _onReferencesChanged();
                    }
                    else
                    {
                        await _reloadScript();
                    }
                }
            }
            catch (Exception exc)
            {
                LogOnPrimaryHost("Package restore failed:", LogLevel.Error);
                LogOnPrimaryHost(exc.ToFormattedString(), LogLevel.Error);
            }
        }
        private void RestorePackages()
        {
            TraceWriter.Info("Restoring packages.");

            _metadataResolver.RestorePackagesAsync()
            .ContinueWith(t =>
            {
                if (t.IsFaulted)
                {
                    TraceWriter.Info("Package restore failed:");
                    TraceWriter.Info(t.Exception.ToString());
                    return;
                }

                TraceWriter.Info("Packages restored.");
                _reloadScript();
            });
        }
        private async Task RestorePackagesAsync(bool reloadScriptOnSuccess = true)
        {
            TraceOnPrimaryHost("Restoring packages.", TraceLevel.Info);

            try
            {
                await _metadataResolver.RestorePackagesAsync();

                TraceOnPrimaryHost("Packages restored.", TraceLevel.Info);

                if (reloadScriptOnSuccess)
                {
                    _reloadScript();
                }
            }
            catch (Exception exc)
            {
                TraceOnPrimaryHost("Package restore failed:", TraceLevel.Error);
                TraceOnPrimaryHost(exc.ToString(), TraceLevel.Error);
            }
        }