mirror of
https://github.com/microsoft/mcp.git
synced 2026-11-04 12:01:31 +00:00
92 lines
2.6 KiB
PowerShell
92 lines
2.6 KiB
PowerShell
#!/bin/env pwsh
|
|
#Requires -Version 7
|
|
|
|
[CmdletBinding(DefaultParameterSetName='none')]
|
|
param(
|
|
[string] $ServerName,
|
|
[switch] $NoTrimmed,
|
|
[switch] $NoSelfContained,
|
|
[switch] $NoUsePaths,
|
|
[switch] $AllPlatforms,
|
|
[switch] $VerifyNpx,
|
|
[switch] $ReleaseBuild,
|
|
[switch] $IncludeNative
|
|
)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
. "$PSScriptRoot/../common/scripts/common.ps1"
|
|
$RepoRoot = $RepoRoot.Path.Replace('\', '/')
|
|
|
|
$buildOutputPath = "$RepoRoot/.work/build"
|
|
$packageOutputPath = "$RepoRoot/.work/packages_npm"
|
|
|
|
Remove-Item -Path $buildOutputPath -Recurse -Force -ErrorAction SilentlyContinue -ProgressAction SilentlyContinue
|
|
Remove-Item -Path $packageOutputPath -Recurse -Force -ErrorAction SilentlyContinue -ProgressAction SilentlyContinue
|
|
|
|
& "$RepoRoot/eng/scripts/New-BuildInfo.ps1" `
|
|
-ServerName $ServerName `
|
|
-PublishTarget none `
|
|
-BuildId 12345 `
|
|
-IncludeNative:$IncludeNative
|
|
|
|
$oses = $AllPlatforms ? @('linux', 'windows', 'macos') : $null
|
|
$architectures = $AllPlatforms ? @('x64', 'arm64') : $null
|
|
|
|
& "$RepoRoot/eng/scripts/Build-Code.ps1" `
|
|
-ServerName $ServerName `
|
|
-SelfContained:(!$NoSelfContained) `
|
|
-Trimmed:(!$NoTrimmed) `
|
|
-ReleaseBuild:$ReleaseBuild `
|
|
-OperatingSystems $oses `
|
|
-Architectures $architectures
|
|
|
|
if ($LastExitCode -ne 0) {
|
|
exit $LastExitCode
|
|
}
|
|
|
|
if ($IncludeNative) {
|
|
& "$RepoRoot/eng/scripts/Build-Code.ps1" `
|
|
-SelfContained:(!$NoSelfContained) `
|
|
-Trimmed:(!$NoTrimmed) `
|
|
-ReleaseBuild:$ReleaseBuild `
|
|
-OperatingSystems $oses `
|
|
-Architectures $architectures `
|
|
-Native
|
|
}
|
|
|
|
# build_info.json is initialized with all buildable platforms, native and not
|
|
# Trim the platform lists to only built platforms
|
|
$buildInfoPath = "$RepoRoot/.work/build_info.json"
|
|
$buildInfo = Get-Content $buildInfoPath -Raw | ConvertFrom-Json -AsHashtable
|
|
|
|
foreach($server in $buildInfo.servers) {
|
|
$built = @()
|
|
foreach($platform in $server.platforms) {
|
|
if (Test-Path "$buildOutputPath/$($platform.artifactPath)") {
|
|
$built += $platform
|
|
}
|
|
}
|
|
$server.platforms = $built
|
|
}
|
|
|
|
$buildInfo | ConvertTo-Json -Depth 10 | Set-Content -Path $buildInfoPath
|
|
|
|
& "$RepoRoot/eng/scripts/Pack-Npm.ps1" -UsePaths:(!$NoUsePaths)
|
|
|
|
if ($VerifyNpx -and !$NoUsePaths) {
|
|
$tgzFiles = Get-ChildItem -Path $packageOutputPath -Filter '*.tgz' -Recurse
|
|
| Where-Object { $_.Directory.Name -eq 'wrapper' }
|
|
|
|
foreach($tgzFile in $tgzFiles) {
|
|
Push-Location -Path $RepoRoot
|
|
try {
|
|
Invoke-LoggedCommand "npx -y clear-npx-cache"
|
|
Invoke-LoggedCommand "npx -y `"file://$tgzFile`" tools list"
|
|
}
|
|
finally {
|
|
Pop-Location
|
|
}
|
|
}
|
|
}
|