Show message on what exactly is missing

Show message on what exactly is missing
This commit is contained in:
MishaTY 2021-01-05 11:21:29 -05:00
parent 3f3d6ab5ef
commit 4af1b27e11
6 changed files with 69 additions and 2 deletions

View file

@ -16,6 +16,11 @@ namespace Cosmos.Build.Builder.Dependencies
public string Name => "Inno Setup";
public bool ShouldInstallByDefault => true;
public string OtherDependencysThatAreMissing
{
get { return Name; }
}
private readonly IInnoSetupService _innoSetupService;
public InnoSetupDependency(IInnoSetupService innoSetupService)

View file

@ -15,6 +15,27 @@ namespace Cosmos.Build.Builder.Dependencies
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;

View file

@ -11,6 +11,10 @@ namespace Cosmos.Build.Builder.Dependencies
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;

View file

@ -20,6 +20,30 @@ namespace Cosmos.Build.Builder.Dependencies
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(

View file

@ -8,6 +8,7 @@ namespace Cosmos.Build.Builder
string Name { get; }
bool ShouldInstallByDefault { get; }
string OtherDependencysThatAreMissing { get; }
Task<bool> IsInstalledAsync(CancellationToken cancellationToken);
Task InstallAsync(CancellationToken cancellationToken);
}

View file

@ -107,7 +107,7 @@ namespace Cosmos.Build.Builder.ViewModels
}
else
{
_logger.LogMessage($"{dependency.Name} not found.");
_logger.LogMessage($"{dependency.Name} not found. Install {dependency.OtherDependencysThatAreMissing}");
if (dependency.ShouldInstallByDefault)
{
@ -123,7 +123,7 @@ namespace Cosmos.Build.Builder.ViewModels
}
else
{
MessageBox.Show($"{dependency.Name} is not installed. Please install {dependency.Name}");
MessageBox.Show($"{dependency.Name} is not installed. Please install {dependency.OtherDependencysThatAreMissing}");
_logger.SetError();
_logger.NewSection("Error");
_logger.LogMessage($"{dependency.Name} not found.");