Example #1
0
        internal NuGetUpgrader(
            string currentVersion,
            ITracer tracer,
            bool dryRun,
            bool noVerify,
            PhysicalFileSystem fileSystem,
            NuGetUpgraderConfig config,
            NuGetFeed nuGetFeed,
            ICredentialStore credentialStore)
            : base(
                currentVersion,
                tracer,
                dryRun,
                noVerify,
                fileSystem)
        {
            this.nuGetUpgraderConfig = config;

            this.nuGetFeed       = nuGetFeed;
            this.credentialStore = credentialStore;

            // Extract the folder inside ProductUpgraderInfo.GetAssetDownloadsPath to ensure the
            // correct ACLs are in place
            this.ExtractedInstallerPath = Path.Combine(
                ProductUpgraderInfo.GetAssetDownloadsPath(),
                ExtractedInstallerDirectoryName);
        }
Example #2
0
 public NuGetUpgrader(
     string currentVersion,
     ITracer tracer,
     PhysicalFileSystem fileSystem,
     bool dryRun,
     bool noVerify,
     NuGetUpgraderConfig config,
     string downloadFolder,
     ICredentialStore credentialStore)
     : this(
         currentVersion,
         tracer,
         dryRun,
         noVerify,
         fileSystem,
         config,
         new NuGetFeed(
             config.FeedUrl,
             config.PackageFeedName,
             downloadFolder,
             null,
             tracer),
         credentialStore)
 {
 }
Example #3
0
 public NuGetUpgrader(
     string currentVersion,
     ITracer tracer,
     PhysicalFileSystem fileSystem,
     bool dryRun,
     bool noVerify,
     NuGetUpgraderConfig config,
     string downloadFolder,
     ICredentialStore credentialStore)
     : this(
         currentVersion,
         tracer,
         dryRun,
         noVerify,
         fileSystem,
         config,
         new NuGetFeed(
             config.FeedUrl,
             config.PackageFeedName,
             downloadFolder,
             null,
             ScalarPlatform.Instance.UnderConstruction.SupportsNuGetEncryption,
             tracer,
             fileSystem),
         credentialStore,
         ScalarPlatform.Instance.CreateProductUpgraderPlatformInteractions(fileSystem, tracer))
 {
 }
Example #4
0
        /// <summary>
        /// Try to load a NuGetUpgrader from config settings.
        /// <isConfigured>Flag to indicate whether the system is configured to use a NuGetUpgrader.
        /// A NuGetUpgrader can be set as the Upgrader to use, but it might not be properly configured.
        /// </isConfigured>
        /// <Returns>True if able to load a properly configured NuGetUpgrader<Returns>
        /// </summary>
        public static bool TryCreate(
            ITracer tracer,
            PhysicalFileSystem fileSystem,
            bool dryRun,
            bool noVerify,
            out NuGetUpgrader nuGetUpgrader,
            out bool isConfigured,
            out string error)
        {
            NuGetUpgraderConfig upgraderConfig = new NuGetUpgraderConfig(tracer, new LocalGVFSConfig());

            nuGetUpgrader = null;
            isConfigured  = false;

            if (!upgraderConfig.TryLoad(out error))
            {
                nuGetUpgrader = null;
                return(false);
            }

            if (!(isConfigured = upgraderConfig.IsConfigured(out error)))
            {
                return(false);
            }

            // At this point, we have determined that the system is set up to use
            // the NuGetUpgrader

            if (!upgraderConfig.IsReady(out error))
            {
                return(false);
            }

            string gitBinPath = GVFSPlatform.Instance.GitInstallation.GetInstalledGitBinPath();

            if (string.IsNullOrEmpty(gitBinPath))
            {
                error = $"NuGetUpgrader: Unable to locate git installation. Ensure git is installed and try again.";
                return(false);
            }

            ICredentialStore credentialStore = new GitProcess(gitBinPath, workingDirectoryRoot: null, gvfsHooksRoot: null);

            nuGetUpgrader = new NuGetUpgrader(
                ProcessHelper.GetCurrentProcessVersion(),
                tracer,
                fileSystem,
                dryRun,
                noVerify,
                upgraderConfig,
                ProductUpgraderInfo.GetAssetDownloadsPath(),
                credentialStore);

            return(true);
        }
Example #5
0
        /// <summary>
        /// Try to load a NuGetUpgrader from config settings.
        /// <isConfigured>Flag to indicate whether the system is configured to use a NuGetUpgrader.
        /// A NuGetUpgrader can be set as the Upgrader to use, but it might not be properly configured.
        /// </isConfigured>
        /// <Returns>True if able to load a properly configured NuGetUpgrader<Returns>
        /// </summary>
        public static bool TryCreate(
            ITracer tracer,
            PhysicalFileSystem fileSystem,
            LocalScalarConfig scalarConfig,
            ICredentialStore credentialStore,
            bool dryRun,
            bool noVerify,
            out NuGetUpgrader nuGetUpgrader,
            out bool isConfigured,
            out string error)
        {
            NuGetUpgraderConfig upgraderConfig = new NuGetUpgraderConfig(tracer, scalarConfig);

            nuGetUpgrader = null;
            isConfigured  = false;

            if (!upgraderConfig.TryLoad(out error))
            {
                nuGetUpgrader = null;
                return(false);
            }

            if (!(isConfigured = upgraderConfig.IsConfigured(out error)))
            {
                return(false);
            }

            // At this point, we have determined that the system is set up to use
            // the NuGetUpgrader

            if (!upgraderConfig.IsReady(out error))
            {
                return(false);
            }

            nuGetUpgrader = new NuGetUpgrader(
                ProcessHelper.GetCurrentProcessVersion(),
                tracer,
                fileSystem,
                dryRun,
                noVerify,
                upgraderConfig,
                ProductUpgraderInfo.GetAssetDownloadsPath(),
                credentialStore);

            return(true);
        }
Example #6
0
 public NuGetUpgrader(
     string currentVersion,
     ITracer tracer,
     PhysicalFileSystem fileSystem,
     bool dryRun,
     bool noVerify,
     NuGetUpgraderConfig config,
     string downloadFolder,
     string personalAccessToken)
     : this(
         currentVersion,
         tracer,
         dryRun,
         noVerify,
         fileSystem,
         config,
         new NuGetFeed(
             config.FeedUrl,
             config.PackageFeedName,
             downloadFolder,
             personalAccessToken,
             tracer))
 {
 }
Example #7
0
        /// <summary>
        /// Try to load a NuGetUpgrader from config settings.
        /// <isConfigured>Flag to indicate whether the system is configured to use a NuGetUpgrader.
        /// A NuGetUpgrader can be set as the Upgrader to use, but it might not be properly configured.
        /// </isConfigured>
        /// <Returns>True if able to load a properly configured NuGetUpgrader<Returns>
        /// </summary>
        public static bool TryCreate(
            ITracer tracer,
            PhysicalFileSystem fileSystem,
            bool dryRun,
            bool noVerify,
            out NuGetUpgrader nuGetUpgrader,
            out bool isConfigured,
            out string error)
        {
            NuGetUpgraderConfig upgraderConfig = new NuGetUpgraderConfig(tracer, new LocalGVFSConfig());

            nuGetUpgrader = null;
            isConfigured  = false;

            if (!upgraderConfig.TryLoad(out error))
            {
                nuGetUpgrader = null;
                return(false);
            }

            if (!(isConfigured = upgraderConfig.IsConfigured(out error)))
            {
                return(false);
            }

            // At this point, we have determined that the system is set up to use
            // the NuGetUpgrader

            if (!upgraderConfig.IsReady(out error))
            {
                return(false);
            }

            string gitBinPath = GVFSPlatform.Instance.GitInstallation.GetInstalledGitBinPath();

            if (string.IsNullOrEmpty(gitBinPath))
            {
                error = $"NuGetUpgrader: Unable to locate git installation. Ensure git is installed and try again.";
                return(false);
            }

            string authUrl;

            if (!TryCreateAzDevOrgUrlFromPackageFeedUrl(upgraderConfig.FeedUrl, out authUrl, out error))
            {
                return(false);
            }

            if (!TryGetPersonalAccessToken(
                    gitBinPath,
                    authUrl,
                    tracer,
                    out string token,
                    out string getPatError))
            {
                error = $"NuGetUpgrader was not able to acquire Personal Access Token to access NuGet feed. Error: {getPatError}";
                tracer.RelatedError(error);
                return(false);
            }

            nuGetUpgrader = new NuGetUpgrader(
                ProcessHelper.GetCurrentProcessVersion(),
                tracer,
                fileSystem,
                dryRun,
                noVerify,
                upgraderConfig,
                ProductUpgraderInfo.GetAssetDownloadsPath(),
                token);

            return(true);
        }