From f388ac932264ebc454c0e2baa8bdf2c9db8b2822 Mon Sep 17 00:00:00 2001 From: Meee <104610177+mee-ironsoftware@users.noreply.github.com> Date: Wed, 20 Sep 2023 08:40:51 +0700 Subject: [PATCH 1/5] DevOps Deployment: Revision version should be between minor and path --- CI/azure-pipelines-build.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CI/azure-pipelines-build.yml b/CI/azure-pipelines-build.yml index 58a0398..7b7310d 100644 --- a/CI/azure-pipelines-build.yml +++ b/CI/azure-pipelines-build.yml @@ -26,12 +26,15 @@ variables: - name: IronDrawingPatch value: $[counter(format('{0}.{1}', variables['IronDrawingMajorVersion'], variables['IronDrawingMinorVersion']), 1)] + + - name: splitVersion + value: $[split(parameters.inputNuGetVersion, '.')] - name: AssemblyVersion ${{ if eq(parameters.inputNuGetVersion, '0') }}: - value: $(IronDrawingMajorVersion).$(IronDrawingMinorVersion).$(IronDrawingPatch).$(IronDrawingRevisionVersion) + value: $(IronDrawingMajorVersion).$(IronDrawingMinorVersion).$(IronDrawingRevisionVersion).$(IronDrawingPatch) ${{ if ne(parameters.inputNuGetVersion, '0') }}: - value: ${{ parameters.inputNuGetVersion }}.$(IronDrawingRevisionVersion) + value: $[format('{0}.{1}.{2}.{3}', splitVersion[0], splitVersion[1], variables.IronDrawingRevisionVersion, splitVersion[2])] - name: NugetVersion ${{ if eq(parameters.inputNuGetVersion, '0') }}: @@ -97,4 +100,4 @@ stages: jobs: - template: job_templates/deploy_drawing_libraries.yml parameters: - NuGetVersion: $(NuGetVersion) \ No newline at end of file + NuGetVersion: $(NuGetVersion) From 6e1680082b1e22b9968751e75a07b25783f9da02 Mon Sep 17 00:00:00 2001 From: Meee Date: Wed, 20 Sep 2023 08:59:00 +0700 Subject: [PATCH 2/5] DevOps Deployment: Change to prepare assembly version in job due to variable can't get parameter --- CI/azure-pipelines-build.yml | 24 ++++++++++++-------- CI/job_templates/build_drawing_libraries.yml | 2 ++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/CI/azure-pipelines-build.yml b/CI/azure-pipelines-build.yml index 7b7310d..cf674a8 100644 --- a/CI/azure-pipelines-build.yml +++ b/CI/azure-pipelines-build.yml @@ -27,15 +27,6 @@ variables: - name: IronDrawingPatch value: $[counter(format('{0}.{1}', variables['IronDrawingMajorVersion'], variables['IronDrawingMinorVersion']), 1)] - - name: splitVersion - value: $[split(parameters.inputNuGetVersion, '.')] - - - name: AssemblyVersion - ${{ if eq(parameters.inputNuGetVersion, '0') }}: - value: $(IronDrawingMajorVersion).$(IronDrawingMinorVersion).$(IronDrawingRevisionVersion).$(IronDrawingPatch) - ${{ if ne(parameters.inputNuGetVersion, '0') }}: - value: $[format('{0}.{1}.{2}.{3}', splitVersion[0], splitVersion[1], variables.IronDrawingRevisionVersion, splitVersion[2])] - - name: NugetVersion ${{ if eq(parameters.inputNuGetVersion, '0') }}: ${{ if eq(parameters.preRelease, true) }}: @@ -63,10 +54,25 @@ stages: displayName: Build IronSoftware.Drawing Libraries dependsOn: [] jobs: + - job: PrepareDrawingAssemblyVersion + steps: + # Prepare Assembly version + - powershell: | + if ("${{ parameters.inputNuGetVersion }}" -eq "0") { + $AssemblyVersion = "$(IronDrawingMajorVersion).$(IronDrawingMinorVersion).$(IronDrawingRevisionVersion).$(IronDrawingPatch)" + } else { + $splitVersion = "${{ parameters.inputNuGetVersion }}".Split('.') + $AssemblyVersion = "$($splitVersion[0]).$($splitVersion[1]).$(IronDrawingRevisionVersion).$($splitVersion[2])" + } + Write-Host "##vso[task.setvariable variable=AssemblyVersion]$AssemblyVersion" + displayName: 'Generate Assembly version' + - script: echo $(AssemblyVersion) + displayName: 'Display Assembly version' - template: job_templates/build_drawing_libraries.yml parameters: publishAssemblies: true buildConfiguration: $(Configuration) + dependsOn: 'PrepareDrawingAssemblyVersion' ## Test Windows - template: stage_templates/run_tests_on_pool.yml parameters: diff --git a/CI/job_templates/build_drawing_libraries.yml b/CI/job_templates/build_drawing_libraries.yml index cd3887a..4369bfb 100644 --- a/CI/job_templates/build_drawing_libraries.yml +++ b/CI/job_templates/build_drawing_libraries.yml @@ -1,9 +1,11 @@ parameters: publishAssemblies: false buildConfiguration: '' + dependsOn: '' jobs: - job: BuildDrawingLibraries + dependsOn: ${{ parameters.dependsOn }} steps: # Checkout Repo - checkout: self From 6cdcfc84fa834d558823e1ccb42ab489fe8942fa Mon Sep 17 00:00:00 2001 From: Meee Date: Wed, 20 Sep 2023 09:31:00 +0700 Subject: [PATCH 3/5] DevOps Deployment: Replace AssemblyVersion when build --- CI/azure-pipelines-build.yml | 1 + CI/job_templates/build_drawing_libraries.yml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CI/azure-pipelines-build.yml b/CI/azure-pipelines-build.yml index cf674a8..0232ed6 100644 --- a/CI/azure-pipelines-build.yml +++ b/CI/azure-pipelines-build.yml @@ -73,6 +73,7 @@ stages: publishAssemblies: true buildConfiguration: $(Configuration) dependsOn: 'PrepareDrawingAssemblyVersion' + assemblyVersion: $(AssemblyVersion) ## Test Windows - template: stage_templates/run_tests_on_pool.yml parameters: diff --git a/CI/job_templates/build_drawing_libraries.yml b/CI/job_templates/build_drawing_libraries.yml index 4369bfb..47e2a40 100644 --- a/CI/job_templates/build_drawing_libraries.yml +++ b/CI/job_templates/build_drawing_libraries.yml @@ -2,6 +2,7 @@ parameters: publishAssemblies: false buildConfiguration: '' dependsOn: '' + assemblyVersion: '1.0.0.0' jobs: - job: BuildDrawingLibraries @@ -52,6 +53,7 @@ jobs: ${{ parameters.buildConfiguration }} --no-restore --verbosity normal + --property:AssemblyVersion=${{ parameters.assemblyVersion }} versioningScheme: byEnvVar versionEnvVar: AssemblyVersion # Publish Pipeline Artifacts From 2eff4460fd04309230700e00970a3750458e62d7 Mon Sep 17 00:00:00 2001 From: Meee Date: Wed, 20 Sep 2023 09:52:30 +0700 Subject: [PATCH 4/5] DevOps Deployment: Attempt 1 to fixes Replace Assembly Version when build --- CI/azure-pipelines-build.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CI/azure-pipelines-build.yml b/CI/azure-pipelines-build.yml index 0232ed6..4d68468 100644 --- a/CI/azure-pipelines-build.yml +++ b/CI/azure-pipelines-build.yml @@ -65,15 +65,14 @@ stages: $AssemblyVersion = "$($splitVersion[0]).$($splitVersion[1]).$(IronDrawingRevisionVersion).$($splitVersion[2])" } Write-Host "##vso[task.setvariable variable=AssemblyVersion]$AssemblyVersion" - displayName: 'Generate Assembly version' - - script: echo $(AssemblyVersion) - displayName: 'Display Assembly version' + displayName: 'Generate Assembly version' + name: setVarStep - template: job_templates/build_drawing_libraries.yml parameters: publishAssemblies: true buildConfiguration: $(Configuration) dependsOn: 'PrepareDrawingAssemblyVersion' - assemblyVersion: $(AssemblyVersion) + assemblyVersion: $[ dependencies.PrepareDrawingAssemblyVersion.outputs['setVarStep.AssemblyVersion'] ] ## Test Windows - template: stage_templates/run_tests_on_pool.yml parameters: From 2ca1291d1a043ce7021006d6a7ced5a2e67272a1 Mon Sep 17 00:00:00 2001 From: Meee Date: Wed, 20 Sep 2023 10:15:30 +0700 Subject: [PATCH 5/5] DevOps Deployment: Attempt 2 to fixes Replace Assembly Version when build --- CI/azure-pipelines-build.yml | 10 +++++----- CI/job_templates/build_drawing_libraries.yml | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/CI/azure-pipelines-build.yml b/CI/azure-pipelines-build.yml index 4d68468..156a4e7 100644 --- a/CI/azure-pipelines-build.yml +++ b/CI/azure-pipelines-build.yml @@ -8,11 +8,11 @@ parameters: - name: githubRelease displayName: GitHub Release type: boolean - default: True + default: False - name: preRelease displayName: Pre-Release type: boolean - default: true + default: True - name: inputNuGetVersion displayName: NuGet-Version type: string @@ -64,15 +64,15 @@ stages: $splitVersion = "${{ parameters.inputNuGetVersion }}".Split('.') $AssemblyVersion = "$($splitVersion[0]).$($splitVersion[1]).$(IronDrawingRevisionVersion).$($splitVersion[2])" } - Write-Host "##vso[task.setvariable variable=AssemblyVersion]$AssemblyVersion" + Set-Content -Path "AssemblyVersion.txt" -Value $AssemblyVersion displayName: 'Generate Assembly version' - name: setVarStep + - publish: 'AssemblyVersion.txt' + artifact: 'AssemblyVersionInfo' - template: job_templates/build_drawing_libraries.yml parameters: publishAssemblies: true buildConfiguration: $(Configuration) dependsOn: 'PrepareDrawingAssemblyVersion' - assemblyVersion: $[ dependencies.PrepareDrawingAssemblyVersion.outputs['setVarStep.AssemblyVersion'] ] ## Test Windows - template: stage_templates/run_tests_on_pool.yml parameters: diff --git a/CI/job_templates/build_drawing_libraries.yml b/CI/job_templates/build_drawing_libraries.yml index 47e2a40..24b1c24 100644 --- a/CI/job_templates/build_drawing_libraries.yml +++ b/CI/job_templates/build_drawing_libraries.yml @@ -2,12 +2,23 @@ parameters: publishAssemblies: false buildConfiguration: '' dependsOn: '' - assemblyVersion: '1.0.0.0' jobs: - job: BuildDrawingLibraries dependsOn: ${{ parameters.dependsOn }} steps: + - download: current + artifact: 'AssemblyVersionInfo' + - powershell: | + $AssemblyVersion = Get-Content "$(Pipeline.Workspace)\AssemblyVersionInfo\AssemblyVersion.txt" + if (![string]::IsNullOrEmpty($AssemblyVersion)) { + Write-Host "Using AssemblyVersion from previous job: $AssemblyVersion" + Write-Host "##vso[task.setvariable variable=finalAssemblyVersion]$AssemblyVersion" + } else { + Write-Host "AssemblyVersion is not set, using default: 1.0.0.0" + Write-Host "##vso[task.setvariable variable=finalAssemblyVersion]1.0.0.0" + } + displayName: 'Use or Set Assembly Version' # Checkout Repo - checkout: self displayName: Checkout IronSoftware.Drawing repository @@ -53,7 +64,7 @@ jobs: ${{ parameters.buildConfiguration }} --no-restore --verbosity normal - --property:AssemblyVersion=${{ parameters.assemblyVersion }} + --property:AssemblyVersion=$(finalAssemblyVersion) versioningScheme: byEnvVar versionEnvVar: AssemblyVersion # Publish Pipeline Artifacts