diff --git a/Application/BuildScripts/PreBuild.ps1 b/Application/BuildScripts/PreBuild.ps1 index 300f97e5..95a9935a 100644 --- a/Application/BuildScripts/PreBuild.ps1 +++ b/Application/BuildScripts/PreBuild.ps1 @@ -16,9 +16,35 @@ if (-not (Test-Path "$SolutionDir/WebfrontCore/wwwroot/lib/open-iconic/font/css/ (Get-Content "$SolutionDir/WebfrontCore/wwwroot/lib/open-iconic/font/css/open-iconic-bootstrap-override.scss") -replace '../fonts/', '/font/' | Set-Content "$SolutionDir/WebfrontCore/wwwroot/lib/open-iconic/font/css/open-iconic-bootstrap-override.scss" } +Write-Output "checking for Excubo.WebCompiler..." + +$toolExists = dotnet tool list -g | Where-Object { $_ -match "Excubo.WebCompiler" } + +if ($toolExists) { + $installedVersion = ($toolExists | Select-String -Pattern "Excubo.WebCompiler\s+(\d+\.\d+\.\d+)" -AllMatches).Matches.Groups[1].Value + $latestVersion = (Invoke-WebRequest -Uri "https://api.nuget.org/v3-flatcontainer/excubo.webcompiler/index.json" | ConvertFrom-Json).versions | Select-Object -Last 1 + + Write-Output "installed version: $installedVersion" + Write-Output "latest version: $latestVersion" + + if ([version]$latestVersion -gt [version]$installedVersion) { + Write-Output "updating Excubo.WebCompiler to version $latestVersion..." + try { + dotnet tool update Excubo.WebCompiler --global + } + catch { + Write-Output "failed to update Excubo.WebCompiler. Using existing version." + } + } else { + Write-Output "Excubo.WebCompiler is already up-to-date." + } +} else { + Write-Output "installing Excubo.WebCompiler..." + dotnet tool install Excubo.WebCompiler --global +} + Write-Output "compiling scss files" -dotnet tool install Excubo.WebCompiler --global webcompiler -r "$SolutionDir/WebfrontCore/wwwroot/css/src" -o WebfrontCore/wwwroot/css/ -m disable -z disable webcompiler "$SolutionDir/WebfrontCore/wwwroot/lib/open-iconic/font/css/open-iconic-bootstrap-override.scss" -o "$SolutionDir/WebfrontCore/wwwroot/css/" -m disable -z disable diff --git a/Application/BuildScripts/PreBuild.sh b/Application/BuildScripts/PreBuild.sh index 18765093..632fa7c1 100644 --- a/Application/BuildScripts/PreBuild.sh +++ b/Application/BuildScripts/PreBuild.sh @@ -20,9 +20,30 @@ if [ ! -f "$SolutionDir/WebfrontCore/wwwroot/lib/open-iconic/font/css/open-iconi sed -i 's#../fonts/#/font/#g' "$SolutionDir/WebfrontCore/wwwroot/lib/open-iconic/font/css/open-iconic-bootstrap-override.scss" fi -echo compiling scss files +echo "checking for Excubo.WebCompiler..." + +toolExists=$(dotnet tool list -g | grep "Excubo.WebCompiler") + +if [[ ! -z "$toolExists" ]]; then + installedVersion=$(echo "$toolExists" | grep -oE "Excubo.WebCompiler\s+(\d+\.\d+\.\d+)" | grep -oE "\d+\.\d+\.\d+") + latestVersion=$(curl -s "https://api.nuget.org/v3-flatcontainer/excubo.webcompiler/index.json" | jq -r '.versions | last') + + echo "installed version: $installedVersion" + echo "latest version: $latestVersion" + + if [[ "$latestVersion" != "$installedVersion" && "$(printf '%s\n%s' "$installedVersion" "$latestVersion" | sort -V | head -n 1)" == "$installedVersion" ]]; then + echo "updating Excubo.WebCompiler to version $latestVersion..." + dotnet tool update Excubo.WebCompiler --global || echo "failed to update Excubo.WebCompiler. Using existing version." + else + echo "Excubo.WebCompiler is already up-to-date." + fi +else + echo "installing Excubo.WebCompiler..." + dotnet tool install Excubo.WebCompiler --global +fi + +echo "compiling scss files" -dotnet tool install Excubo.WebCompiler --global webcompiler -r "$SolutionDir/WebfrontCore/wwwroot/css/src" -o "$SolutionDir/WebfrontCore/wwwroot/css/" -m disable -z disable webcompiler "$SolutionDir/WebfrontCore/wwwroot/lib/open-iconic/font/css/open-iconic-bootstrap-override.scss" -o "$SolutionDir/WebfrontCore/wwwroot/css/" -m disable -z disable