From 8c4d9c9fcef87f0f1fa98c706cbd05ce9b6d8955 Mon Sep 17 00:00:00 2001 From: Przemyslaw Klys Date: Fri, 5 Apr 2024 10:36:19 +0200 Subject: [PATCH] Improvement for better binary handling in projects --- Private/Start-LibraryBuilding.ps1 | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Private/Start-LibraryBuilding.ps1 b/Private/Start-LibraryBuilding.ps1 index cb5994e..e918313 100644 --- a/Private/Start-LibraryBuilding.ps1 +++ b/Private/Start-LibraryBuilding.ps1 @@ -67,9 +67,26 @@ Write-Text "[-] Can't read $ModuleProjectFile file. Error: $($_.Exception.Message)" -Color Red return $false } + + if ($IsLinux) { + $OSVersion = 'Linux' + } elseif ($IsMacOS) { + $OSVersion = 'OSX' + } else { + $OSVersion = 'Windows' + } + $SupportedFrameworks = foreach ($PropertyGroup in $ProjectInformation.Project.PropertyGroup) { if ($PropertyGroup.TargetFrameworks) { - $PropertyGroup.TargetFrameworks -split ";" + if ($PropertyGroup.TargetFrameworks -is [array]) { + foreach ($Target in $PropertyGroup.TargetFrameworks) { + if ($Target.Condition -like "*$OSVersion*" -and $Target.'#text') { + $Target.'#text'.Trim() -split ";" + } + } + } else { + $PropertyGroup.TargetFrameworks -split ";" + } } elseif ($PropertyGroup.TargetFrameworkVersion) { throw "TargetFrameworkVersion is not supported. Please use TargetFrameworks/TargetFramework instead which may require different project profile." } elseIf ($PropertyGroup.TargetFramework) {