public static IInstaller GetWorkloadInstaller( IReporter reporter, SdkFeatureBand sdkFeatureBand, IWorkloadResolver workloadResolver, VerbosityOptions verbosity, string userProfileDir, bool verifySignatures, INuGetPackageDownloader nugetPackageDownloader = null, string dotnetDir = null, string tempDirPath = null, PackageSourceLocation packageSourceLocation = null, RestoreActionConfig restoreActionConfig = null, bool elevationRequired = true) { dotnetDir = string.IsNullOrWhiteSpace(dotnetDir) ? Path.GetDirectoryName(Environment.ProcessPath) : dotnetDir; var installType = GetWorkloadInstallType(sdkFeatureBand, dotnetDir); if (installType == InstallType.Msi) { if (!OperatingSystem.IsWindows()) { throw new InvalidOperationException(LocalizableStrings.OSDoesNotSupportMsi); } return(NetSdkMsiInstallerClient.Create(verifySignatures, sdkFeatureBand, workloadResolver, nugetPackageDownloader, verbosity, packageSourceLocation, reporter, tempDirPath)); } if (elevationRequired && !WorkloadFileBasedInstall.IsUserLocal(dotnetDir, sdkFeatureBand.ToString()) && !CanWriteToDotnetRoot(dotnetDir)) { throw new GracefulException(LocalizableStrings.InadequatePermissions, isUserError: false); } userProfileDir ??= CliFolderPathCalculator.DotnetUserProfileFolderPath; return(new FileBasedInstaller(reporter, sdkFeatureBand, workloadResolver, userProfileDir, nugetPackageDownloader, dotnetDir: dotnetDir, tempDirPath: tempDirPath, verbosity: verbosity, packageSourceLocation: packageSourceLocation, restoreActionConfig: restoreActionConfig)); }
public static IInstaller GetWorkloadInstaller( IReporter reporter, SdkFeatureBand sdkFeatureBand, IWorkloadResolver workloadResolver, VerbosityOptions verbosity, INuGetPackageDownloader nugetPackageDownloader = null, string dotnetDir = null, string tempDirPath = null, PackageSourceLocation packageSourceLocation = null, RestoreActionConfig restoreActionConfig = null, bool elevationRequired = true) { var installType = GetWorkloadInstallType(sdkFeatureBand, string.IsNullOrWhiteSpace(dotnetDir) ? Path.GetDirectoryName(Environment.ProcessPath) : dotnetDir); if (installType == InstallType.Msi) { if (!OperatingSystem.IsWindows()) { throw new InvalidOperationException(LocalizableStrings.OSDoesNotSupportMsi); } return(NetSdkMsiInstallerClient.Create(sdkFeatureBand, workloadResolver, nugetPackageDownloader, verbosity, packageSourceLocation, reporter, tempDirPath)); } if (elevationRequired && !CanWriteToDotnetRoot(dotnetDir)) { throw new GracefulException(LocalizableStrings.InadequatePermissions); } return(new NetSdkManagedInstaller(reporter, sdkFeatureBand, workloadResolver, nugetPackageDownloader, dotnetDir: dotnetDir, tempDirPath: tempDirPath, verbosity: verbosity, packageSourceLocation: packageSourceLocation, restoreActionConfig: restoreActionConfig)); }