From da8314b308928d16689557d21f1af3f6b8031320 Mon Sep 17 00:00:00 2001 From: "chengfei.jin" Date: Thu, 23 Jul 2026 00:33:29 +0800 Subject: [PATCH] fix(minimax-docx): support .NET 8 project restore --- skills/minimax-docx/scripts/env_check.sh | 22 ++++++++++++++------- skills/minimax-docx/scripts/setup.ps1 | 23 ++++++++++------------ skills/minimax-docx/scripts/setup.sh | 25 ++++++++++++------------ 3 files changed, 37 insertions(+), 33 deletions(-) diff --git a/skills/minimax-docx/scripts/env_check.sh b/skills/minimax-docx/scripts/env_check.sh index 871317ca..85a529de 100755 --- a/skills/minimax-docx/scripts/env_check.sh +++ b/skills/minimax-docx/scripts/env_check.sh @@ -7,6 +7,7 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" DOTNET_DIR="$SCRIPT_DIR/dotnet" +CLI_PROJECT="$DOTNET_DIR/MiniMaxAIDocx.Cli/MiniMaxAIDocx.Cli.csproj" # Force English output for dotnet CLI export DOTNET_CLI_UI_LANGUAGE=en @@ -60,34 +61,41 @@ else fi # --- Critical: NuGet packages --- -if [ -d "$DOTNET_DIR" ]; then +if [ ! -d "$DOTNET_DIR" ]; then + printf "[FAIL] %-14s directory not found: %s\n" "project" "$DOTNET_DIR" + STATUS="NOT READY" +elif [ ! -f "$CLI_PROJECT" ]; then + printf "[FAIL] %-14s file not found: %s\n" "project" "$CLI_PROJECT" + STATUS="NOT READY" +else if [ -f "$DOTNET_DIR/MiniMaxAIDocx.Cli/bin/Debug/net10.0/MiniMaxAIDocx.Cli.dll" ] || \ [ -f "$DOTNET_DIR/MiniMaxAIDocx.Cli/bin/Debug/net8.0/MiniMaxAIDocx.Cli.dll" ]; then printf "[OK] %-14s built\n" "project" else # Try restore + build - if dotnet restore "$DOTNET_DIR" --verbosity quiet &>/dev/null; then + if restore_output=$(dotnet restore "$CLI_PROJECT" --verbosity quiet 2>&1); then printf "[OK] %-14s packages restored\n" "nuget" - if dotnet build "$DOTNET_DIR" --verbosity quiet --no-restore &>/dev/null; then + if build_output=$(dotnet build "$CLI_PROJECT" --verbosity quiet --no-restore 2>&1); then printf "[OK] %-14s build succeeded\n" "project" else - printf "[FAIL] %-14s build failed (run: dotnet build %s)\n" "project" "$DOTNET_DIR" + printf "[FAIL] %-14s build failed\n" "project" + printf '%s\n' "$build_output" | sed 's/^/ /' + echo " Retry: dotnet build \"$CLI_PROJECT\" --verbosity normal" STATUS="NOT READY" fi else printf "[FAIL] %-14s restore failed\n" "nuget" + printf '%s\n' "$restore_output" | sed 's/^/ /' echo "" echo " Common causes:" echo " - No internet access (NuGet needs to download packages)" echo " - Corporate proxy blocking nuget.org" echo " - SSL certificate issues (try: dotnet nuget list source)" + echo " Retry: dotnet restore \"$CLI_PROJECT\" --verbosity detailed" echo "" STATUS="NOT READY" fi fi -else - printf "[FAIL] %-14s directory not found: %s\n" "project" "$DOTNET_DIR" - STATUS="NOT READY" fi # --- Optional: pandoc --- diff --git a/skills/minimax-docx/scripts/setup.ps1 b/skills/minimax-docx/scripts/setup.ps1 index 86ac12a5..8876e85d 100644 --- a/skills/minimax-docx/scripts/setup.ps1 +++ b/skills/minimax-docx/scripts/setup.ps1 @@ -13,6 +13,7 @@ $ErrorActionPreference = "Stop" $ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path $ProjectDir = Split-Path -Parent $ScriptDir $DotnetDir = Join-Path $ScriptDir "dotnet" +$CliProject = Join-Path (Join-Path $DotnetDir "MiniMaxAIDocx.Cli") "MiniMaxAIDocx.Cli.csproj" $LogFile = Join-Path $ProjectDir ".setup.log" # --- Output Helpers --- @@ -200,11 +201,13 @@ if (-not (Test-Path $DotnetDir)) { Fail "Dotnet project directory not found: $DotnetDir" exit 1 } - -Push-Location $DotnetDir +if (-not (Test-Path $CliProject)) { + Fail "CLI project not found: $CliProject" + exit 1 +} Info "Restoring NuGet packages..." -$restoreResult = & dotnet restore --verbosity quiet 2>&1 +$restoreResult = & dotnet restore $CliProject --verbosity quiet 2>&1 if ($LASTEXITCODE -ne 0) { Fail "NuGet restore failed:" $restoreResult | ForEach-Object { Fail " $_" } @@ -212,24 +215,20 @@ if ($LASTEXITCODE -ne 0) { Fail " - No internet (NuGet needs to download packages)" Fail " - Corporate proxy/firewall blocking nuget.org" Fail " - Insufficient disk space" - Fail "Try: dotnet restore --verbosity detailed" - Pop-Location + Fail "Try: dotnet restore `"$CliProject`" --verbosity detailed" exit 1 } Log "NuGet packages restored" Info "Building project..." -$buildResult = & dotnet build --verbosity quiet --no-restore 2>&1 +$buildResult = & dotnet build $CliProject --verbosity quiet --no-restore 2>&1 if ($LASTEXITCODE -ne 0) { Fail "Build failed:" $buildResult | ForEach-Object { Fail " $_" } - Pop-Location exit 1 } Log "Project built successfully" -Pop-Location - # --- Verification --- if (-not $SkipVerify) { Step "Verification Test" @@ -237,10 +236,8 @@ if (-not $SkipVerify) { $testOutput = Join-Path $env:TEMP "minimax-docx-setup-test-$PID.docx" Info "Creating a test document..." - Push-Location $DotnetDir - $testResult = & dotnet run --project MiniMaxAIDocx.Cli -- create --type report --output $testOutput --title "Setup Test" 2>&1 + $testResult = & dotnet run --project $CliProject -- create --type report --output $testOutput --title "Setup Test" 2>&1 $testExitCode = $LASTEXITCODE - Pop-Location if ($testExitCode -eq 0 -and (Test-Path $testOutput)) { Log "Test document created: $testOutput" @@ -269,6 +266,6 @@ Write-Host " pandoc: $pandocInfo" Write-Host " Project: $DotnetDir" Write-Host "" Write-Host " Usage:" -Write-Host " dotnet run --project $DotnetDir\MiniMaxAIDocx.Cli -- create --type report --output my_report.docx" +Write-Host " dotnet run --project `"$CliProject`" -- create --type report --output my_report.docx" Write-Host "" Write-Host " Log file: $LogFile" diff --git a/skills/minimax-docx/scripts/setup.sh b/skills/minimax-docx/scripts/setup.sh index 2e4bccab..ca4cf65a 100755 --- a/skills/minimax-docx/scripts/setup.sh +++ b/skills/minimax-docx/scripts/setup.sh @@ -10,6 +10,7 @@ export DOTNET_CLI_UI_LANGUAGE=en SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" DOTNET_DIR="$SCRIPT_DIR/dotnet" +CLI_PROJECT="$DOTNET_DIR/MiniMaxAIDocx.Cli/MiniMaxAIDocx.Cli.csproj" LOG_FILE="$PROJECT_DIR/.setup.log" # --- Colors --- @@ -265,31 +266,31 @@ build_project() { fail "Dotnet project directory not found: $DOTNET_DIR" return 1 fi - - cd "$DOTNET_DIR" + if [ ! -f "$CLI_PROJECT" ]; then + fail "CLI project not found: $CLI_PROJECT" + return 1 + fi info "Restoring NuGet packages..." - if ! dotnet restore --verbosity quiet 2>>"$LOG_FILE"; then + if ! dotnet restore "$CLI_PROJECT" --verbosity quiet 2>>"$LOG_FILE"; then fail "NuGet restore failed. Check network and $LOG_FILE for details." fail "Common causes:" fail " - No internet access (NuGet needs to download packages)" fail " - Corporate proxy blocking nuget.org" fail " - Disk space insufficient" echo "" - fail "Try manually: cd $DOTNET_DIR && dotnet restore --verbosity detailed" + fail "Try manually: dotnet restore \"$CLI_PROJECT\" --verbosity detailed" return 1 fi log "NuGet packages restored" info "Building project..." - if ! dotnet build --verbosity quiet --no-restore 2>>"$LOG_FILE"; then + if ! dotnet build "$CLI_PROJECT" --verbosity quiet --no-restore 2>>"$LOG_FILE"; then fail "Build failed. Check $LOG_FILE for details." - fail "Try manually: cd $DOTNET_DIR && dotnet build --verbosity normal" + fail "Try manually: dotnet build \"$CLI_PROJECT\" --verbosity normal" return 1 fi log "Project built successfully" - - cd "$PROJECT_DIR" } # --- Shell Script Permissions --- @@ -410,7 +411,7 @@ verify_installation() { local test_output="/tmp/minimax-docx-setup-test-$$.docx" info "Creating a test document..." - if cd "$DOTNET_DIR" && dotnet run --project MiniMaxAIDocx.Cli -- create \ + if dotnet run --project "$CLI_PROJECT" -- create \ --type report --output "$test_output" --title "Setup Test" 2>>"$LOG_FILE"; then log "Test document created: $test_output" @@ -430,8 +431,6 @@ verify_installation() { fail "Test document creation failed. Check $LOG_FILE for details." return 1 fi - - cd "$PROJECT_DIR" } # --- Summary --- @@ -446,8 +445,8 @@ print_summary() { echo " Project: $DOTNET_DIR" echo "" echo " Usage:" - echo " dotnet run --project $DOTNET_DIR/MiniMaxAIDocx.Cli -- create --type report --output my_report.docx" - echo " bash $SCRIPT_DIR/env_check.sh # Quick environment check" + echo " dotnet run --project \"$CLI_PROJECT\" -- create --type report --output my_report.docx" + echo " bash \"$SCRIPT_DIR/env_check.sh\" # Quick environment check" echo "" echo " Log file: $LOG_FILE" }