diff --git a/DotnetRuntimeBootstrapper/BootstrapperTask.cs b/DotnetRuntimeBootstrapper/BootstrapperTask.cs index e1b4d83..9de1c82 100644 --- a/DotnetRuntimeBootstrapper/BootstrapperTask.cs +++ b/DotnetRuntimeBootstrapper/BootstrapperTask.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Reflection; +using System.Runtime.InteropServices; using System.Text; using DotnetRuntimeBootstrapper.Utils.Extensions; using Microsoft.Build.Framework; @@ -15,6 +16,13 @@ public class BootstrapperTask : Task { private Version Version { get; } = Assembly.GetExecutingAssembly().GetName().Version; + public string? RuntimeIdentifier { get; init; } + + public bool IsWindowsTarget => + string.IsNullOrWhiteSpace(RuntimeIdentifier) + && RuntimeInformation.IsOSPlatform(OSPlatform.Windows) + || RuntimeIdentifier?.StartsWith("win", StringComparison.OrdinalIgnoreCase) == true; + [Required] public required string Variant { get; init; } @@ -130,10 +138,18 @@ private void InjectResources() public override bool Execute() { Log.LogMessage("Version: '{0}'.", Version); + Log.LogMessage("Runtime identifier: '{0}'.", RuntimeIdentifier); Log.LogMessage("Variant: '{0}'.", Variant); Log.LogMessage("Prompt required: '{0}'.", IsPromptRequired); Log.LogMessage("Target: '{0}'.", TargetFilePath); + // Currently only Windows is supported + if (!IsWindowsTarget) + { + Log.LogMessage("Target platform is not Windows. Boostrapper will not be created."); + return true; + } + ExtractAppHost(); InjectConfiguration(); InjectResources(); diff --git a/DotnetRuntimeBootstrapper/DotnetRuntimeBootstrapper.targets b/DotnetRuntimeBootstrapper/DotnetRuntimeBootstrapper.targets index 7a90e3a..95a1586 100644 --- a/DotnetRuntimeBootstrapper/DotnetRuntimeBootstrapper.targets +++ b/DotnetRuntimeBootstrapper/DotnetRuntimeBootstrapper.targets @@ -1,21 +1,8 @@ - - - - - - - - - + + @@ -26,13 +13,14 @@ + @@ -43,6 +31,7 @@