|
1 | 1 |
|
2 | 2 | param( |
3 | 3 | [ValidateSet("Debug", "Release")] |
4 | | - [string]$Configuration = "Debug", |
5 | | - |
6 | | - [string[]]$ModuleName = @("Microsoft.PowerShell.ConsoleGuiTools" ) |
| 4 | + [string]$Configuration = "Debug" |
7 | 5 | ) |
8 | 6 |
|
9 | | -$script:TargetFramework = "net6.0" |
10 | | - |
11 | | -$script:ModuleLayouts = @{} |
12 | | -foreach ($mn in $ModuleName) { |
13 | | - $script:ModuleLayouts.$mn = Import-PowerShellDataFile -Path "$PSScriptRoot/src/$mn/ModuleLayout.psd1" |
14 | | -} |
15 | | - |
16 | 7 | task FindDotNet -Before Clean, Build { |
17 | | - Assert (Get-Command dotnet -ErrorAction SilentlyContinue) "dotnet not found, please install it: https://aka.ms/dotnet-cli" |
18 | | - |
19 | | - # Strip out semantic version metadata so it can be cast to `Version` |
20 | | - [Version]$existingVersion, $null = (dotnet --version) -split " " -split "-" |
21 | | - Assert ($existingVersion -ge [Version]("6.0")) ".NET SDK 6.0 or higher is required, please update it: https://aka.ms/dotnet-cli" |
22 | | - |
23 | | - Write-Host "Using dotnet v$(dotnet --version) at path $((Get-Command dotnet).Source)" -ForegroundColor Green |
24 | | -} |
25 | | - |
26 | | -task Build { |
27 | | - Remove-Item $PSScriptRoot/module -Recurse -Force -ErrorAction Ignore |
28 | | - |
29 | | - foreach ($moduleLayout in $script:ModuleLayouts.Values) { |
30 | | - foreach ($projName in $moduleLayout.RequiredBuildAssets.Keys) { |
31 | | - exec { & dotnet publish -c $Configuration "$PSScriptRoot/src/$projName/$projName.csproj" } |
32 | | - } |
33 | | - |
34 | | - foreach ($nativeProj in $moduleLayout.NativeBuildAssets.Keys) { |
35 | | - foreach ($targetPlatform in $moduleLayout.NativeBuildAssets[$nativeProj]) { |
36 | | - $buildPropertyParams = if ($targetPlatform -eq "win-x64") { |
37 | | - "/property:IsWindows=true" |
38 | | - } |
39 | | - else { |
40 | | - "/property:IsWindows=false" |
41 | | - } |
42 | | - exec { & dotnet publish -c $Configuration "$PSScriptRoot/src/$nativeProj/$nativeProj.csproj" -r $targetPlatform $buildPropertyParams } |
43 | | - } |
44 | | - } |
45 | | - } |
| 8 | + Assert (Get-Command dotnet -ErrorAction SilentlyContinue) "The dotnet CLI was not found, please install it: https://aka.ms/dotnet-cli" |
| 9 | + $DotnetVersion = dotnet --version |
| 10 | + Assert ($?) "The required .NET SDK was not found, please install it: https://aka.ms/dotnet-cli" |
| 11 | + Write-Host "Using dotnet $DotnetVersion at path $((Get-Command dotnet).Source)" -ForegroundColor Green |
46 | 12 | } |
47 | 13 |
|
48 | 14 | task Clean { |
49 | | - Remove-BuildItem $PSScriptRoot/module |
50 | | - |
51 | | - foreach ($moduleLayout in $script:ModuleLayouts.Values) { |
52 | | - foreach ($projName in $moduleLayout.RequiredBuildAssets.Keys) { |
53 | | - exec { & dotnet clean -c $Configuration "$PSScriptRoot/src/$projName/$projName.csproj" } |
54 | | - } |
55 | | - |
56 | | - foreach ($projName in $moduleLayout.NativeBuildAssets.Keys) { |
57 | | - exec { & dotnet clean -c $Configuration "$PSScriptRoot/src/$projName/$projName.csproj" } |
58 | | - } |
59 | | - } |
| 15 | + Remove-BuildItem ./module, ./out |
| 16 | + Push-Location src/Microsoft.PowerShell.ConsoleGuiTools |
| 17 | + Invoke-BuildExec { & dotnet clean } |
| 18 | + Pop-Location |
60 | 19 | } |
61 | 20 |
|
62 | | -task LayoutModule -After Build { |
63 | | - foreach ($mn in $ModuleName) { |
64 | | - $moduleLayout = $script:ModuleLayouts[$mn] |
65 | | - $moduleBinPath = "$PSScriptRoot/module/$mn/" |
66 | | - |
67 | | - # Create the destination dir |
68 | | - $null = New-Item -Force $moduleBinPath -Type Directory |
69 | | - |
70 | | - # For each subproject |
71 | | - foreach ($projectName in $moduleLayout.RequiredBuildAssets.Keys) { |
72 | | - # Get the project build dir path |
73 | | - $basePath = [System.IO.Path]::Combine($PSScriptRoot, 'src', $projectName, 'bin', $Configuration, $script:TargetFramework) |
74 | | - |
75 | | - # For each asset in the subproject |
76 | | - foreach ($bin in $moduleLayout.RequiredBuildAssets[$projectName]) { |
77 | | - # Get the asset path |
78 | | - $binPath = Join-Path $basePath $bin |
79 | | - |
80 | | - # Binplace the asset |
81 | | - Copy-Item -Force -Verbose $binPath $moduleBinPath |
82 | | - } |
83 | | - } |
84 | | - |
85 | | - foreach ($projectName in $moduleLayout.NativeBuildAssets.Keys) { |
86 | | - foreach ($targetPlatform in $moduleLayout.NativeBuildAssets[$projectName]) { |
87 | | - $destDir = Join-Path $moduleBinPath $projectName $targetPlatform |
88 | | - |
89 | | - $null = New-Item -Force $destDir -Type Directory |
90 | | - |
91 | | - # Get the project build dir path |
92 | | - $publishPath = [System.IO.Path]::Combine($PSScriptRoot, 'src', $projectName, 'bin', $Configuration, $script:TargetFramework, $targetPlatform, "publish\*" ) |
93 | | - |
94 | | - Write-Host $publishPath |
95 | | - # Binplace the asset |
96 | | - Copy-Item -Recurse -Force $publishPath $destDir |
97 | | - } |
98 | | - } |
99 | | - |
100 | | - Copy-Item -Force "$PSScriptRoot/README.md" $moduleBinPath |
101 | | - Copy-Item -Force "$PSScriptRoot/LICENSE.txt" $moduleBinPath |
| 21 | +task Build { |
| 22 | + New-Item -ItemType Directory -Force ./module | Out-Null |
| 23 | + |
| 24 | + Push-Location src/Microsoft.PowerShell.ConsoleGuiTools |
| 25 | + Invoke-BuildExec { & dotnet publish --configuration $Configuration --output publish } |
| 26 | + $Assets = $( |
| 27 | + "../../README.md", |
| 28 | + "../../LICENSE.txt", |
| 29 | + "./publish/Microsoft.PowerShell.ConsoleGuiTools.dll", |
| 30 | + "./publish/Microsoft.PowerShell.ConsoleGuiTools.psd1", |
| 31 | + "./publish/Microsoft.PowerShell.OutGridView.Models.dll", |
| 32 | + "./publish/Terminal.Gui.dll", |
| 33 | + "./publish/NStack.dll") |
| 34 | + $Assets | ForEach-Object { |
| 35 | + Copy-Item -Force -Path $_ -Destination ../../module |
102 | 36 | } |
| 37 | + Pop-Location |
| 38 | + |
| 39 | + New-ExternalHelp -Path docs/Microsoft.PowerShell.ConsoleGuiTools -OutputPath module/en-US -Force |
103 | 40 | } |
104 | 41 |
|
105 | | -task BuildCmdletHelp { |
106 | | - foreach ($mn in $ModuleName) { |
107 | | - New-ExternalHelp -Path "$PSScriptRoot/docs/$mn" -OutputPath "$PSScriptRoot/module/$mn/en-US" -Force |
| 42 | +task Package { |
| 43 | + New-Item -ItemType Directory -Force ./out | Out-Null |
| 44 | + if (-Not (Get-PSResourceRepository -Name ConsoleGuiTools -ErrorAction SilentlyContinue)) { |
| 45 | + Register-PSResourceRepository -Name ConsoleGuiTools -Uri ./out |
108 | 46 | } |
| 47 | + Publish-PSResource -Path ./module -Repository ConsoleGuiTools -Verbose |
109 | 48 | } |
110 | 49 |
|
111 | | -task . Clean, Build, BuildCmdletHelp |
| 50 | +task . Clean, Build |
0 commit comments