mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-24 12:35:31 +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";
|
private const string InnoSetupInstallerUrl = "http://www.jrsoftware.org/download.php/is.exe";
|
||||||
|
|
||||||
public string Name => "Inno Setup";
|
public string Name => "Inno Setup";
|
||||||
|
public bool ShouldInstallByDefault => true;
|
||||||
|
|
||||||
|
public string OtherDependencysThatAreMissing
|
||||||
|
{
|
||||||
|
get { return Name; }
|
||||||
|
}
|
||||||
|
|
||||||
private readonly IInnoSetupService _innoSetupService;
|
private readonly IInnoSetupService _innoSetupService;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,28 @@ namespace Cosmos.Build.Builder.Dependencies
|
||||||
internal class ReposDependency : IDependency
|
internal class ReposDependency : IDependency
|
||||||
{
|
{
|
||||||
public string Name => "Repos: IL2CPU, XSharp and Common";
|
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 string _cosmosDir;
|
||||||
private readonly IEnumerable<Repo> _repos;
|
private readonly IEnumerable<Repo> _repos;
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,16 @@ namespace Cosmos.Build.Builder.Dependencies
|
||||||
internal class VisualStudioDependency : IDependency
|
internal class VisualStudioDependency : IDependency
|
||||||
{
|
{
|
||||||
private static readonly Version MinimumVsVersion = new Version(15, 9);
|
private static readonly Version MinimumVsVersion = new Version(15, 9);
|
||||||
|
public bool ShouldInstallByDefault => true;
|
||||||
public string Name => $"Visual Studio {MinimumVsVersion.Major}.{MinimumVsVersion.Minor}+";
|
public string Name => $"Visual Studio {MinimumVsVersion.Major}.{MinimumVsVersion.Minor}+";
|
||||||
|
public string OtherDependencysThatAreMissing
|
||||||
|
{
|
||||||
|
get { return Name+"+"; }
|
||||||
|
}
|
||||||
|
|
||||||
private readonly ISetupInstance2 _visualStudioInstance;
|
private readonly ISetupInstance2 _visualStudioInstance;
|
||||||
|
|
||||||
|
|
||||||
public VisualStudioDependency(ISetupInstance2 visualStudioInstance)
|
public VisualStudioDependency(ISetupInstance2 visualStudioInstance)
|
||||||
{
|
{
|
||||||
_visualStudioInstance = visualStudioInstance;
|
_visualStudioInstance = visualStudioInstance;
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,33 @@ namespace Cosmos.Build.Builder.Dependencies
|
||||||
NetCoreToolsWorkload,
|
NetCoreToolsWorkload,
|
||||||
VisualStudioExtensionsWorkload
|
VisualStudioExtensionsWorkload
|
||||||
};
|
};
|
||||||
|
public bool ShouldInstallByDefault => false;
|
||||||
public string Name => "Visual Studio Workloads";
|
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;
|
private readonly ISetupInstance2 _visualStudioInstance;
|
||||||
|
|
||||||
public VisualStudioWorkloadsDependency(ISetupInstance2 visualStudioInstance)
|
public VisualStudioWorkloadsDependency(ISetupInstance2 visualStudioInstance)
|
||||||
|
|
@ -32,7 +56,19 @@ namespace Cosmos.Build.Builder.Dependencies
|
||||||
var installedPackages = _visualStudioInstance.GetPackages();
|
var installedPackages = _visualStudioInstance.GetPackages();
|
||||||
return Task.FromResult(RequiredPackages.All(p => IsPackageInstalled(p)));
|
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)
|
public async Task InstallAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var vsInstallerPath = Environment.ExpandEnvironmentVariables(
|
var vsInstallerPath = Environment.ExpandEnvironmentVariables(
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,9 @@ namespace Cosmos.Build.Builder
|
||||||
internal interface IDependency
|
internal interface IDependency
|
||||||
{
|
{
|
||||||
string Name { get; }
|
string Name { get; }
|
||||||
|
bool ShouldInstallByDefault { get; }
|
||||||
|
|
||||||
|
string OtherDependencysThatAreMissing { get; }
|
||||||
Task<bool> IsInstalledAsync(CancellationToken cancellationToken);
|
Task<bool> IsInstalledAsync(CancellationToken cancellationToken);
|
||||||
Task InstallAsync(CancellationToken cancellationToken);
|
Task InstallAsync(CancellationToken cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -107,8 +107,10 @@ namespace Cosmos.Build.Builder.ViewModels
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_logger.LogMessage($"{dependency.Name} not found.");
|
_logger.LogMessage($"{dependency.Name} not found. Install {dependency.OtherDependencysThatAreMissing}");
|
||||||
|
|
||||||
|
if (dependency.ShouldInstallByDefault)
|
||||||
|
{
|
||||||
using (var viewModel = new DependencyInstallationDialogViewModel(dependency))
|
using (var viewModel = new DependencyInstallationDialogViewModel(dependency))
|
||||||
{
|
{
|
||||||
_dependencyInstallationDialogService.ShowDialog(viewModel);
|
_dependencyInstallationDialogService.ShowDialog(viewModel);
|
||||||
|
|
@ -119,6 +121,16 @@ namespace Cosmos.Build.Builder.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var buildTask in _buildDefinition.GetBuildTasks())
|
foreach (var buildTask in _buildDefinition.GetBuildTasks())
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue