internal NuGetUpgrader( string currentVersion, ITracer tracer, bool dryRun, bool noVerify, PhysicalFileSystem fileSystem, NuGetUpgraderConfig config, NuGetFeed nuGetFeed, ICredentialStore credentialStore, ProductUpgraderPlatformStrategy productUpgraderPlatformStrategy) : base( currentVersion, tracer, dryRun, noVerify, fileSystem, productUpgraderPlatformStrategy) { 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); }
private bool TryInitializeUpgrader(out string error) { if (this.DryRun && this.Confirmed) { error = $"{DryRunOption} and {ConfirmOption} arguments are not compatible."; return(false); } if (GVFSPlatform.Instance.UnderConstruction.SupportsGVFSUpgrade) { error = null; if (this.upgrader == null) { this.productUpgraderPlatformStrategy = GVFSPlatform.Instance.CreateProductUpgraderPlatformInteractions(this.fileSystem, tracer: null); if (!this.productUpgraderPlatformStrategy.TryPrepareLogDirectory(out error)) { return(false); } JsonTracer jsonTracer = new JsonTracer(GVFSConstants.GVFSEtwProviderName, "UpgradeVerb"); string logFilePath = GVFSEnlistment.GetNewGVFSLogFileName( ProductUpgraderInfo.GetLogDirectoryPath(), GVFSConstants.LogFileTypes.UpgradeVerb); jsonTracer.AddLogFileEventListener(logFilePath, EventLevel.Informational, Keywords.Any); this.tracer = jsonTracer; this.prerunChecker = new InstallerPreRunChecker(this.tracer, this.Confirmed ? GVFSPlatform.Instance.Constants.UpgradeConfirmCommandMessage : GVFSConstants.UpgradeVerbMessages.GVFSUpgrade); string gitBinPath = GVFSPlatform.Instance.GitInstallation.GetInstalledGitBinPath(); if (string.IsNullOrEmpty(gitBinPath)) { error = $"nameof(this.TryInitializeUpgrader): Unable to locate git installation. Ensure git is installed and try again."; return(false); } ICredentialStore credentialStore = new GitProcess(gitBinPath, workingDirectoryRoot: null); ProductUpgrader upgrader; if (ProductUpgrader.TryCreateUpgrader(this.tracer, this.fileSystem, new LocalGVFSConfig(), credentialStore, this.DryRun, this.NoVerify, out upgrader, out error)) { this.upgrader = upgrader; } else { error = $"ERROR: {error}"; } } return(this.upgrader != null); } else { error = $"ERROR: {GVFSConstants.UpgradeVerbMessages.GVFSUpgrade} is not supported on this operating system."; return(false); } }
public UpgradeVerb( ProductUpgrader upgrader, ITracer tracer, PhysicalFileSystem fileSystem, InstallerPreRunChecker prerunChecker, ProcessLauncher processWrapper, TextWriter output) { this.upgrader = upgrader; this.tracer = tracer; this.fileSystem = fileSystem; this.prerunChecker = prerunChecker; this.processLauncher = processWrapper; this.Output = output; this.productUpgraderPlatformStrategy = GVFSPlatform.Instance.CreateProductUpgraderPlatformInteractions(fileSystem, tracer); }
public void SetUp() { this.upgraderConfig = new NuGetUpgrader.NuGetUpgraderConfig(this.tracer, null, NuGetFeedUrl, NuGetFeedName); this.tracer = new MockTracer(); this.mockFileSystem = new MockFileSystem( new MockDirectory( Path.GetDirectoryName(this.downloadDirectoryPath), new[] { new MockDirectory(this.downloadDirectoryPath, null, null) }, null)); this.mockNuGetFeed = new Mock <NuGetFeed>( NuGetFeedUrl, NuGetFeedName, this.downloadDirectoryPath, null, ScalarPlatform.Instance.UnderConstruction.SupportsNuGetEncryption, this.tracer, this.mockFileSystem); this.mockNuGetFeed.Setup(feed => feed.SetCredentials(It.IsAny <string>())); this.mockCredentialManager = new Mock <ICredentialStore>(); string credentialManagerString = "value"; string emptyString = string.Empty; this.mockCredentialManager.Setup(foo => foo.TryGetCredential(It.IsAny <ITracer>(), It.IsAny <string>(), out credentialManagerString, out credentialManagerString, out credentialManagerString)).Returns(true); this.productUpgraderPlatformStrategy = this.CreateProductUpgraderPlatformStrategy(); this.upgrader = new NuGetUpgrader( CurrentVersion, this.tracer, false, false, this.mockFileSystem, this.upgraderConfig, this.mockNuGetFeed.Object, this.mockCredentialManager.Object, this.productUpgraderPlatformStrategy); }