From 228c6aef234e218249542830c9aed517962c87b3 Mon Sep 17 00:00:00 2001 From: NoriZC <110961157+NoriZC@users.noreply.github.com> Date: Thu, 9 May 2024 15:46:56 +0800 Subject: [PATCH] Added after build task in build-module generation (#1331) * after build * after build * add root module * add default after build * Update project.ts * revert * after build * add diusable * update * update --- powershell/cmdlets/class.ts | 2 +- powershell/internal/project.ts | 8 +++++++- powershell/resources/assets/build-module.ps1 | 12 +++++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/powershell/cmdlets/class.ts b/powershell/cmdlets/class.ts index f0d389f84e..3f0ea4ed8f 100644 --- a/powershell/cmdlets/class.ts +++ b/powershell/cmdlets/class.ts @@ -2323,7 +2323,7 @@ export class CmdletClass extends Class { if (operation.details.default.externalDocs) { this.add(new Attribute(ExternalDocsAttribute, { parameters: [`${new StringExpression(this.operation.details.default.externalDocs?.url ?? '')}`, - `${new StringExpression(this.operation.details.default.externalDocs?.description ?? '')}`] + `${new StringExpression(this.operation.details.default.externalDocs?.description ?? '')}`] })); } diff --git a/powershell/internal/project.ts b/powershell/internal/project.ts index 37685132ea..6589a919b0 100644 --- a/powershell/internal/project.ts +++ b/powershell/internal/project.ts @@ -148,6 +148,8 @@ export class Project extends codeDomProject { public gitAttributes!: string; public propertiesExcludedForTableview!: string; public readme!: string; + public afterBuildTasksPath!: string; + public afterBuildTasksArgs!: string; public dllName!: string; public dll!: string; public psd1!: string; @@ -327,6 +329,10 @@ export class Project extends codeDomProject { this.gitIgnore = `${this.baseFolder}/.gitignore`; this.gitAttributes = `${this.baseFolder}/.gitattributes`; this.readme = `${this.baseFolder}/README.md`; + this.afterBuildTasksPath = await this.state.getValue('after-build-tasks-path', ''); + + const afterBuildTasksArgsDictionary: Dictionary = await this.state.getValue>('after-build-tasks-args', {}); + this.afterBuildTasksArgs = JSON.stringify(afterBuildTasksArgsDictionary); // excluded properties in table view const excludedList = >( @@ -411,4 +417,4 @@ export class Project extends codeDomProject { private convertToPsListAsString(items: Array): string { return items ? items.map((i) => `'${i}'`).join(', ') : 'undefined'; } -} \ No newline at end of file +} diff --git a/powershell/resources/assets/build-module.ps1 b/powershell/resources/assets/build-module.ps1 index c1ba157405..085952e226 100644 --- a/powershell/resources/assets/build-module.ps1 +++ b/powershell/resources/assets/build-module.ps1 @@ -1,7 +1,7 @@ # ---------------------------------------------------------------------------------- ${$project.pwshCommentHeader} # ---------------------------------------------------------------------------------- -param([switch]$NotIsolated, [switch]$Run, [switch]$Test, [switch]$Docs, [switch]$Pack, [switch]$Code, [switch]$Release, [switch]$Debugger, [switch]$NoDocs, [switch]$UX) +param([switch]$NotIsolated, [switch]$Run, [switch]$Test, [switch]$Docs, [switch]$Pack, [switch]$Code, [switch]$Release, [switch]$Debugger, [switch]$NoDocs, [switch]$UX, [Switch]$DisableAfterBuildTasks) $ErrorActionPreference = 'Stop' if($PSEdition -ne 'Core') { @@ -166,4 +166,14 @@ if (Test-Path (Join-Path $PSScriptRoot 'generate-portal-ux.ps1')) . (Join-Path $PSScriptRoot 'generate-portal-ux.ps1') } +if (-not $DisableAfterBuildTasks){ + $afterBuildTasksPath = Join-Path $PSScriptRoot '${$project.afterBuildTasksPath}' + $afterBuildTasksArgs = ConvertFrom-Json '${$project.afterBuildTasksArgs}' -AsHashtable + if(Test-Path -Path $afterBuildTasksPath -PathType leaf){ + Write-Host -ForegroundColor Green 'Running after build tasks...' + . $afterBuildTasksPath @afterBuildTasksArgs + } +} + + Write-Host -ForegroundColor Green '-------------Done-------------'