mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-20 12:58:39 +00:00
Merge pull request #1619 from MishaTY/master
Disable auto-install of workloads
This commit is contained in:
commit
86dfa0879f
6 changed files with 91 additions and 8 deletions
|
|
@ -14,6 +14,12 @@ namespace Cosmos.Build.Builder.Dependencies
|
|||
private const string InnoSetupInstallerUrl = "http://www.jrsoftware.org/download.php/is.exe";
|
||||
|
||||
public string Name => "Inno Setup";
|
||||
public bool ShouldInstallByDefault => true;
|
||||
|
||||
public string OtherDependencysThatAreMissing
|
||||
{
|
||||
get { return Name; }
|
||||
}
|
||||
|
||||
private readonly IInnoSetupService _innoSetupService;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,28 @@ namespace Cosmos.Build.Builder.Dependencies
|
|||
internal class ReposDependency : IDependency
|
||||
{
|
||||
public string Name => "Repos: IL2CPU, XSharp and Common";
|
||||
public bool ShouldInstallByDefault => true;
|
||||
|
||||
public string OtherDependencysThatAreMissing
|
||||
{
|
||||
get
|
||||
{
|
||||
string result = "";
|
||||
if (!Directory.Exists(Path.GetFullPath(Path.Combine(_cosmosDir, "..", "IL2CPU"))))
|
||||
{
|
||||
result += "IL2CPU Repo, ";
|
||||
}
|
||||
if (!Directory.Exists(Path.GetFullPath(Path.Combine(_cosmosDir, "..", "XSharp"))))
|
||||
{
|
||||
result += "XSharp Repo, ";
|
||||
}
|
||||
if (!Directory.Exists(Path.GetFullPath(Path.Combine(_cosmosDir, "..", "Common"))))
|
||||
{
|
||||
result += "Common Repo";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly string _cosmosDir;
|
||||
private readonly IEnumerable<Repo> _repos;
|
||||
|
|
|
|||
|
|
@ -9,11 +9,16 @@ namespace Cosmos.Build.Builder.Dependencies
|
|||
internal class VisualStudioDependency : IDependency
|
||||
{
|
||||
private static readonly Version MinimumVsVersion = new Version(15, 9);
|
||||
|
||||
public bool ShouldInstallByDefault => true;
|
||||
public string Name => $"Visual Studio {MinimumVsVersion.Major}.{MinimumVsVersion.Minor}+";
|
||||
public string OtherDependencysThatAreMissing
|
||||
{
|
||||
get { return Name+"+"; }
|
||||
}
|
||||
|
||||
private readonly ISetupInstance2 _visualStudioInstance;
|
||||
|
||||
|
||||
public VisualStudioDependency(ISetupInstance2 visualStudioInstance)
|
||||
{
|
||||
_visualStudioInstance = visualStudioInstance;
|
||||
|
|
|
|||
|
|
@ -17,9 +17,33 @@ namespace Cosmos.Build.Builder.Dependencies
|
|||
NetCoreToolsWorkload,
|
||||
VisualStudioExtensionsWorkload
|
||||
};
|
||||
|
||||
public bool ShouldInstallByDefault => false;
|
||||
public string Name => "Visual Studio Workloads";
|
||||
|
||||
public string OtherDependencysThatAreMissing
|
||||
{
|
||||
get
|
||||
{
|
||||
var missingPackages = ((string[])RequiredPackages.Clone()).ToList();
|
||||
foreach (var item in RequiredPackages)
|
||||
{
|
||||
if (IsPackageInstalled(item))
|
||||
{
|
||||
missingPackages.Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
//Add the missing packages together
|
||||
string missingPackages_proper = "";
|
||||
foreach (var item in missingPackages)
|
||||
{
|
||||
missingPackages_proper += GetProperName(item) + ", ";
|
||||
}
|
||||
|
||||
return missingPackages_proper;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly ISetupInstance2 _visualStudioInstance;
|
||||
|
||||
public VisualStudioWorkloadsDependency(ISetupInstance2 visualStudioInstance)
|
||||
|
|
@ -32,7 +56,19 @@ namespace Cosmos.Build.Builder.Dependencies
|
|||
var installedPackages = _visualStudioInstance.GetPackages();
|
||||
return Task.FromResult(RequiredPackages.All(p => IsPackageInstalled(p)));
|
||||
}
|
||||
private string GetProperName(string packageId)
|
||||
{
|
||||
if (packageId == NetCoreToolsWorkload)
|
||||
{
|
||||
return ".NET Core cross-platform development";
|
||||
}
|
||||
else if (packageId == VisualStudioExtensionsWorkload)
|
||||
{
|
||||
return "Visual Studio Extension development";
|
||||
}
|
||||
|
||||
return "Unknown Workload: " + packageId;
|
||||
}
|
||||
public async Task InstallAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var vsInstallerPath = Environment.ExpandEnvironmentVariables(
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@ namespace Cosmos.Build.Builder
|
|||
internal interface IDependency
|
||||
{
|
||||
string Name { get; }
|
||||
bool ShouldInstallByDefault { get; }
|
||||
|
||||
string OtherDependencysThatAreMissing { get; }
|
||||
Task<bool> IsInstalledAsync(CancellationToken cancellationToken);
|
||||
Task InstallAsync(CancellationToken cancellationToken);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,17 +107,29 @@ namespace Cosmos.Build.Builder.ViewModels
|
|||
}
|
||||
else
|
||||
{
|
||||
_logger.LogMessage($"{dependency.Name} not found.");
|
||||
_logger.LogMessage($"{dependency.Name} not found. Install {dependency.OtherDependencysThatAreMissing}");
|
||||
|
||||
using (var viewModel = new DependencyInstallationDialogViewModel(dependency))
|
||||
if (dependency.ShouldInstallByDefault)
|
||||
{
|
||||
_dependencyInstallationDialogService.ShowDialog(viewModel);
|
||||
|
||||
if (!viewModel.InstallationSucceeded)
|
||||
using (var viewModel = new DependencyInstallationDialogViewModel(dependency))
|
||||
{
|
||||
throw new Exception($"Dependency installation failed! Dependency name: {dependency.Name}");
|
||||
_dependencyInstallationDialogService.ShowDialog(viewModel);
|
||||
|
||||
if (!viewModel.InstallationSucceeded)
|
||||
{
|
||||
throw new Exception($"Dependency installation failed! Dependency name: {dependency.Name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show($"{dependency.Name} is not installed. Please install {dependency.OtherDependencysThatAreMissing}");
|
||||
_logger.SetError();
|
||||
_logger.NewSection("Error");
|
||||
_logger.LogMessage($"{dependency.Name} not found.");
|
||||
_logger.SetError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue