Ejemplo n.º 1
0
        public void CtorFromVersionParts(int major, int minor, int patch, string prerelease, string expectedVersion,
                                         int expectedSdkFeatureBand, int expectedSdkPatchLevel)
        {
            ReleaseVersion v = new ReleaseVersion(major, minor, patch, prerelease);

            Assert.Equal(expectedVersion, v.ToString());

            if (patch > 99)
            {
                Assert.Equal(expectedSdkFeatureBand, v.SdkFeatureBand);
                Assert.Equal(expectedSdkPatchLevel, v.SdkPatchLevel);
            }
        }
Ejemplo n.º 2
0
        static void Generate(TypeIFC type, ReleaseVersion release, string path)
        {
            DatabaseIfc db       = new DatabaseIfc(true, release);
            IfcBuilding building = new IfcBuilding(db, "IfcBuilding")
            {
            };
            IfcProject project = new IfcProject(building, "IfcProject", IfcUnitAssignment.Length.Millimetre)
            {
            };

            IfcRectangleProfileDef    rect      = new IfcRectangleProfileDef(db, "Rect", 1000, 500);
            IfcExtrudedAreaSolid      extrusion = new IfcExtrudedAreaSolid(rect, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0)), new IfcDirection(db, 0, 0, 1), 2000);
            IfcProductDefinitionShape rep       = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrusion));

            if (type == TypeIFC.Chiller)
            {
                IfcChiller chiller = new IfcChiller(building, null, rep, null)
                {
                    PredefinedType = IfcChillerTypeEnum.AIRCOOLED
                };
                if (release == ReleaseVersion.IFC2x3)
                {
                    chiller.RelatingType = new IfcChillerType(db, "MyChillerType", IfcChillerTypeEnum.AIRCOOLED);
                }
            }
            else if (type == TypeIFC.AirTerminal)
            {
                IfcAirTerminal terminal = new IfcAirTerminal(building, null, rep, null)
                {
                    PredefinedType = IfcAirTerminalTypeEnum.DIFFUSER
                };
                if (release == ReleaseVersion.IFC2x3)
                {
                    terminal.RelatingType = new IfcAirTerminalType(db, "MyAirTerminalType", IfcAirTerminalTypeEnum.DIFFUSER);
                }
            }
            else
            {
                IfcElectricDistributionPoint point = new IfcElectricDistributionPoint(building, null, rep, null)
                {
                    DistributionPointFunction = IfcElectricDistributionPointFunctionEnum.DISTRIBUTIONBOARD
                };
            }
            db.WriteFile(Path.Combine(path, type.ToString() + " " + release.ToString() + ".ifc"));
        }
Ejemplo n.º 3
0
        private async Task UseTempManifestsToResolvePacksAsync(DirectoryPath tempPath, bool includePreview)
        {
            var manifestPackagePaths = await _workloadManifestUpdater.DownloadManifestPackagesAsync(includePreview, tempPath);

            if (manifestPackagePaths == null || !manifestPackagePaths.Any())
            {
                Reporter.WriteLine(LocalizableStrings.SkippingManifestUpdate);
                return;
            }
            await _workloadManifestUpdater.ExtractManifestPackagesToTempDirAsync(manifestPackagePaths, tempPath);

            var overlayProvider = new TempDirectoryWorkloadManifestProvider(tempPath.Value, _sdkVersion.ToString());

            _workloadResolver = _workloadResolver.CreateOverlayResolver(overlayProvider);
        }
Ejemplo n.º 4
0
        public WorkloadSearchCommand(
            ParseResult result,
            IReporter reporter = null,
            IWorkloadResolver workloadResolver = null,
            string version        = null,
            string userProfileDir = null) : base(result)
        {
            _reporter       = reporter ?? Reporter.Output;
            _verbosity      = result.GetValueForOption(WorkloadSearchCommandParser.VerbosityOption);
            _workloadIdStub = result.GetValueForArgument(WorkloadSearchCommandParser.WorkloadIdStubArgument);
            var dotnetPath = Path.GetDirectoryName(Environment.ProcessPath);

            userProfileDir ??= CliFolderPathCalculator.DotnetUserProfileFolderPath;
            _sdkVersion = WorkloadOptionsExtensions.GetValidatedSdkVersion(result.GetValueForOption(WorkloadSearchCommandParser.VersionOption), version, dotnetPath, userProfileDir);
            var workloadManifestProvider = new SdkDirectoryWorkloadManifestProvider(dotnetPath, _sdkVersion.ToString(), userProfileDir);

            _workloadResolver = workloadResolver ?? WorkloadResolver.Create(workloadManifestProvider, dotnetPath, _sdkVersion.ToString(), userProfileDir);
        }
