diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..d20e627 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,55 @@ +stages: + - build + - publish + +variables: + DOTNET_CLI_TELEMETRY_OPTOUT: "1" + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: "1" + BUILD_CONFIG: "Release" + +# Build job for Windows runner (shell executor). Remove 'image' so the runner uses the host environment. +build_windows: + stage: build + tags: + - windows + script: + - dotnet --info + - dotnet restore + - dotnet build "imagecatalog\ImageCatalog 2.csproj" -c $BUILD_CONFIG -v minimal + artifacts: + paths: + - "**/bin/$BUILD_CONFIG/net10.0-windows/**" + expire_in: 1 hour + +# Publish and create GitLab Release when building a tag. This job expects a Windows runner with PowerShell and curl available. +publish_release: + stage: publish + tags: + - windows + needs: + - build_windows + script: + # Publish the app + - dotnet publish "imagecatalog\ImageCatalog 2.csproj" -c $BUILD_CONFIG -r win-x64 --self-contained false -o publish + - echo "Published to $(pwd)\\publish" + # Find first file in publish folder + - $file = Get-ChildItem -Path publish -File | Select-Object -First 1; Write-Host "Uploading $($file.FullName)" + # Upload to GitLab project uploads API to get a public URL for the artifact + - $uploadUrl = "$env:CI_API_V4_URL/projects/$env:CI_PROJECT_ID/uploads" + - $formData = "file=@$($file.FullName)" + - $uploadResp = curl --silent --show-error --header "JOB-TOKEN:$env:CI_JOB_TOKEN" --form $formData $uploadUrl + - $uploadJson = $uploadResp | ConvertFrom-Json + - $assetUrl = "$env:CI_SERVER_URL$($uploadJson.url)" + - 'Write-Host "Uploaded asset url: $assetUrl"' + # Create the release using uploads URL + - $body = @{ name = $env:CI_COMMIT_TAG; tag_name = $env:CI_COMMIT_TAG; description = "Automated release from CI"; assets = @{ links = @(@{ name = "$($file.Name)"; url = $assetUrl }) } } | ConvertTo-Json -Depth 10 + - Invoke-RestMethod -Method Post -Uri "$env:CI_API_V4_URL/projects/$env:CI_PROJECT_ID/releases" -Headers @{ "JOB-TOKEN" = $env:CI_JOB_TOKEN } -Body $body -ContentType "application/json" + artifacts: + paths: + - publish/* + expire_in: 1 day + only: + - tags + +# Notes for runner setup: Ensure a GitLab Windows runner with tag 'windows' is registered and has .NET 10 SDK installed. +# Use the shell executor on the Windows machine so the job runs in the host PowerShell environment diff --git a/imagecatalog/ImageCatalog 2.csproj b/imagecatalog/ImageCatalog 2.csproj index af7d536..3744a5c 100644 --- a/imagecatalog/ImageCatalog 2.csproj +++ b/imagecatalog/ImageCatalog 2.csproj @@ -46,21 +46,19 @@ - + all - + - - $(GitVersion_AssemblySemVer) - - $(GitVersion_FileVersion) - - $(GitVersion_FullSemVer) + + $(Version) + $(Version) + $(Version) @@ -76,18 +74,7 @@ - - - - - - - - + - <_Ver Condition="'$(GitVersion_FullSemVer)' != ''">$(GitVersion_FullSemVer) - <_Ver Condition="'$(GitVersion_FullSemVer)' == ''">$(FileVersion) + + <_Ver Condition="'$(Version)' != ''">$(Version) + <_Ver Condition="'$(Version)' == ''">$(FileVersion) <_Ver Condition="'$(_Ver)' == ''">$(AssemblyVersion) diff --git a/imagecatalog/MainWindow.xaml b/imagecatalog/MainWindow.xaml index 7634adf..17bda4f 100644 --- a/imagecatalog/MainWindow.xaml +++ b/imagecatalog/MainWindow.xaml @@ -196,11 +196,18 @@ - - - - - + + + + + + Nessuna + Aggiungi scritta + Nome file + Aggiungi orario + Nome+Orario + Tempo gara + diff --git a/imagecatalog/Program.cs b/imagecatalog/Program.cs index 678864c..55b12c5 100644 --- a/imagecatalog/Program.cs +++ b/imagecatalog/Program.cs @@ -79,24 +79,24 @@ static class Program // the block below and comment out the WPF branch. // ----------------------------------------------------------------------------- // // Force WinForms UI (uncomment to enable) - var mainForm = serviceProvider.GetRequiredService(); - // If you want to set the DataModel explicitly on the WinForms form use the lines below - // var mainViewModel = serviceProvider.GetRequiredService(); - // mainForm.Model = mainViewModel; - Application.Run(mainForm); + //var mainForm = serviceProvider.GetRequiredService(); + //// If you want to set the DataModel explicitly on the WinForms form use the lines below + //// var mainViewModel = serviceProvider.GetRequiredService(); + //// mainForm.Model = mainViewModel; + //Application.Run(mainForm); // ----------------------------------------------------------------------------- - //if (serviceProvider.GetService(typeof(ImageCatalog_2.MainWindow)) is ImageCatalog_2.MainWindow wpfMain) - //{ - // // Start WPF app - // var app = new System.Windows.Application(); - // app.Run(wpfMain); - //} - //else - //{ - // var mainForm = serviceProvider.GetRequiredService(); - // Application.Run(mainForm); - //} + if (serviceProvider.GetService(typeof(ImageCatalog_2.MainWindow)) is ImageCatalog_2.MainWindow wpfMain) + { + // Start WPF app + var app = new System.Windows.Application(); + app.Run(wpfMain); + } + else + { + var mainForm = serviceProvider.GetRequiredService(); + Application.Run(mainForm); + } } private static void ConfigureServices(ServiceCollection services)