diff --git a/.forgejo/workflows/build-windows-avalonia.yml b/.forgejo/workflows/build-windows-avalonia.yml index c418d92..d1709a0 100644 --- a/.forgejo/workflows/build-windows-avalonia.yml +++ b/.forgejo/workflows/build-windows-avalonia.yml @@ -71,6 +71,8 @@ jobs: - name: Publish Windows Avalonia build run: | set -eu + publish_dir="${GITHUB_WORKSPACE}/${{ env.PUBLISH_DIR }}" + rm -rf "${publish_dir}" dotnet publish "${{ env.PROJECT_PATH }}" \ -c Release \ -r win-x64 \ @@ -80,7 +82,7 @@ jobs: -p:PublishSingleFile=true \ -p:PublishTrimmed=false \ -p:PublishReadyToRun=false \ - -o "${{ env.PUBLISH_DIR }}" + -o "${publish_dir}" - name: Validate published executable run: | @@ -98,6 +100,13 @@ jobs: exit 1 fi + - name: Validate AI runtime libraries + run: | + set -eu + dotnet msbuild "${{ env.PROJECT_PATH }}" \ + -target:ValidateWindowsCatalogPublishOutput \ + -p:PublishDir="${GITHUB_WORKSPACE}/${{ env.PUBLISH_DIR }}" + - name: Upload publish artifact uses: actions/upload-artifact@v3 with: diff --git a/.forgejo/workflows/release-windows-avalonia.yml b/.forgejo/workflows/release-windows-avalonia.yml index ca7c521..9beb30a 100644 --- a/.forgejo/workflows/release-windows-avalonia.yml +++ b/.forgejo/workflows/release-windows-avalonia.yml @@ -9,6 +9,7 @@ env: DOTNET_VERSION: 10.0.x PROJECT_PATH: imagecatalog/ImageCatalog 2.csproj PUBLISH_DIR: artifacts/publish/win-x64 + PACKAGE_PATH: artifacts/publish/ImageCatalog-avalonia-win-x64.zip ARTIFACT_NAME: imagecatalog-windows-avalonia NUGET_SOURCE_NAME: Nuget-Forgejo-AIFotoONLUS NUGET_SOURCE_URL: ${{ vars.AIFOTOONLUS_NUGET_SOURCE_URL || format('{0}/api/packages/{1}/nuget/index.json', forgejo.server_url, vars.AIFOTOONLUS_PACKAGE_OWNER || forgejo.repository_owner) }} @@ -62,6 +63,8 @@ jobs: - name: Publish Windows Avalonia build run: | set -eu + publish_dir="${GITHUB_WORKSPACE}/${{ env.PUBLISH_DIR }}" + rm -rf "${publish_dir}" dotnet publish "${{ env.PROJECT_PATH }}" \ -c Release \ -r win-x64 \ @@ -71,7 +74,7 @@ jobs: -p:PublishSingleFile=true \ -p:PublishTrimmed=false \ -p:PublishReadyToRun=false \ - -o "${{ env.PUBLISH_DIR }}" + -o "${publish_dir}" - name: Validate published executable run: | @@ -89,11 +92,20 @@ jobs: exit 1 fi + - name: Package complete Windows release + run: | + set -eu + dotnet msbuild "${{ env.PROJECT_PATH }}" \ + -target:PackageWindowsCatalogOutput \ + -p:PublishDir="${GITHUB_WORKSPACE}/${{ env.PUBLISH_DIR }}" \ + -p:PublishArchivePath="${GITHUB_WORKSPACE}/${{ env.PACKAGE_PATH }}" + test -s "${GITHUB_WORKSPACE}/${{ env.PACKAGE_PATH }}" + - name: Upload publish artifact uses: actions/upload-artifact@v3 with: name: ${{ env.ARTIFACT_NAME }} - path: ${{ env.PUBLISH_DIR }} + path: ${{ env.PACKAGE_PATH }} if-no-files-found: error release: @@ -153,22 +165,22 @@ jobs: echo "RELEASE_ID=${release_id}" >> "${GITHUB_ENV}" - - name: Upload executable to release + - name: Upload Windows distributable ZIP to release run: | set -eu api_base="${FORGEJO_SERVER_URL%/}/api/v1/repos/${FORGEJO_REPOSITORY}" - executable_path="$(find artifacts/release -maxdepth 1 -type f -iname '*.exe' | head -n1)" + archive_path="$(find artifacts/release -maxdepth 1 -type f -iname '*.zip' | head -n1)" - if [ -z "${executable_path}" ]; then - echo "No executable found in downloaded artifact" + if [ -z "${archive_path}" ]; then + echo "No Windows distributable ZIP found in downloaded artifact" exit 1 fi short_sha="$(printf '%s' "${FORGEJO_SHA}" | cut -c1-12)" - asset_name="ImageCatalog-avalonia-win-x64-${FORGEJO_REF_NAME}-${short_sha}.exe" + asset_name="ImageCatalog-avalonia-win-x64-${FORGEJO_REF_NAME}-${short_sha}.zip" curl -fsS \ -H "Authorization: token ${FORGEJO_TOKEN}" \ -H "Content-Type: application/octet-stream" \ - --data-binary @"${executable_path}" \ + --data-binary @"${archive_path}" \ "${api_base}/releases/${RELEASE_ID}/assets?name=${asset_name}" \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 04a76b7..0baa8a0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -85,16 +85,28 @@ build_windows: } & $dotnetExe restore & $dotnetExe build "imagecatalog\ImageCatalog 2.csproj" -c $env:BUILD_CONFIG -v minimal - # Produce a single-file, ready-to-run publish so downstream jobs only need the EXE. + # Publish a single-file executable with the CUDA/OpenCV runtime libraries alongside it. try { - & $dotnetExe publish "imagecatalog\ImageCatalog 2.csproj" -c $env:BUILD_CONFIG -r win-x64 --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=false -p:PublishReadyToRun=true -o "imagecatalog\bin\$env:BUILD_CONFIG\net10.0-windows\publish" -v minimal $publishDir = "imagecatalog\bin\$env:BUILD_CONFIG\net10.0-windows\publish" - $legacyRendererFiles = Get-ChildItem $publishDir -File | Where-Object { $_.Name -in @('Microsoft.Windows.Compatibility.dll', 'System.Private.Windows.GdiPlus.dll') } + $archivePath = Join-Path (Split-Path $publishDir -Parent) 'ImageCatalog-avalonia-win-x64.zip' + $publishDirAbsolute = [System.IO.Path]::GetFullPath($publishDir) + $archivePathAbsolute = [System.IO.Path]::GetFullPath($archivePath) + if (Test-Path $publishDirAbsolute) { + Remove-Item -LiteralPath $publishDirAbsolute -Recurse -Force + } + if (Test-Path $archivePathAbsolute) { + Remove-Item -LiteralPath $archivePathAbsolute -Force + } + & $dotnetExe publish "imagecatalog\ImageCatalog 2.csproj" -c $env:BUILD_CONFIG -r win-x64 --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=false -p:PublishReadyToRun=true -o $publishDirAbsolute -v minimal + if ($LASTEXITCODE -ne 0) { throw 'dotnet publish failed' } + $legacyRendererFiles = Get-ChildItem $publishDirAbsolute -File | Where-Object { $_.Name -in @('Microsoft.Windows.Compatibility.dll', 'System.Private.Windows.GdiPlus.dll') } if ($legacyRendererFiles) { Write-Host 'Legacy GDI compatibility assemblies must not be published:' $legacyRendererFiles | ForEach-Object { Write-Host $_.FullName } exit 1 } + & $dotnetExe msbuild "imagecatalog\ImageCatalog 2.csproj" -target:PackageWindowsCatalogOutput "-p:PublishDir=$publishDirAbsolute" "-p:PublishArchivePath=$archivePathAbsolute" + if ($LASTEXITCODE -ne 0) { throw 'Failed to package the Windows Catalog output' } } catch { Write-Host "dotnet publish failed: $_" throw @@ -102,7 +114,7 @@ build_windows: } artifacts: paths: - - "imagecatalog/bin/$BUILD_CONFIG/net10.0-windows/publish/**" + - "imagecatalog/bin/$BUILD_CONFIG/net10.0-windows/ImageCatalog-avalonia-win-x64.zip" expire_in: 1 hour # Publish and create GitLab Release when building a tag. @@ -128,17 +140,16 @@ publish_release: if [ -z "$version" ]; then echo "minver failed to produce a version"; exit 1; fi echo "Using version: $version" export VERSION="$version" - # find the single-file exe from the publish output - file=$(find imagecatalog/bin -type f -iname '*.exe' -print | head -n1 || true) - if [ -z "$file" ]; then file=$(find imagecatalog -type f -iname '*.exe' -print | head -n1 || true); fi - if [ -z "$file" ]; then echo "No artifact EXE found to attach"; exit 1; fi - echo "Uploading artifact: $file" - uploadResp=$(curl --silent --show-error --header "JOB-TOKEN:$CI_JOB_TOKEN" --form "file=@$file" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/uploads") + # Attach the complete distributable ZIP, including native OpenCV/CUDA dependencies. + file=$(find imagecatalog/bin -type f -name 'ImageCatalog-avalonia-win-x64.zip' -print | head -n1 || true) + if [ -z "$file" ]; then echo "No Windows distributable ZIP found to attach"; exit 1; fi + basename="ImageCatalog-avalonia-win-x64-${version}.zip" + echo "Uploading artifact: $file as $basename" + uploadResp=$(curl --silent --show-error --header "JOB-TOKEN:$CI_JOB_TOKEN" --form "file=@$file;filename=$basename" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/uploads") assetPath=$(echo "$uploadResp" | sed -n 's/.*"url":"\([^\"]*\)".*/\1/p') if [ -z "$assetPath" ]; then echo "Upload failed: $uploadResp"; exit 1; fi assetUrl="$CI_SERVER_URL$assetPath" echo "Uploaded asset url: $assetUrl" - basename=$(basename "$file") export RELEASE_ASSET_URL="$assetUrl" export ASSET_BASENAME="$basename" artifacts: diff --git a/imagecatalog/ImageCatalog 2.csproj b/imagecatalog/ImageCatalog 2.csproj index c7bb517..98768d1 100644 --- a/imagecatalog/ImageCatalog 2.csproj +++ b/imagecatalog/ImageCatalog 2.csproj @@ -174,4 +174,59 @@ + + + + <_CublasLtFragment0>$([System.IO.Path]::GetFullPath('$(NuGetPackageRoot)ntvlibs.cuda11.cublaslt64_11.runtime.win-x64.f00/11.8.0/fragments/win-x64/native/cublasLt64_11.dll.f00')) + <_CublasLtFragment1>$([System.IO.Path]::GetFullPath('$(NuGetPackageRoot)ntvlibs.cuda11.cublaslt64_11.runtime.win-x64.f01/11.8.0/fragments/win-x64/native/cublasLt64_11.dll.f01')) + <_CudnnCnnInferFragment0>$([System.IO.Path]::GetFullPath('$(NuGetPackageRoot)ntvlibs.cudnn.cuda11.cudnn_cnn_infer64_8.runtime.win-x64.f00/8.9.7.29/fragments/win-x64/native/cudnn_cnn_infer64_8.dll.f00')) + <_CudnnCnnInferFragment1>$([System.IO.Path]::GetFullPath('$(NuGetPackageRoot)ntvlibs.cudnn.cuda11.cudnn_cnn_infer64_8.runtime.win-x64.f01/8.9.7.29/fragments/win-x64/native/cudnn_cnn_infer64_8.dll.f01')) + <_CublasLtOutput>$([System.IO.Path]::GetFullPath('$(PublishDir)/cublasLt64_11.dll')) + <_CudnnCnnInferOutput>$([System.IO.Path]::GetFullPath('$(PublishDir)/cudnn_cnn_infer64_8.dll')) + + + + + + + + + + + + + + + <_CatalogPublishDirectory>$([System.IO.Path]::GetFullPath('$(PublishDir)')) + <_OpenCvSharpRuntimePath>$([System.IO.Path]::Combine('$(_CatalogPublishDirectory)', 'OpenCvSharpExtern.dll')) + <_CublasRuntimePath>$([System.IO.Path]::Combine('$(_CatalogPublishDirectory)', 'cublas64_11.dll')) + <_CublasLtRuntimePath>$([System.IO.Path]::Combine('$(_CatalogPublishDirectory)', 'cublasLt64_11.dll')) + <_CudaRuntimePath>$([System.IO.Path]::Combine('$(_CatalogPublishDirectory)', 'cudart64_110.dll')) + <_CudnnRuntimePath>$([System.IO.Path]::Combine('$(_CatalogPublishDirectory)', 'cudnn64_8.dll')) + <_CudnnOpsRuntimePath>$([System.IO.Path]::Combine('$(_CatalogPublishDirectory)', 'cudnn_ops_infer64_8.dll')) + <_CudnnAdvRuntimePath>$([System.IO.Path]::Combine('$(_CatalogPublishDirectory)', 'cudnn_adv_infer64_8.dll')) + <_CudnnCnnRuntimePath>$([System.IO.Path]::Combine('$(_CatalogPublishDirectory)', 'cudnn_cnn_infer64_8.dll')) + + + <_CatalogPublishedExecutable Include="$(_CatalogPublishDirectory)/*.exe" /> + + + + + + + + + + + + + + + + + <_CatalogPublishArchivePath Condition="'$(PublishArchivePath)' != ''">$([System.IO.Path]::GetFullPath('$(PublishArchivePath)')) + + + \ No newline at end of file