Skip to content

Commit 8bbfc8c

Browse files
committed
Add bash wrapper and fix MCP server URL encoding
Add build.sh wrapper: - Create bash script that calls Build.ps1 with pwsh - Pass all arguments correctly using "$@" - Auto-generate from Resources via generate-scripts Fix MCP server startup failure: - Use URL-safe Base64 encoding for MCP authentication secret - Replace / with _, + with -, remove trailing = - Prevents MapMcp() failure when secret contains URL-unsafe chars
1 parent 59cd32b commit 8bbfc8c

File tree

6 files changed

+23
-8
lines changed

6 files changed

+23
-8
lines changed

Build.ps1

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ if (-not $Interactive -or $BuildArgs)
9898
if ($needsBuild)
9999
{
100100
# Build is needed
101-
Write-Host "Rebuilding Build$ProductName..." -ForegroundColor Cyan
101+
Write-Host "Building Build$ProductName..." -ForegroundColor Cyan
102102
& dotnet build $projectPath
103103
if ($LASTEXITCODE -ne 0)
104104
{
@@ -121,11 +121,7 @@ if (-not $Interactive -or $BuildArgs)
121121
throw "Build succeeded but output DLL '$outputDll' not found."
122122
}
123123
}
124-
else
125-
{
126-
Write-Host "Build cache valid, skipping build." -ForegroundColor Green
127-
}
128-
124+
129125
# Run the project using dotnet exec (faster than dotnet run)
130126
if (-not $outputDll -or -not (Test-Path $outputDll))
131127
{

DockerBuild.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,8 @@ if (-not $BuildImage)
696696
# Generate 128-bit (16 byte) random secret for authentication
697697
$randomBytes = New-Object byte[] 16
698698
[Security.Cryptography.RandomNumberGenerator]::Fill($randomBytes)
699-
$mcpSecret = [Convert]::ToBase64String($randomBytes)
699+
# Use URL-safe Base64 encoding (replace / with _, + with -, remove =)
700+
$mcpSecret = [Convert]::ToBase64String($randomBytes).Replace('/', '_').Replace('+', '-').TrimEnd('=')
700701
Write-Host "Generated MCP authentication secret" -ForegroundColor Cyan
701702

702703
# Use the MCP server snapshot saved before cleanup

build.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
# *** DO NOT EDIT THIS FILE DIRECTLY ***
3+
# This file is auto-generated from src/PostSharp.Engineering.BuildTools/Resources/build.sh
4+
# Edit the source version, then run `./Build.ps1 generate-scripts` to regenerate this file.
5+
6+
# Wrapper script to call Build.ps1 with PowerShell
7+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8+
pwsh -File "$SCRIPT_DIR/Build.ps1" "$@"

src/PostSharp.Engineering.BuildTools/ContinuousIntegration/GenerateScriptsCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public static bool Execute( BuildContext context, CommonCommandSettings settings
2727
}
2828

2929
EmbeddedResourceHelper.ExtractScript( context, "Build.ps1", "" );
30+
EmbeddedResourceHelper.ExtractScript( context, "build.sh", "" );
3031

3132
// Docker.
3233
if ( product.UseDocker )

src/PostSharp.Engineering.BuildTools/Resources/DockerBuild.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,8 @@ if (-not $BuildImage)
696696
# Generate 128-bit (16 byte) random secret for authentication
697697
$randomBytes = New-Object byte[] 16
698698
[Security.Cryptography.RandomNumberGenerator]::Fill($randomBytes)
699-
$mcpSecret = [Convert]::ToBase64String($randomBytes)
699+
# Use URL-safe Base64 encoding (replace / with _, + with -, remove =)
700+
$mcpSecret = [Convert]::ToBase64String($randomBytes).Replace('/', '_').Replace('+', '-').TrimEnd('=')
700701
Write-Host "Generated MCP authentication secret" -ForegroundColor Cyan
701702

702703
# Use the MCP server snapshot saved before cleanup
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
# *** DO NOT EDIT THIS FILE DIRECTLY ***
3+
# This file is auto-generated from src/PostSharp.Engineering.BuildTools/Resources/build.sh
4+
# Edit the source version, then run `./Build.ps1 generate-scripts` to regenerate this file.
5+
6+
# Wrapper script to call Build.ps1 with PowerShell
7+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8+
pwsh -File "$SCRIPT_DIR/Build.ps1" "$@"

0 commit comments

Comments
 (0)