diff --git a/build.cmd b/build.cmd index 242094145..70fd58c7f 100644 --- a/build.cmd +++ b/build.cmd @@ -1,4 +1,4 @@ @echo off -powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0scripts\build_demo.ps1"""" +powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0build.ps1"""" @REM powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0scripts\build_extension.ps1"""" -exit /b %ErrorLevel% \ No newline at end of file +exit /b %ErrorLevel% diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 000000000..de2b25257 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,36 @@ +$wingetVersion = & winget --version 2>$null + +if ($wingetVersion -eq $null) { + Write-Output "winget is not installed. Starting installation..." + + Invoke-WebRequest -Uri "https://github.com/microsoft/winget-cli/releases/download/v1.6.3482/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -OutFile "$env:TEMP\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" + + Add-AppxPackage -Path "$env:TEMP\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" + + Write-Output "winget has been installed." +} + +$dotnetVersion = & dotnet --version 2>$null + +if ($dotnetVersion -eq $null) { + Write-Output ".NET SDK is not installed." + + winget install Microsoft.DotNet.SDK.8 +} else { + $majorVersion = $dotnetVersion.Split('.')[0] + + if ($majorVersion -ge 8) { + Write-Output ".NET SDK version is $dotnetVersion, which is 8.0.0 or newer." + } else { + Write-Output ".NET SDK version is $dotnetVersion, which is older than 8.0.0." + + winget install Microsoft.DotNet.SDK.8 + } +} + +if ($env:PROCESSOR_ARCHITECTURE -eq "AMD64") { + dotnet restore Wpf.Ui.sln /tl + dotnet build src\Wpf.Ui.Gallery\Wpf.Ui.Gallery.csproj --configuration Release --no-restore --verbosity quiet /tl +} else { + Write-Host "Not in the x64 desktop environment." +} diff --git a/etc/build_demo.ps1 b/etc/build_demo.ps1 deleted file mode 100644 index 537322dac..000000000 --- a/etc/build_demo.ps1 +++ /dev/null @@ -1 +0,0 @@ -. $PSScriptRoot\dotnet_build.ps1 -restore -build -solution Wpf.Ui.Demo.sln \ No newline at end of file diff --git a/etc/build_extension.ps1 b/etc/build_extension.ps1 deleted file mode 100644 index c1cc56708..000000000 --- a/etc/build_extension.ps1 +++ /dev/null @@ -1 +0,0 @@ -. $PSScriptRoot\msbuild_build.ps1 -restore -build -solution Wpf.Ui.Extension.sln \ No newline at end of file diff --git a/etc/build_library.ps1 b/etc/build_library.ps1 deleted file mode 100644 index bb7aa2fb8..000000000 --- a/etc/build_library.ps1 +++ /dev/null @@ -1 +0,0 @@ -. $PSScriptRoot\dotnet_build.ps1 -restore -build -solution Wpf.Ui.sln \ No newline at end of file diff --git a/etc/dotnet_build.ps1 b/etc/dotnet_build.ps1 deleted file mode 100644 index 035fca836..000000000 --- a/etc/dotnet_build.ps1 +++ /dev/null @@ -1,127 +0,0 @@ -# Copyright 2022-2023 Leszek Pomianowski and WPF UI Contributors - -[CmdletBinding(PositionalBinding = $false)] -Param( - [string][Alias('c')]$configuration = "Release", - [string][Alias('v')]$verbosity = "minimal", - [string][Alias('p')]$platform = "AnyCPU", - [string][Alias('s')]$solution = "", - [switch][Alias('r')]$restore, - [switch][Alias('b')]$build, - [switch] $nologo, - [switch] $help, - [Parameter(ValueFromRemainingArguments = $true)][String[]]$properties -) - -$Script:BuildPath = "" - -function Invoke-Help { - Write-Host "Common settings:" - Write-Host " -configuration Build configuration: 'Debug' or 'Release' (short: -c)" - Write-Host " -platform Platform configuration: 'x86', 'x64' or any valid Platform value to pass to msbuild" - Write-Host " -verbosity Msbuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic] (short: -v)" - Write-Host " -nologo Doesn't display the startup banner or the copyright message" - Write-Host " -help Print help and exit" - Write-Host "" - - Write-Host "Actions:" - Write-Host " -restore Restore dependencies (short: -r)" - Write-Host " -build Build solution (short: -b)" - Write-Host "" -} - -function Invoke-Hello { - if ($nologo) { - return - } - - $TextInfo = (Get-Culture).TextInfo - - Write-Host " -------------------" -ForegroundColor Cyan - Write-Host "| " -NoNewline -ForegroundColor Cyan - Write-Host " WPF UI" -NoNewline -ForegroundColor White - Write-Host " | "-ForegroundColor Cyan - Write-Host "| " -NoNewline -ForegroundColor Cyan - Write-Host " lepo.co 2021-$(Get-Date -UFormat "%Y")" -NoNewline -ForegroundColor Gray - Write-Host " | " -ForegroundColor Cyan - Write-Host " ------------------ - " -ForegroundColor Cyan - Write-Host "" - Write-Host "Solution: " -NoNewline - Write-Host "$($Script:Solution)" -ForegroundColor Cyan - Write-Host "Platform: " -NoNewline - Write-Host "$($TextInfo.ToTitleCase($platform))" -ForegroundColor Cyan - Write-Host "Configuration: " -NoNewline - Write-Host "$($TextInfo.ToTitleCase($configuration))" -ForegroundColor Cyan - Write-Host "Verbosity: " -NoNewline - Write-Host "$($TextInfo.ToTitleCase($verbosity))" -ForegroundColor Cyan - Write-Host "" -} - -function Invoke-ExitWithExitCode([int] $exitCode) { - if ($ci -and $prepareMachine) { - Stop-Processes - } - - exit $exitCode -} - -function Initialize-Script { - - if ((Test-Path "$($PSScriptRoot)\..\src\$($solution)") -eq $False) { - Write-Host "Solution $($PSScriptRoot)\..\src\$($solution) not found" -ForegroundColor Red - Invoke-ExitWithExitCode 1 - } - - $Script:BuildPath = (Resolve-Path -Path "$($PSScriptRoot)\..\src\$($solution)").ToString() -} - -function Initialize-Toolset { - -} - -function Invoke-Restore { - if (-not $restore) { - return - } - - dotnet restore $Script:BuildPath --verbosity $verbosity - - if ($lastExitCode -ne 0) { - Write-Host "Restore failed" -ForegroundColor Red - - Invoke-ExitWithExitCode $LastExitCode - } -} - -function Invoke-Build { - if (-not $build) { - return - } - - dotnet build $Script:BuildPath --configuration $configuration --verbosity $verbosity --no-restore --nologo - - if ($lastExitCode -ne 0) { - Write-Host "Build failed" -ForegroundColor Red - Invoke-ExitWithExitCode $LastExitCode - } -} - -if ($help) { - Invoke-Help - - exit 0 -} - -[timespan]$execTime = Measure-Command { - Invoke-Hello | Out-Default - Initialize-Script | Out-Default - Initialize-Toolset | Out-Default - Invoke-Restore | Out-Default - Invoke-Build | Out-Default -} - -Write-Host "Finished in " -NoNewline -Write-Host "$($execTime.Minutes) min $($execTime.Seconds),$($execTime.Milliseconds) s." -ForegroundColor Cyan - -Write-Host "Finished at " -NoNewline -Write-Host "$(Get-Date -UFormat "%d.%m.%Y %R")" -ForegroundColor Cyan \ No newline at end of file diff --git a/etc/msbuild_build.ps1 b/etc/msbuild_build.ps1 deleted file mode 100644 index b1fc458e8..000000000 --- a/etc/msbuild_build.ps1 +++ /dev/null @@ -1,158 +0,0 @@ -# Copyright 2022 Leszek Pomianowski and WPF UI Contributors - -[CmdletBinding(PositionalBinding = $false)] -Param( - [string][Alias('c')]$configuration = "Release", - [string][Alias('v')]$verbosity = "minimal", - [string][Alias('p')]$platform = "AnyCPU", - [string][Alias('s')]$solution = "", - [switch][Alias('r')]$restore, - [switch][Alias('b')]$build, - [switch] $nologo, - [switch] $help, - [Parameter(ValueFromRemainingArguments = $true)][String[]]$properties -) - -$Script:BuildPath = "" -$Script:VsPath = "" - -function Invoke-Help { - Write-Host "Common settings:" - Write-Host " -configuration Build configuration: 'Debug' or 'Release' (short: -c)" - Write-Host " -platform Platform configuration: 'x86', 'x64' or any valid Platform value to pass to msbuild" - Write-Host " -verbosity Msbuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic] (short: -v)" - Write-Host " -nologo Doesn't display the startup banner or the copyright message" - Write-Host " -help Print help and exit" - Write-Host "" - - Write-Host "Actions:" - Write-Host " -restore Restore dependencies (short: -r)" - Write-Host " -build Build solution (short: -b)" - Write-Host "" -} - -function Invoke-Hello { - if ($nologo) { - return - } - - $TextInfo = (Get-Culture).TextInfo - - Write-Host " -------------------" -ForegroundColor Cyan - Write-Host "| " -NoNewline -ForegroundColor Cyan - Write-Host " WPF UI" -NoNewline -ForegroundColor White - Write-Host " | "-ForegroundColor Cyan - Write-Host "| " -NoNewline -ForegroundColor Cyan - Write-Host " lepo.co 2021-$(Get-Date -UFormat "%Y")" -NoNewline -ForegroundColor Gray - Write-Host " | " -ForegroundColor Cyan - Write-Host " ------------------ - " -ForegroundColor Cyan - Write-Host "" - Write-Host "Solution: " -NoNewline - Write-Host "$($Script:Solution)" -ForegroundColor Cyan - Write-Host "Platform: " -NoNewline - Write-Host "$($TextInfo.ToTitleCase($platform))" -ForegroundColor Cyan - Write-Host "Configuration: " -NoNewline - Write-Host "$($TextInfo.ToTitleCase($configuration))" -ForegroundColor Cyan - Write-Host "Verbosity: " -NoNewline - Write-Host "$($TextInfo.ToTitleCase($verbosity))" -ForegroundColor Cyan - Write-Host "" -} - -function Invoke-ExitWithExitCode([int] $exitCode) { - if ($ci -and $prepareMachine) { - Stop-Processes - } - - exit $exitCode -} - -function Initialize-Script { - - if ((Test-Path "$($PSScriptRoot)\..\src\$($solution)") -eq $False) { - Write-Host "Solution $($PSScriptRoot)\..\src\$($solution) not found" -ForegroundColor Red - Invoke-ExitWithExitCode 1 - } - - $Script:BuildPath = (Resolve-Path -Path "$($PSScriptRoot)\..\src\$($solution)").ToString() -} - -function Initialize-VisualStudio { - - if ((Test-Path "C:\Program Files\Microsoft Visual Studio\2022\Community\Msbuild\Current\Bin") -ne $False) { - $Script:VsPath = "C:\Program Files\Microsoft Visual Studio\2022\Community\Msbuild\Current\Bin\"; - } - elseif ((Test-Path "C:\Program Files\Microsoft Visual Studio\2022\Preview\Msbuild\Current\Bin") -ne $False) { - $Script:VsPath = "C:\Program Files\Microsoft Visual Studio\2022\Preview\Msbuild\Current\Bin\"; - } - elseif ((Test-Path "C:\Program Files\Microsoft Visual Studio\2022\Professional\Msbuild\Current\Bin") -ne $False) { - $Script:VsPath = "C:\Program Files\Microsoft Visual Studio\2022\Professional\Msbuild\Current\Bin\"; - } - elseif ((Test-Path "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Msbuild\Current\Bin") -ne $False) { - $Script:VsPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Msbuild\Current\Bin\"; - } - elseif ((Test-Path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Msbuild\Current\Bin") -ne $False) { - $Script:VsPath = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Msbuild\Current\Bin\"; - } - elseif ((Test-Path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Msbuild\Current\Bin") -ne $False) { - $Script:VsPath = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Msbuild\Current\Bin\"; - } - elseif ((Test-Path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Msbuild\Current\Bin") -ne $False) { - $Script:VsPath = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Msbuild\Current\Bin\"; - } - elseif ((Test-Path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Msbuild\Current\Bin") -ne $False) { - $Script:VsPath = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Msbuild\Current\Bin\"; - } - else { - Write-Host "Visual Studio 2022 or 2019 not found." -ForegroundColor Red - Invoke-ExitWithExitCode 1 - } -} - -function Invoke-Build { - if (-not $build) { - return - } - - $msBuild = "$($Script:VsPath)MSBuild.exe" - - if ($platform.ToLower() -eq "anycpu") { - $platform = "Any CPU" - } - - if ($restore) { - & $msBuild $Script:BuildPath ` - /target:Clean ` - /target:Build ` - /p:Configuration=$configuration ` - /p:Platform="$($platform)" ` - --verbosity:$verbosity ` - --restore - } - else { - & $msBuild $Script:BuildPath ` - /target:Clean ` - /target:Build ` - /p:Configuration=$configuration ` - /p:Platform="$($platform)" ` - --verbosity:$verbosity - } -} - -if ($help) { - Invoke-Help - - exit 0 -} - -[timespan]$execTime = Measure-Command { - Invoke-Hello | Out-Default - Initialize-Script | Out-Default - Initialize-VisualStudio | Out-Default - Invoke-Build | Out-Default -} - -Write-Host "Finished in " -NoNewline -Write-Host "$($execTime.Minutes) min $($execTime.Seconds),$($execTime.Milliseconds) s." -ForegroundColor Cyan - -Write-Host "Finished at " -NoNewline -Write-Host "$(Get-Date -UFormat "%d.%m.%Y %R")" -ForegroundColor Cyan \ No newline at end of file