Ejemplo n.º 5
0
        public WorkloadRepairCommand(
            ParseResult parseResult,
            IReporter reporter = null,
            IWorkloadResolver workloadResolver             = null,
            IInstaller workloadInstaller                   = null,
            INuGetPackageDownloader nugetPackageDownloader = null,
            string dotnetDir      = null,
            string tempDirPath    = null,
            string version        = null,
            string userProfileDir = null)
            : base(parseResult, reporter: reporter, nugetPackageDownloader: nugetPackageDownloader)
        {
            _dotnetPath = dotnetDir ?? Path.GetDirectoryName(Environment.ProcessPath);
            userProfileDir ??= CliFolderPathCalculator.DotnetUserProfileFolderPath;
            _sdkVersion = WorkloadOptionsExtensions.GetValidatedSdkVersion(parseResult.GetValueForOption(WorkloadRepairCommandParser.VersionOption), version, _dotnetPath, userProfileDir);

            var configOption = parseResult.GetValueForOption(WorkloadRepairCommandParser.ConfigOption);
            var sourceOption = parseResult.GetValueForOption(WorkloadRepairCommandParser.SourceOption);

            _packageSourceLocation = string.IsNullOrEmpty(configOption) && (sourceOption == null || !sourceOption.Any()) ? null :
                                     new PackageSourceLocation(string.IsNullOrEmpty(configOption) ? null : new FilePath(configOption), sourceFeedOverrides: sourceOption);

            var workloadManifestProvider = new SdkDirectoryWorkloadManifestProvider(_dotnetPath, _sdkVersion.ToString(), userProfileDir);

            _workloadResolver = workloadResolver ?? WorkloadResolver.Create(workloadManifestProvider, _dotnetPath, _sdkVersion.ToString(), userProfileDir);
            var sdkFeatureBand = new SdkFeatureBand(_sdkVersion);

            _workloadInstaller = workloadInstaller ??
                                 WorkloadInstallerFactory.GetWorkloadInstaller(Reporter, sdkFeatureBand,
                                                                               _workloadResolver, Verbosity, userProfileDir, VerifySignatures, PackageDownloader, dotnetDir, TempDirectoryPath,
                                                                               _packageSourceLocation, _parseResult.ToRestoreActionConfig());
        }
Ejemplo n.º 6
0
        public void ToStringContainsMajorMinorPatch()
        {
            ReleaseVersion v1 = new ReleaseVersion("4.9.7");

            Assert.Equal("4.9.7", v1.ToString());
        }
Ejemplo n.º 7
0
        public WorkloadInstallCommand(
            ParseResult parseResult,
            IReporter reporter = null,
            IWorkloadResolver workloadResolver               = null,
            IInstaller workloadInstaller                     = null,
            INuGetPackageDownloader nugetPackageDownloader   = null,
            IWorkloadManifestUpdater workloadManifestUpdater = null,
            string dotnetDir   = null,
            string userHome    = null,
            string tempDirPath = null,
            string version     = null)
            : base(parseResult)
        {
            _reporter              = reporter ?? Reporter.Output;
            _skipManifestUpdate    = parseResult.ValueForOption <bool>(WorkloadInstallCommandParser.SkipManifestUpdateOption);
            _includePreviews       = parseResult.ValueForOption <bool>(WorkloadInstallCommandParser.IncludePreviewOption);
            _printDownloadLinkOnly = parseResult.ValueForOption <bool>(WorkloadInstallCommandParser.PrintDownloadLinkOnlyOption);
            _fromCacheOption       = parseResult.ValueForOption <string>(WorkloadInstallCommandParser.FromCacheOption);
            _downloadToCacheOption = parseResult.ValueForOption <string>(WorkloadInstallCommandParser.DownloadToCacheOption);
            _workloadIds           = parseResult.ValueForArgument <IEnumerable <string> >(WorkloadInstallCommandParser.WorkloadIdArgument).ToList().AsReadOnly();
            _verbosity             = parseResult.ValueForOption <VerbosityOptions>(WorkloadInstallCommandParser.VerbosityOption);
            _sdkVersion            = string.IsNullOrEmpty(parseResult.ValueForOption <string>(WorkloadInstallCommandParser.VersionOption)) ?
                                     new ReleaseVersion(version ?? Product.Version) :
                                     new ReleaseVersion(parseResult.ValueForOption <string>(WorkloadInstallCommandParser.VersionOption));
            _tempDirPath = tempDirPath ?? (string.IsNullOrWhiteSpace(parseResult.ValueForOption <string>(WorkloadInstallCommandParser.TempDirOption)) ?
                                           Path.GetTempPath() :
                                           parseResult.ValueForOption <string>(WorkloadInstallCommandParser.TempDirOption));

            var configOption    = parseResult.ValueForOption <string>(WorkloadInstallCommandParser.ConfigOption);
            var addSourceOption = parseResult.ValueForOption <string[]>(WorkloadInstallCommandParser.AddSourceOption);

            _packageSourceLocation = string.IsNullOrEmpty(configOption) && (addSourceOption == null || !addSourceOption.Any()) ? null :
                                     new PackageSourceLocation(string.IsNullOrEmpty(configOption) ? null : new FilePath(configOption), sourceFeedOverrides: addSourceOption);

            _dotnetPath = dotnetDir ?? Path.GetDirectoryName(Environment.ProcessPath);
            _workloadManifestProvider = new SdkDirectoryWorkloadManifestProvider(_dotnetPath, _sdkVersion.ToString());
            _workloadResolver         = workloadResolver ?? WorkloadResolver.Create(_workloadManifestProvider, _dotnetPath, _sdkVersion.ToString());
            var sdkFeatureBand = new SdkFeatureBand(_sdkVersion);

            _workloadInstaller = workloadInstaller ??
                                 WorkloadInstallerFactory.GetWorkloadInstaller(_reporter, sdkFeatureBand, _workloadResolver, _verbosity, nugetPackageDownloader, _dotnetPath, _packageSourceLocation);
            _userHome = userHome ?? CliFolderPathCalculator.DotnetHomePath;
            var tempPackagesDir = new DirectoryPath(Path.Combine(_tempDirPath, "dotnet-sdk-advertising-temp"));

            _nugetPackageDownloader  = nugetPackageDownloader ?? new NuGetPackageDownloader(tempPackagesDir, filePermissionSetter: null, new NullLogger());
            _workloadManifestUpdater = workloadManifestUpdater ?? new WorkloadManifestUpdater(_reporter, _workloadManifestProvider, _nugetPackageDownloader, _userHome, _tempDirPath, _packageSourceLocation);
        }
