Removed Immediate.Apis, Added AOT Testing Scripts.
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
#!/bin/bash
|
||||
# AOT Build and Test Script for POP_OS/Linux
|
||||
# This script builds the Htmx.ApiDemo application with AOT compilation enabled
|
||||
# and runs the application to check for trimming issues
|
||||
|
||||
# Set error handling
|
||||
set -e
|
||||
|
||||
# Initialize flags
|
||||
RUN_ONLY=false
|
||||
BUILD_ONLY=false
|
||||
|
||||
# Parse command line arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--run-only)
|
||||
RUN_ONLY=true
|
||||
shift
|
||||
;;
|
||||
--build-only)
|
||||
BUILD_ONLY=true
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
echo "Usage: $0 [--run-only] [--build-only]"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Define paths
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
||||
API_DEMO_PROJECT="$PROJECT_ROOT/Htmx.ApiDemo"
|
||||
PUBLISH_PATH="$SCRIPT_DIR/Publish"
|
||||
|
||||
echo "========================================"
|
||||
echo "AOT Build and Test Script"
|
||||
echo "========================================"
|
||||
echo ""
|
||||
|
||||
if [ "$RUN_ONLY" = false ]; then
|
||||
echo "Starting AOT Build Process..."
|
||||
echo "Project Path: $API_DEMO_PROJECT"
|
||||
echo "Publish Path: $PUBLISH_PATH"
|
||||
echo ""
|
||||
|
||||
# Clean previous publish folder if it exists
|
||||
if [ -d "$PUBLISH_PATH" ]; then
|
||||
echo "Cleaning previous publish folder..."
|
||||
rm -rf "$PUBLISH_PATH"
|
||||
fi
|
||||
|
||||
# Create publish folder
|
||||
mkdir -p "$PUBLISH_PATH"
|
||||
|
||||
# Navigate to project directory
|
||||
cd "$API_DEMO_PROJECT" || exit 1
|
||||
|
||||
# Run dotnet publish with AOT enabled
|
||||
# PublishAot=true is already set in the .csproj
|
||||
# A Runtime Identifier (RID) is required for AOT compilation
|
||||
echo "Publishing with AOT compilation enabled (linux-x64)..."
|
||||
|
||||
if ! dotnet publish -c Release -r linux-x64 -o "$PUBLISH_PATH" \
|
||||
-p:DebugSymbols=false \
|
||||
-p:DebugType=none; then
|
||||
echo "Build failed!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "AOT build completed successfully!"
|
||||
echo ""
|
||||
|
||||
# Copy appsettings.Development.json over appsettings.json in the publish folder
|
||||
# so the AOT executable has the correct connection strings for local testing
|
||||
DEV_SETTINGS="$API_DEMO_PROJECT/appsettings.Development.json"
|
||||
PUBLISHED_SETTINGS="$PUBLISH_PATH/appsettings.json"
|
||||
if [ -f "$DEV_SETTINGS" ]; then
|
||||
echo "Copying appsettings.Development.json -> appsettings.json in publish folder..."
|
||||
cp -f "$DEV_SETTINGS" "$PUBLISHED_SETTINGS"
|
||||
echo "Done."
|
||||
echo ""
|
||||
else
|
||||
echo "Warning: appsettings.Development.json not found, skipping copy."
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$BUILD_ONLY" = false ]; then
|
||||
echo "Starting Application..."
|
||||
echo ""
|
||||
|
||||
# Find the executable
|
||||
EXECUTABLE=$(find "$PUBLISH_PATH" -type f -perm /u+x ! -name "*.so" ! -name "*.a" ! -name "*.o" | head -n 1)
|
||||
|
||||
if [ -z "$EXECUTABLE" ]; then
|
||||
echo "Executable not found in publish directory!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Running: $EXECUTABLE"
|
||||
echo "Press Ctrl+C to stop the application"
|
||||
echo ""
|
||||
|
||||
# cd into publish dir so appsettings.json is found relative to the executable
|
||||
cd "$PUBLISH_PATH" || exit 1
|
||||
"$EXECUTABLE"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo "AOT Test Complete"
|
||||
echo "========================================"
|
||||
Reference in New Issue
Block a user