Skip to content

Commit

Permalink
Merge pull request #337 from unoplatform/restore-uno.sdk-required-by-…
Browse files Browse the repository at this point in the history
…solution

feat: Add parameter to allow passing Uno.SDK version required by solution
  • Loading branch information
jeromelaban authored Feb 7, 2025
2 parents 7156497 + 02b29df commit 3e6e39b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ jobs:
- manifest: 'manifests\uno.ui.manifest.json'
manifest_name: Test net8.0-browserwasm TFM
tool_params: '--tfm net8.0-browserwasm'
- manifest: 'manifests\uno.ui.manifest.json'
manifest_name: Test unoSdkVersion
tool_params: '--unoSdkVersion 5.6.19'
- manifest: 'manifests\uno.ui-preview-major.manifest.json'
manifest_name: Test default Uno template TFM's with net9
tool_params: '--tfm net9.0-android --tfm net9.0-ios --tfm net9.0-maccatalyst --tfm net9.0-windows10.0.19041 --tfm net9.0-browserwasm --tfm net9.0-desktop'
Expand Down
2 changes: 2 additions & 0 deletions UnoCheck/CheckCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public override async Task<int> ExecuteAsync(CommandContext context, CheckSettin
sharedState.SetEnvironmentVariable("DOTNET_FORCE", "true");
if (settings.CI)
sharedState.SetEnvironmentVariable("CI", "true");
if (!string.IsNullOrEmpty(settings.UnoSdkVersion))
sharedState.SetEnvironmentVariable("UnoSdkVersion", settings.UnoSdkVersion);
if (settings.Frameworks is { Length: > 0 })
settings.TargetPlatforms = ParseTfmsToTargetPlatforms(settings);
if (!string.IsNullOrEmpty(settings.Ide))
Expand Down
5 changes: 5 additions & 0 deletions UnoCheck/CheckSettings.Uno.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,10 @@ partial class CheckSettings
[Description(
@"This parameter skips some checks based on the IDE which is used to run the Uno.Check.")]
public string? Ide { get; set; }

[CommandOption("--unoSdkVersion <UNO_SDK_VERSION>")]
[Description(
@"Uno SDK Checkup will validate if provided Uno SDK version is installed.")]
public string? UnoSdkVersion { get; set; }
}
}
30 changes: 18 additions & 12 deletions UnoCheck/Checkups/UnoSdkCheckup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,34 @@ internal class UnoSdkCheckup : Checkup

public override async Task<DiagnosticResult> Examine(SharedState state)
{
state.TryGetState("unosdk", "unoSdkLatestVersion", out string unoSdkLatestVersion);
string unoSdkVersion;
if (state.TryGetEnvironmentVariable("UnoSdkVersion", out var version))
{
unoSdkVersion = version;
}
else
{
state.TryGetState("unosdk", "unoSdkLatestVersion", out unoSdkVersion);

unoSdkLatestVersion ??= (await NuGetHelper.GetLatestPackageVersionAsync("Uno.Sdk", ToolInfo.CurrentVersion.IsPrerelease)).ToString();
unoSdkVersion ??= (await NuGetHelper.GetLatestPackageVersionAsync("Uno.Sdk", ToolInfo.CurrentVersion.IsPrerelease)).ToString();
}

var defaultSettings = Settings.LoadDefaultSettings(root: null);

var packagesPath = SettingsUtility.GetGlobalPackagesFolder(defaultSettings);

if (Directory.Exists(Path.Combine(packagesPath, "uno.sdk", unoSdkLatestVersion)))
if (Directory.Exists(Path.Combine(packagesPath, "uno.sdk", unoSdkVersion)))
{
return DiagnosticResult.Ok(this);
}
else
{
state.ContributeState(this, "unoSdkLatestVersion", unoSdkLatestVersion);

return new DiagnosticResult(
Status.Error,
this,
$"Uno.Sdk {unoSdkLatestVersion} is not installed.",
new Suggestion($"Install Uno.Sdk {unoSdkLatestVersion}", new UnoSdkSolution()));
}
state.ContributeState(this, "unoSdkLatestVersion", unoSdkVersion);

return new DiagnosticResult(
Status.Error,
this,
$"Uno.Sdk {unoSdkVersion} is not installed.",
new Suggestion($"Install Uno.Sdk {unoSdkVersion}", new UnoSdkSolution()));
}
}
}

0 comments on commit 3e6e39b

Please sign in to comment.