Ejemplo n.º 8
0
        public WorkloadUninstallCommand(
            ParseResult parseResult,
            IReporter reporter = null,
            IWorkloadResolver workloadResolver             = null,
            INuGetPackageDownloader nugetPackageDownloader = null,
            string dotnetDir      = null,
            string version        = null,
            string userProfileDir = null)
            : base(parseResult, reporter: reporter, nugetPackageDownloader: nugetPackageDownloader)
        {
            _workloadIds = parseResult.GetValueForArgument(WorkloadUninstallCommandParser.WorkloadIdArgument)
                           .Select(workloadId => new WorkloadId(workloadId)).ToList().AsReadOnly();
            var dotnetPath = dotnetDir ?? Path.GetDirectoryName(Environment.ProcessPath);

            userProfileDir = userProfileDir ?? CliFolderPathCalculator.DotnetUserProfileFolderPath;
            _sdkVersion    = WorkloadOptionsExtensions.GetValidatedSdkVersion(parseResult.GetValueForOption(WorkloadUninstallCommandParser.VersionOption), version, dotnetPath, userProfileDir);

            var workloadManifestProvider = new SdkDirectoryWorkloadManifestProvider(dotnetPath, _sdkVersion.ToString(), userProfileDir);

            workloadResolver ??= WorkloadResolver.Create(workloadManifestProvider, dotnetPath, _sdkVersion.ToString(), userProfileDir);

            var sdkFeatureBand = new SdkFeatureBand(_sdkVersion);

            _workloadInstaller = WorkloadInstallerFactory.GetWorkloadInstaller(Reporter, sdkFeatureBand, workloadResolver, Verbosity, userProfileDir, VerifySignatures, PackageDownloader, dotnetPath);
        }
Ejemplo n.º 9
0
        public WorkloadUninstallCommand(
            ParseResult parseResult,
            IReporter reporter = null,
            IWorkloadResolver workloadResolver             = null,
            INuGetPackageDownloader nugetPackageDownloader = null,
            string dotnetDir = null,
            string version   = null)
            : base(parseResult)
        {
            _reporter    = reporter ?? Reporter.Output;
            _workloadIds = parseResult.ValueForArgument <IEnumerable <string> >(WorkloadUninstallCommandParser.WorkloadIdArgument)
                           .Select(workloadId => new WorkloadId(workloadId)).ToList().AsReadOnly();
            var dotnetPath = dotnetDir ?? Path.GetDirectoryName(Environment.ProcessPath);

            _sdkVersion = WorkloadOptionsExtensions.GetValidatedSdkVersion(parseResult.ValueForOption <string>(WorkloadUninstallCommandParser.VersionOption), version, dotnetPath);
            var verbosity = parseResult.ValueForOption <VerbosityOptions>(WorkloadUninstallCommandParser.VerbosityOption);
            var workloadManifestProvider = new SdkDirectoryWorkloadManifestProvider(dotnetPath, _sdkVersion.ToString());

            workloadResolver ??= WorkloadResolver.Create(workloadManifestProvider, dotnetPath, _sdkVersion.ToString());
            nugetPackageDownloader ??= new NuGetPackageDownloader(new DirectoryPath(Path.GetTempPath()), filePermissionSetter: null, verboseLogger: new NullLogger());
            var sdkFeatureBand = new SdkFeatureBand(_sdkVersion);

            _workloadInstaller = WorkloadInstallerFactory.GetWorkloadInstaller(_reporter, sdkFeatureBand, workloadResolver, verbosity, nugetPackageDownloader, dotnetPath);
        }
Ejemplo n.º 10
0
        public WorkloadInstallCommand(
            ParseResult parseResult,
            IReporter reporter = null,
            IWorkloadResolver workloadResolver = null,
            IInstaller workloadInstaller       = null,
            string version = null)
            : base(parseResult)
        {
            _reporter              = reporter ?? Reporter.Output;
            _skipManifestUpdate    = parseResult.ValueForOption <bool>(WorkloadInstallCommandParser.SkipManifestUpdateOption);
            _printDownloadLinkOnly = parseResult.ValueForOption <bool>(WorkloadInstallCommandParser.PrintDownloadLinkOnlyOption);
            _fromCacheOption       = parseResult.ValueForOption <string>(WorkloadInstallCommandParser.FromCacheOption);
            _workloadIds           = parseResult.ValueForArgument <IReadOnlyCollection <string> >(WorkloadInstallCommandParser.WorkloadIdArgument);
            _sdkVersion            = new ReleaseVersion(version ?? Product.Version);

            var dotnetPath = EnvironmentProvider.GetDotnetExeDirectory();
            var workloadManifestProvider = new SdkDirectoryWorkloadManifestProvider(dotnetPath, _sdkVersion.ToString());

            _workloadResolver = workloadResolver ?? WorkloadResolver.Create(workloadManifestProvider, dotnetPath, _sdkVersion.ToString());
            var sdkFeatureBand = new SdkFeatureBand(string.Join('.', _sdkVersion.Major, _sdkVersion.Minor, _sdkVersion.SdkFeatureBand));

            _workloadInstaller = workloadInstaller ?? WorkloadInstallerFactory.GetWorkloadInstaller(_reporter, sdkFeatureBand, _workloadResolver);
        }
Ejemplo n.º 11
0
        public WorkloadUpdateCommand(
            ParseResult parseResult,
            IReporter reporter = null,
            IWorkloadResolver workloadResolver               = null,
            IInstaller workloadInstaller                     = null,
            INuGetPackageDownloader nugetPackageDownloader   = null,
            IWorkloadManifestUpdater workloadManifestUpdater = null,
            string dotnetDir      = null,
            string userProfileDir = null,
            string tempDirPath    = null,
            string version        = null)
            : base(parseResult, reporter: reporter, tempDirPath: tempDirPath, nugetPackageDownloader: nugetPackageDownloader)
        {
            _printDownloadLinkOnly =
                parseResult.GetValueForOption(WorkloadUpdateCommandParser.PrintDownloadLinkOnlyOption);
            _fromCacheOption       = parseResult.GetValueForOption(WorkloadUpdateCommandParser.FromCacheOption);
            _includePreviews       = parseResult.GetValueForOption(WorkloadUpdateCommandParser.IncludePreviewsOption);
            _fromPreviousSdk       = parseResult.GetValueForOption(WorkloadUpdateCommandParser.FromPreviousSdkOption);
            _adManifestOnlyOption  = parseResult.GetValueForOption(WorkloadUpdateCommandParser.AdManifestOnlyOption);
            _downloadToCacheOption = parseResult.GetValueForOption(WorkloadUpdateCommandParser.DownloadToCacheOption);
            _dotnetPath            = dotnetDir ?? Path.GetDirectoryName(Environment.ProcessPath);
            _userProfileDir        = userProfileDir ?? CliFolderPathCalculator.DotnetUserProfileFolderPath;
            _sdkVersion            = WorkloadOptionsExtensions.GetValidatedSdkVersion(parseResult.GetValueForOption(WorkloadUpdateCommandParser.VersionOption), version, _dotnetPath, _userProfileDir);

            _printRollbackDefinitionOnly = parseResult.GetValueForOption(WorkloadUpdateCommandParser.PrintRollbackOption);
            _fromRollbackDefinition      = parseResult.GetValueForOption(WorkloadUpdateCommandParser.FromRollbackFileOption);

            var configOption = parseResult.GetValueForOption(WorkloadUpdateCommandParser.ConfigOption);
            var sourceOption = parseResult.GetValueForOption <string[]>(WorkloadUpdateCommandParser.SourceOption);

            _packageSourceLocation = string.IsNullOrEmpty(configOption) && (sourceOption == null || !sourceOption.Any()) ? null :
                                     new PackageSourceLocation(string.IsNullOrEmpty(configOption) ? null : new FilePath(configOption), sourceFeedOverrides: sourceOption);

            var workloadManifestProvider = new SdkDirectoryWorkloadManifestProvider(_dotnetPath, _sdkVersion.ToString(), _userProfileDir);

            _workloadResolver = workloadResolver ?? WorkloadResolver.Create(workloadManifestProvider, _dotnetPath, _sdkVersion.ToString(), _userProfileDir);
            var sdkFeatureBand = new SdkFeatureBand(_sdkVersion);

            _workloadInstaller = workloadInstaller ?? WorkloadInstallerFactory.GetWorkloadInstaller(Reporter,
                                                                                                    sdkFeatureBand, _workloadResolver, Verbosity, _userProfileDir, VerifySignatures, PackageDownloader,
                                                                                                    dotnetDir, TempDirectoryPath, packageSourceLocation: _packageSourceLocation, RestoreActionConfiguration,
                                                                                                    elevationRequired: !_printDownloadLinkOnly && !_printRollbackDefinitionOnly && string.IsNullOrWhiteSpace(_downloadToCacheOption));
            _workloadManifestUpdater = workloadManifestUpdater ?? new WorkloadManifestUpdater(Reporter, _workloadResolver, PackageDownloader, _userProfileDir, TempDirectoryPath,
                                                                                              _workloadInstaller.GetWorkloadInstallationRecordRepository(), _packageSourceLocation);
        }
Ejemplo n.º 12
0
        private async Task DownloadToOfflineCacheAsync(DirectoryPath offlineCache, bool includePreviews)
        {
            var manifestPackagePaths = await _workloadManifestUpdater.DownloadManifestPackagesAsync(includePreviews, offlineCache);

            var tempManifestDir = Path.Combine(offlineCache.Value, "temp-manifests");

            try
            {
                await _workloadManifestUpdater.ExtractManifestPackagesToTempDirAsync(manifestPackagePaths, new DirectoryPath(tempManifestDir));

                var overlayManifestProvider = new TempDirectoryWorkloadManifestProvider(tempManifestDir, _sdkVersion.ToString());
                _workloadResolver = WorkloadResolver.Create(overlayManifestProvider, _dotnetPath, _sdkVersion.ToString(), _userProfileDir);

                if (_workloadInstaller.GetInstallationUnit().Equals(InstallationUnit.Packs))
                {
                    var installer     = _workloadInstaller.GetPackInstaller();
                    var packsToUpdate = GetUpdatablePacks(installer);
                    foreach (var pack in packsToUpdate)
                    {
                        installer.DownloadToOfflineCache(pack, new DirectoryPath(_downloadToCacheOption), _includePreviews);
                    }
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
            finally
            {
                if (!string.IsNullOrWhiteSpace(tempManifestDir) && Directory.Exists(tempManifestDir))
                {
                    Directory.Delete(tempManifestDir, true);
                }
            }
        }
Ejemplo n.º 13
0
        public void ToStringContainsBuildMetadata()
        {
            ReleaseVersion v1 = new ReleaseVersion("4.9.7+build.12345");

            Assert.Equal("4.9.7+build.12345", v1.ToString());
        }
Ejemplo n.º 14
0
        public void ToStringContainsPrereleaseLabels()
        {
            ReleaseVersion v1 = new ReleaseVersion("4.9.7-a.b.c.d.e.f");

            Assert.Equal("4.9.7-a.b.c.d.e.f", v1.ToString());
        }
Ejemplo n.º 15
0
        public WorkloadInstallCommand(
            ParseResult parseResult,
            IReporter reporter = null,
            IWorkloadResolver workloadResolver               = null,
            IInstaller workloadInstaller                     = null,
            INuGetPackageDownloader nugetPackageDownloader   = null,
            IWorkloadManifestUpdater workloadManifestUpdater = null,
            string dotnetDir      = null,
            string userProfileDir = null,
            string tempDirPath    = null,
            string version        = null,
            IReadOnlyCollection <string> workloadIds = null)
            : base(parseResult, reporter: reporter, tempDirPath: tempDirPath, nugetPackageDownloader: nugetPackageDownloader)
        {
            _skipManifestUpdate     = parseResult.GetValueForOption(WorkloadInstallCommandParser.SkipManifestUpdateOption);
            _includePreviews        = parseResult.GetValueForOption(WorkloadInstallCommandParser.IncludePreviewOption);
            _printDownloadLinkOnly  = parseResult.GetValueForOption(WorkloadInstallCommandParser.PrintDownloadLinkOnlyOption);
            _fromCacheOption        = parseResult.GetValueForOption(WorkloadInstallCommandParser.FromCacheOption);
            _downloadToCacheOption  = parseResult.GetValueForOption(WorkloadInstallCommandParser.DownloadToCacheOption);
            _workloadIds            = workloadIds ?? parseResult.GetValueForArgument(WorkloadInstallCommandParser.WorkloadIdArgument).ToList().AsReadOnly();
            _dotnetPath             = dotnetDir ?? Path.GetDirectoryName(Environment.ProcessPath);
            _userProfileDir         = userProfileDir ?? CliFolderPathCalculator.DotnetUserProfileFolderPath;
            _sdkVersion             = WorkloadOptionsExtensions.GetValidatedSdkVersion(parseResult.GetValueForOption(WorkloadInstallCommandParser.VersionOption), version, _dotnetPath, _userProfileDir);
            _sdkFeatureBand         = new SdkFeatureBand(_sdkVersion);
            _fromRollbackDefinition = parseResult.GetValueForOption(WorkloadInstallCommandParser.FromRollbackFileOption);

            var configOption = parseResult.GetValueForOption(WorkloadInstallCommandParser.ConfigOption);
            var sourceOption = parseResult.GetValueForOption(WorkloadInstallCommandParser.SourceOption);

            _packageSourceLocation = string.IsNullOrEmpty(configOption) && (sourceOption == null || !sourceOption.Any()) ? null :
                                     new PackageSourceLocation(string.IsNullOrEmpty(configOption) ? null : new FilePath(configOption), sourceFeedOverrides: sourceOption);

            var sdkWorkloadManifestProvider = new SdkDirectoryWorkloadManifestProvider(_dotnetPath, _sdkVersion.ToString(), userProfileDir);

            _workloadResolver = workloadResolver ?? WorkloadResolver.Create(sdkWorkloadManifestProvider, _dotnetPath, _sdkVersion.ToString(), _userProfileDir);
            var sdkFeatureBand  = new SdkFeatureBand(_sdkVersion);
            var tempPackagesDir = new DirectoryPath(Path.Combine(TempDirectoryPath, "dotnet-sdk-advertising-temp"));

            _workloadInstaller = workloadInstaller ??
                                 WorkloadInstallerFactory.GetWorkloadInstaller(Reporter, sdkFeatureBand,
                                                                               _workloadResolver, Verbosity, _userProfileDir, VerifySignatures, PackageDownloader, _dotnetPath, TempDirectoryPath,
                                                                               _packageSourceLocation, RestoreActionConfiguration, elevationRequired: !_printDownloadLinkOnly && string.IsNullOrWhiteSpace(_downloadToCacheOption));
            bool displayManifestUpdates = false;

            if (Verbosity.VerbosityIsDetailedOrDiagnostic())
            {
                displayManifestUpdates = true;
            }
            _workloadManifestUpdater = workloadManifestUpdater ?? new WorkloadManifestUpdater(Reporter, _workloadResolver, PackageDownloader, _userProfileDir, TempDirectoryPath,
                                                                                              _workloadInstaller.GetWorkloadInstallationRecordRepository(), _packageSourceLocation, displayManifestUpdates: displayManifestUpdates);

            ValidateWorkloadIdsInput();
        }
Ejemplo n.º 16
0
        public WorkloadListCommand(
            ParseResult result,
            IReporter reporter = null,
            IWorkloadInstallationRecordRepository workloadRecordRepo = null,
            string version = null) : base(result)
        {
            _reporter = reporter ?? Reporter.Output;
            _machineReadableOption = result.ValueForOption <bool>(WorkloadListCommandParser.MachineReadableOption);
            _verbosity             = result.ValueForOption <VerbosityOptions>(WorkloadListCommandParser.VerbosityOption);

            var sdkVersion = new ReleaseVersion(version ?? Product.Version);
            var dotnetPath = Path.GetDirectoryName(Environment.ProcessPath);
            var workloadManifestProvider = new SdkDirectoryWorkloadManifestProvider(dotnetPath, sdkVersion.ToString());
            var workloadResolver         = WorkloadResolver.Create(workloadManifestProvider, dotnetPath, sdkVersion.ToString());

            _sdkFeatureBand     = new SdkFeatureBand(sdkVersion);
            _workloadRecordRepo = workloadRecordRepo ??
                                  WorkloadInstallerFactory
                                  .GetWorkloadInstaller(_reporter, _sdkFeatureBand, workloadResolver, _verbosity)
                                  .GetWorkloadInstallationRecordRepository();
            _sdkVersion = result.ValueForOption <string>(WorkloadUpdateCommandParser.SdkVersionOption);
        }
Ejemplo n.º 17
0
        public WorkloadSearchCommand(
            ParseResult result,
            IReporter reporter = null,
            IWorkloadResolver workloadResolver = null,
            string version = null) : base(result)
        {
            _reporter       = reporter ?? Reporter.Output;
            _verbosity      = result.ValueForOption <VerbosityOptions>(WorkloadSearchCommandParser.VerbosityOption);
            _workloadIdStub = result.ValueForArgument <string>(WorkloadSearchCommandParser.WorkloadIdStubArgument);
            _sdkVersion     = new ReleaseVersion(version ?? Product.Version) ?? new ReleaseVersion(result.ValueForOption <string>(WorkloadSearchCommandParser.VersionOption));
            var dotnetPath = Path.GetDirectoryName(Environment.ProcessPath);
            var workloadManifestProvider = new SdkDirectoryWorkloadManifestProvider(dotnetPath, _sdkVersion.ToString());

            _workloadResolver = workloadResolver ?? WorkloadResolver.Create(workloadManifestProvider, dotnetPath, _sdkVersion.ToString());
        }
Ejemplo n.º 18
0
 public override string ToString()
 {
     return(_featureBand.ToString());
 }
Ejemplo n.º 19
0
        public WorkloadRepairCommand(
            ParseResult parseResult,
            IReporter reporter = null,
            IWorkloadResolver workloadResolver             = null,
            IInstaller workloadInstaller                   = null,
            INuGetPackageDownloader nugetPackageDownloader = null,
            string dotnetDir   = null,
            string tempDirPath = null,
            string version     = null)
            : base(parseResult)
        {
            _reporter   = reporter ?? Reporter.Output;
            _verbosity  = parseResult.ValueForOption <VerbosityOptions>(WorkloadRepairCommandParser.VerbosityOption);
            _dotnetPath = dotnetDir ?? Path.GetDirectoryName(Environment.ProcessPath);
            _sdkVersion = WorkloadOptionsExtensions.GetValidatedSdkVersion(parseResult.ValueForOption <string>(WorkloadRepairCommandParser.VersionOption), version, _dotnetPath);

            var configOption = parseResult.ValueForOption <string>(WorkloadRepairCommandParser.ConfigOption);
            var sourceOption = parseResult.ValueForOption <string[]>(WorkloadRepairCommandParser.SourceOption);

            _packageSourceLocation = string.IsNullOrEmpty(configOption) && (sourceOption == null || !sourceOption.Any()) ? null :
                                     new PackageSourceLocation(string.IsNullOrEmpty(configOption) ? null : new FilePath(configOption), sourceFeedOverrides: sourceOption);

            _workloadManifestProvider = new SdkDirectoryWorkloadManifestProvider(_dotnetPath, _sdkVersion.ToString());
            _workloadResolver         = workloadResolver ?? WorkloadResolver.Create(_workloadManifestProvider, _dotnetPath, _sdkVersion.ToString());
            var sdkFeatureBand = new SdkFeatureBand(_sdkVersion);

            tempDirPath = tempDirPath ?? (string.IsNullOrWhiteSpace(parseResult.ValueForOption <string>(WorkloadInstallCommandParser.TempDirOption)) ?
                                          Path.GetTempPath() :
                                          parseResult.ValueForOption <string>(WorkloadInstallCommandParser.TempDirOption));
            var        tempPackagesDir = new DirectoryPath(Path.Combine(tempDirPath, "dotnet-sdk-advertising-temp"));
            NullLogger nullLogger      = new NullLogger();

            nugetPackageDownloader ??= new NuGetPackageDownloader(
                tempPackagesDir,
                filePermissionSetter: null,
                new FirstPartyNuGetPackageSigningVerifier(tempPackagesDir, nullLogger), nullLogger, restoreActionConfig: _parseResult.ToRestoreActionConfig());
            _workloadInstaller = workloadInstaller ??
                                 WorkloadInstallerFactory.GetWorkloadInstaller(_reporter, sdkFeatureBand,
                                                                               _workloadResolver, _verbosity, nugetPackageDownloader, dotnetDir, tempDirPath,
                                                                               _packageSourceLocation, _parseResult.ToRestoreActionConfig());
        }
Ejemplo n.º 20
0
        public WorkloadUpdateCommand(
            ParseResult parseResult,
            IReporter reporter = null,
            IWorkloadResolver workloadResolver               = null,
            IInstaller workloadInstaller                     = null,
            INuGetPackageDownloader nugetPackageDownloader   = null,
            IWorkloadManifestUpdater workloadManifestUpdater = null,
            string dotnetDir      = null,
            string userProfileDir = null,
            string tempDirPath    = null,
            string version        = null)
            : base(parseResult)
        {
            _printDownloadLinkOnly =
                parseResult.GetValueForOption(WorkloadUpdateCommandParser.PrintDownloadLinkOnlyOption);
            _fromCacheOption       = parseResult.GetValueForOption(WorkloadUpdateCommandParser.FromCacheOption);
            _reporter              = reporter ?? Reporter.Output;
            _includePreviews       = parseResult.GetValueForOption(WorkloadUpdateCommandParser.IncludePreviewsOption);
            _fromPreviousSdk       = parseResult.GetValueForOption(WorkloadUpdateCommandParser.FromPreviousSdkOption);
            _adManifestOnlyOption  = parseResult.GetValueForOption(WorkloadUpdateCommandParser.AdManifestOnlyOption);
            _downloadToCacheOption = parseResult.GetValueForOption(WorkloadUpdateCommandParser.DownloadToCacheOption);
            _verbosity             = parseResult.GetValueForOption(WorkloadUpdateCommandParser.VerbosityOption);
            _dotnetPath            = dotnetDir ?? Path.GetDirectoryName(Environment.ProcessPath);
            _userProfileDir        = userProfileDir ?? CliFolderPathCalculator.DotnetUserProfileFolderPath;
            _sdkVersion            = WorkloadOptionsExtensions.GetValidatedSdkVersion(parseResult.GetValueForOption(WorkloadUpdateCommandParser.VersionOption), version, _dotnetPath, _userProfileDir);
            _tempDirPath           = tempDirPath ?? (string.IsNullOrWhiteSpace(parseResult.GetValueForOption(WorkloadUpdateCommandParser.TempDirOption)) ?
                                                     Path.GetTempPath() :
                                                     parseResult.GetValueForOption(WorkloadUpdateCommandParser.TempDirOption));
            _printRollbackDefinitionOnly = parseResult.GetValueForOption(WorkloadUpdateCommandParser.PrintRollbackOption);
            _fromRollbackDefinition      = parseResult.GetValueForOption(WorkloadUpdateCommandParser.FromRollbackFileOption);

            var configOption = parseResult.GetValueForOption(WorkloadUpdateCommandParser.ConfigOption);
            var sourceOption = parseResult.GetValueForOption <string[]>(WorkloadUpdateCommandParser.SourceOption);

            _packageSourceLocation = string.IsNullOrEmpty(configOption) && (sourceOption == null || !sourceOption.Any()) ? null :
                                     new PackageSourceLocation(string.IsNullOrEmpty(configOption) ? null : new FilePath(configOption), sourceFeedOverrides:  sourceOption);

            var workloadManifestProvider = new SdkDirectoryWorkloadManifestProvider(_dotnetPath, _sdkVersion.ToString(), _userProfileDir);

            _workloadResolver = workloadResolver ?? WorkloadResolver.Create(workloadManifestProvider, _dotnetPath, _sdkVersion.ToString(), _userProfileDir);
            var sdkFeatureBand      = new SdkFeatureBand(_sdkVersion);
            var restoreActionConfig = _parseResult.ToRestoreActionConfig();

            _workloadInstaller = workloadInstaller ?? WorkloadInstallerFactory.GetWorkloadInstaller(_reporter,
                                                                                                    sdkFeatureBand, _workloadResolver, _verbosity, _userProfileDir, nugetPackageDownloader,
                                                                                                    dotnetDir, _tempDirPath, packageSourceLocation: _packageSourceLocation, restoreActionConfig,
                                                                                                    elevationRequired: !_printDownloadLinkOnly && string.IsNullOrWhiteSpace(_downloadToCacheOption));
            var tempPackagesDir = new DirectoryPath(Path.Combine(_tempDirPath, "dotnet-sdk-advertising-temp"));

            _nugetPackageDownloader = nugetPackageDownloader ?? new NuGetPackageDownloader(tempPackagesDir,
                                                                                           filePermissionSetter: null, new FirstPartyNuGetPackageSigningVerifier(tempPackagesDir, _verbosity.VerbosityIsDetailedOrDiagnostic() ? new NuGetConsoleLogger() : new NullLogger()),
                                                                                           _verbosity.VerbosityIsDetailedOrDiagnostic() ? new NuGetConsoleLogger() : new NullLogger(), restoreActionConfig: restoreActionConfig);
            _workloadManifestUpdater = workloadManifestUpdater ?? new WorkloadManifestUpdater(_reporter, _workloadResolver, _nugetPackageDownloader, _userProfileDir, _tempDirPath,
                                                                                              _workloadInstaller.GetWorkloadInstallationRecordRepository(), _packageSourceLocation);
        }
Ejemplo n.º 21
0
        public WorkloadInstallCommand(
            ParseResult parseResult,
            IReporter reporter = null,
            IWorkloadResolver workloadResolver               = null,
            IInstaller workloadInstaller                     = null,
            INuGetPackageDownloader nugetPackageDownloader   = null,
            IWorkloadManifestUpdater workloadManifestUpdater = null,
            string dotnetDir   = null,
            string userHome    = null,
            string tempDirPath = null,
            string version     = null,
            IReadOnlyCollection <string> workloadIds = null)
            : base(parseResult)
        {
            _reporter              = reporter ?? Reporter.Output;
            _skipManifestUpdate    = parseResult.ValueForOption <bool>(WorkloadInstallCommandParser.SkipManifestUpdateOption);
            _includePreviews       = parseResult.ValueForOption <bool>(WorkloadInstallCommandParser.IncludePreviewOption);
            _printDownloadLinkOnly = parseResult.ValueForOption <bool>(WorkloadInstallCommandParser.PrintDownloadLinkOnlyOption);
            _fromCacheOption       = parseResult.ValueForOption <string>(WorkloadInstallCommandParser.FromCacheOption);
            _downloadToCacheOption = parseResult.ValueForOption <string>(WorkloadInstallCommandParser.DownloadToCacheOption);
            _workloadIds           = workloadIds ?? parseResult.ValueForArgument <IEnumerable <string> >(WorkloadInstallCommandParser.WorkloadIdArgument).ToList().AsReadOnly();
            _verbosity             = parseResult.ValueForOption <VerbosityOptions>(WorkloadInstallCommandParser.VerbosityOption);
            _dotnetPath            = dotnetDir ?? Path.GetDirectoryName(Environment.ProcessPath);
            _sdkVersion            = WorkloadOptionsExtensions.GetValidatedSdkVersion(parseResult.ValueForOption <string>(WorkloadInstallCommandParser.VersionOption), version, _dotnetPath);
            _sdkFeatureBand        = new SdkFeatureBand(string.Join('.', _sdkVersion.Major, _sdkVersion.Minor, _sdkVersion.SdkFeatureBand));
            _tempDirPath           = tempDirPath ?? (string.IsNullOrWhiteSpace(parseResult.ValueForOption <string>(WorkloadInstallCommandParser.TempDirOption)) ?
                                                     Path.GetTempPath() :
                                                     parseResult.ValueForOption <string>(WorkloadInstallCommandParser.TempDirOption));

            var configOption = parseResult.ValueForOption <string>(WorkloadInstallCommandParser.ConfigOption);
            var sourceOption = parseResult.ValueForOption <string[]>(WorkloadInstallCommandParser.SourceOption);

            _packageSourceLocation = string.IsNullOrEmpty(configOption) && (sourceOption == null || !sourceOption.Any()) ? null :
                                     new PackageSourceLocation(string.IsNullOrEmpty(configOption) ? null : new FilePath(configOption), sourceFeedOverrides: sourceOption);

            var sdkWorkloadManifestProvider = new SdkDirectoryWorkloadManifestProvider(_dotnetPath, _sdkVersion.ToString());

            _workloadResolver = workloadResolver ?? WorkloadResolver.Create(sdkWorkloadManifestProvider, _dotnetPath, _sdkVersion.ToString());
            var sdkFeatureBand      = new SdkFeatureBand(_sdkVersion);
            var tempPackagesDir     = new DirectoryPath(Path.Combine(_tempDirPath, "dotnet-sdk-advertising-temp"));
            var restoreActionConfig = _parseResult.ToRestoreActionConfig();

            _nugetPackageDownloader = nugetPackageDownloader ??
                                      new NuGetPackageDownloader(tempPackagesDir,
                                                                 filePermissionSetter: null,
                                                                 new FirstPartyNuGetPackageSigningVerifier(tempPackagesDir, _verbosity.VerbosityIsDetailedOrDiagnostic() ? new NuGetConsoleLogger() : new NullLogger()),
                                                                 _verbosity.VerbosityIsDetailedOrDiagnostic() ? new NuGetConsoleLogger() : new NullLogger(), restoreActionConfig: restoreActionConfig);
            _workloadInstaller = workloadInstaller ??
                                 WorkloadInstallerFactory.GetWorkloadInstaller(_reporter, sdkFeatureBand,
                                                                               _workloadResolver, _verbosity, _nugetPackageDownloader, _dotnetPath, _tempDirPath,
                                                                               _packageSourceLocation, restoreActionConfig, elevationRequired: !_printDownloadLinkOnly && string.IsNullOrWhiteSpace(_downloadToCacheOption));
            _userHome = userHome ?? CliFolderPathCalculator.DotnetHomePath;
            _workloadManifestUpdater = workloadManifestUpdater ?? new WorkloadManifestUpdater(_reporter, _workloadResolver, _nugetPackageDownloader, _userHome, _tempDirPath,
                                                                                              _workloadInstaller.GetWorkloadInstallationRecordRepository(), _packageSourceLocation);

            ValidateWorkloadIdsInput();
        }
Ejemplo n.º 22
0
        public WorkloadUpdateCommand(
            ParseResult parseResult,
            IReporter reporter = null,
            IWorkloadResolver workloadResolver               = null,
            IInstaller workloadInstaller                     = null,
            INuGetPackageDownloader nugetPackageDownloader   = null,
            IWorkloadManifestUpdater workloadManifestUpdater = null,
            string dotnetDir = null,
            string userHome  = null,
            string version   = null)
            : base(parseResult)
        {
            _printDownloadLinkOnly =
                parseResult.ValueForOption <bool>(WorkloadInstallCommandParser.PrintDownloadLinkOnlyOption);
            _fromCacheOption = parseResult.ValueForOption <string>(WorkloadInstallCommandParser.FromCacheOption);
            _reporter        = reporter ?? Reporter.Output;
            _includePreviews = parseResult.ValueForOption <bool>(WorkloadUpdateCommandParser.IncludePreviewsOption);
            _verbosity       = parseResult.ValueForOption <VerbosityOptions>(WorkloadUpdateCommandParser.VerbosityOption);
            _sdkVersion      = new ReleaseVersion(version ??
                                                  (string.IsNullOrWhiteSpace(parseResult.ValueForOption <string>(WorkloadUpdateCommandParser.SdkVersionOption)) ?
                                                   Product.Version : parseResult.ValueForOption <string>(WorkloadUpdateCommandParser.SdkVersionOption)));

            var dotnetPath = dotnetDir ?? Path.GetDirectoryName(Environment.ProcessPath);

            _workloadManifestProvider = new SdkDirectoryWorkloadManifestProvider(dotnetPath, _sdkVersion.ToString());
            _workloadResolver         = workloadResolver ?? WorkloadResolver.Create(_workloadManifestProvider, dotnetPath, _sdkVersion.ToString());
            var sdkFeatureBand = new SdkFeatureBand(_sdkVersion);

            _workloadInstaller = workloadInstaller ?? WorkloadInstallerFactory.GetWorkloadInstaller(_reporter, sdkFeatureBand, _workloadResolver, _verbosity, nugetPackageDownloader, dotnetDir);
            userHome           = userHome ?? CliFolderPathCalculator.DotnetHomePath;
            var tempPackagesDir = new DirectoryPath(Path.Combine(userHome, ".dotnet", "sdk-advertising-temp"));

            _nugetPackageDownloader  = nugetPackageDownloader ?? new NuGetPackageDownloader(tempPackagesDir, filePermissionSetter: null, new NullLogger());
            _workloadManifestUpdater = workloadManifestUpdater ?? new WorkloadManifestUpdater(_reporter, _workloadManifestProvider, _nugetPackageDownloader, userHome);
        }
Ejemplo n.º 23
0
        public void ToStringReturnsExpectedNumberOfFields(string version, int fieldCount, string expectedValue)
        {
            ReleaseVersion v = new ReleaseVersion(version);

            Assert.Equal(expectedValue, v.ToString(fieldCount));
        }