From f2fd973e443ab0d45d83472247655fcfa0d21caa Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 17 Sep 2019 15:50:26 -0700 Subject: [PATCH 01/14] initial move to yml --- .vsts-ci/azure-pipelines-release.yml | 49 ++++++++++++++++++++++ .vsts-ci/templates/release-general.yml | 58 ++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 .vsts-ci/azure-pipelines-release.yml create mode 100644 .vsts-ci/templates/release-general.yml diff --git a/.vsts-ci/azure-pipelines-release.yml b/.vsts-ci/azure-pipelines-release.yml new file mode 100644 index 000000000..2d156fa90 --- /dev/null +++ b/.vsts-ci/azure-pipelines-release.yml @@ -0,0 +1,49 @@ +name: PR-$(System.PullRequest.PullRequestNumber)-$(Date:yyyyMMdd)$(Rev:.rr) + +variables: + # Don't download unneeded packages + - name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE + value: 'true' + # Improve performance by not sending telemetry + - name: DOTNET_CLI_TELEMETRY_OPTOUT + value: 'true' + +trigger: + batch: true + branches: + include: + - master + - legacy/1.x + paths: + exclude: + - /.dependabot/* + - /.poshchan/* + - /.github/**/* + - /.vscode/**/* + - /.vsts-ci/misc-analysis.yml + - /tools/**/* + - .editorconfig + - .gitattributes + - .gitignore + - /docs/**/* + - /CHANGELOG.md + - /CONTRIBUTING.md + - /README.md + - /LICENSE + - /CODE_OF_CONDUCT.md + +jobs: + +- job: 'Build' + displayName: 'Build release' + pool: + vmImage: 'vs2017-win2016' + steps: + - template: templates/ci-general.yml +- job: + dependsOn: 'Build' + displayName: 'Sign release and package' + pool: + vmImage: 'vs2017-win2016' + steps: + - template: templates/release-general.yml diff --git a/.vsts-ci/templates/release-general.yml b/.vsts-ci/templates/release-general.yml new file mode 100644 index 000000000..985d264ff --- /dev/null +++ b/.vsts-ci/templates/release-general.yml @@ -0,0 +1,58 @@ +steps: +- task: PkgESSetupBuild@10 + displayName: 'Package ES - Setup Build' + +- task: DownloadBuildArtifacts@0 + displayName: 'Download Build Artifacts' + inputs: + downloadType: specific + +- task: PowerShell@1 + displayName: 'Unzip build' + inputs: + scriptType: inlineScript + inlineScript: | + New-Item -ItemType Directory $env:SYSTEM_ARTIFACTSDIRECTORY/release/out + $psesZip = Get-ChildItem $env:SYSTEM_ARTIFACTSDIRECTORY/PowerShellEditorServices*.zip + $psesZip | Expand-Archive -Path $env:SYSTEM_ARTIFACTSDIRECTORY/release/out + $psesZip | Remove-Item -Recurse -Force + +- task: PkgESCodeSign@10 + displayName: 'CodeSign tools/releaseBuild/signing.xml' + inputs: + signConfigXml: tools/releaseBuild/signing.xml + inPathRoot: '$(System.ArtifactsDirectory)' + outPathRoot: '$(System.ArtifactsDirectory)\Signed' + +- task: PowerShell@1 + displayName: 'Copy signed items into output' + inputs: + scriptType: inlineScript + inlineScript: | + $signed="$(System.ArtifactsDirectory)\Signed\PowerShellEditorServices\*" + $notSigned="$(System.ArtifactsDirectory)\release\out\PowerShellEditorServices" + Copy-Item $signed $notSigned -Recurse -Force + +- task: PowerShell@1 + displayName: 'Create catalog files' + inputs: + scriptType: inlineScript + inlineScript: | + $dir = "$(System.ArtifactsDirectory)\release\out\PowerShellEditorServices\PowerShellEditorServices" + New-FileCatalog -CatalogFilePath "$(System.ArtifactsDirectory)\PowerShellEditorServices.cat" -Path $dir + + $dir = "$(System.ArtifactsDirectory)\release\out\PowerShellEditorServices\PowerShellEditorServices.VSCode" + New-FileCatalog -CatalogFilePath "$(System.ArtifactsDirectory)\PowerShellEditorServices.VSCode.cat" -Path $dir + +- task: PkgESCodeSign@10 + displayName: 'CodeSign tools/releaseBuild/FileCatalogSigning.xml' + inputs: + signConfigXml: tools/releaseBuild/FileCatalogSigning.xml + inPathRoot: '$(System.ArtifactsDirectory)' + outPathRoot: '$(System.ArtifactsDirectory)' + +- task: PowerShell@1 + displayName: 'Upload artifacts' + inputs: + scriptType: inlineScript + inlineScript: 'Write-Host "##vso[artifact.upload containerfolder=PowerShellEditorServices;artifactname=PowerShellEditorServices]$(System.ArtifactsDirectory)\release\out\PowerShellEditorServices"' From d233fa54273c4bfce5f2ddd39ade9200a1d214ef Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 17 Sep 2019 16:13:59 -0700 Subject: [PATCH 02/14] iterate --- .vsts-ci/azure-pipelines-release.yml | 10 +- .vsts-ci/templates/release-general.yml | 91 +++++- tools/terms/FileTypeSet.xml | 379 +++++++++++++++++++++++++ 3 files changed, 470 insertions(+), 10 deletions(-) create mode 100644 tools/terms/FileTypeSet.xml diff --git a/.vsts-ci/azure-pipelines-release.yml b/.vsts-ci/azure-pipelines-release.yml index 2d156fa90..5817542b0 100644 --- a/.vsts-ci/azure-pipelines-release.yml +++ b/.vsts-ci/azure-pipelines-release.yml @@ -34,7 +34,7 @@ trigger: jobs: -- job: 'Build' +- job: 'ReleaseBuild' displayName: 'Build release' pool: vmImage: 'vs2017-win2016' @@ -47,3 +47,11 @@ jobs: vmImage: 'vs2017-win2016' steps: - template: templates/release-general.yml +- job: 'SignBuild' + displayName: Signing Build + dependsOn: 'ReleaseBuild' + pool: + name: 'Package ES CodeHub Lab E' + demands: DotNetFramework + steps: + - template: templates/release-general.yml diff --git a/.vsts-ci/templates/release-general.yml b/.vsts-ci/templates/release-general.yml index 985d264ff..712758529 100644 --- a/.vsts-ci/templates/release-general.yml +++ b/.vsts-ci/templates/release-general.yml @@ -1,6 +1,13 @@ steps: +- pwsh: | + Get-ChildItem -Path env: + displayName: Capture environment + condition: succeededOrFailed() + - task: PkgESSetupBuild@10 displayName: 'Package ES - Setup Build' + inputs: + productName: PowerShellEditorServices - task: DownloadBuildArtifacts@0 displayName: 'Download Build Artifacts' @@ -8,21 +15,23 @@ steps: downloadType: specific - task: PowerShell@1 - displayName: 'Unzip build' + displayName: 'Extract build zip' inputs: scriptType: inlineScript inlineScript: | - New-Item -ItemType Directory $env:SYSTEM_ARTIFACTSDIRECTORY/release/out - $psesZip = Get-ChildItem $env:SYSTEM_ARTIFACTSDIRECTORY/PowerShellEditorServices*.zip - $psesZip | Expand-Archive -Path $env:SYSTEM_ARTIFACTSDIRECTORY/release/out + New-Item -ItemType Directory $env:BUILD_ARTIFACTSTAGINGDIRECTORY/release/out + $psesZip = Get-ChildItem $env:BUILD_ARTIFACTSTAGINGDIRECTORY/PowerShellEditorServices*.zip + $psesZip | Expand-Archive -Path $env:BUILD_ARTIFACTSTAGINGDIRECTORY/release/out $psesZip | Remove-Item -Recurse -Force - task: PkgESCodeSign@10 - displayName: 'CodeSign tools/releaseBuild/signing.xml' - inputs: - signConfigXml: tools/releaseBuild/signing.xml - inPathRoot: '$(System.ArtifactsDirectory)' - outPathRoot: '$(System.ArtifactsDirectory)\Signed' + displayName: 'CodeSign tools/releaseBuild/signing.xml' + env: + SYSTEM_ACCESSTOKEN: $(System.AccessToken) + inputs: + signConfigXml: tools/releaseBuild/signing.xml + inPathRoot: '$(Build.ArtifactStagingDirectory)' + outPathRoot: '$(Build.ArtifactStagingDirectory)\Signed' - task: PowerShell@1 displayName: 'Copy signed items into output' @@ -51,6 +60,70 @@ steps: inPathRoot: '$(System.ArtifactsDirectory)' outPathRoot: '$(System.ArtifactsDirectory)' +- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0 + displayName: 'Component Detection' + +- task: AntiMalware@3 +inputs: + InputType: 'Basic' + ScanType: 'CustomScan' + FileDirPath: '$(Build.ArtifactStagingDirectory)' + EnableServices: false + SupportLogOnError: false + TreatSignatureUpdateFailureAs: 'Warning' + SignatureFreshness: 'UpToDate' + TreatStaleSignatureAs: 'Error' + +- task: PoliCheck@1 +condition: succeededOrFailed() +inputs: + targetType: F + optionsFC: 0 + optionsXS: 0 + optionsPE: '1|2|3|4' + optionsHMENABLE: 0 + optionsFTPATH: '$(Build.SourcesDirectory)\tools\terms\FileTypeSet.xml' + # toolVersion: 5.8.2.1 + +- task: CredScan@2 +condition: succeededOrFailed() + +- task: BinSkim@3 +condition: succeededOrFailed() +inputs: + InputType: 'Basic' + Function: 'analyze' + AnalyzeRecurse: true + AnalyzeTarget: '$(Build.ArtifactStagingDirectory)\Microsoft.PowerShell.GraphicalTools.dll;$(Build.ArtifactStagingDirectory)\OutGridView*.dll' + +# Publish results as artifacts +- task: PublishSecurityAnalysisLogs@3 +condition: succeededOrFailed() +inputs: + ArtifactName: 'CodeAnalysisLogs' + ArtifactType: 'Container' + +# Publish to TSA server +- task: TSAUpload@1 +condition: succeededOrFailed() +continueOnError: true +inputs: + tsaVersion: 'TsaV2' + codebase: 'Existing' + tsaEnvironment: 'PROD' + codeBaseName: 'PowerShell_GraphicalTools_20190809' + uploadAPIScan: false + uploadBinSkim: true + uploadCredScan: true + uploadFortifySCA: false + uploadFxCop: false + uploadModernCop: false + uploadPoliCheck: true + uploadPREfast: false + uploadRoslyn: false + uploadTSLint: false + uploadAsync: true + - task: PowerShell@1 displayName: 'Upload artifacts' inputs: diff --git a/tools/terms/FileTypeSet.xml b/tools/terms/FileTypeSet.xml new file mode 100644 index 000000000..82f9f4d09 --- /dev/null +++ b/tools/terms/FileTypeSet.xml @@ -0,0 +1,379 @@ + + + + + Pure Text Files + + .txt + .des + .pwd + .asm + .cmd + .ini + .poc + .pwt + .hpj + .sql + .inf + .log + .def + .url + .bat + .aspx + .idl + .sys + .resources + .strings + .md + .yml + .yaml + .spelling + .gitignore + .gitattributes + .gitmodules + .csv + .tsv + + + + CodeFiles + + .frm + .inc + .cpp + .cls + .c + .hpp + .vbs + .java + .cs + .cxx + .h + .jav + .bas + .hxx + .js + .pl + .rc + .vb + .json + .resjson + .fs + .fsi + .fsx + .m + .psm1 + .config + .ps1 + .psd1 + .cmake + .sh + .cshtml + .plist + .mof + .mc + + + + XML Files + + .xml + .hxa + .hxk + .hxl + .xsl + .hxc + .hxt + .hxm + .resx + .hxe + .hxf + .hxv + .acctb + .accfl + .xaml + .ttml + .ddue + .sln + .props + .ps1xml + .csproj + .xsd + .svg + .clixml + .nuspec + .cdxml + .manifest + + + + Microsoft Word Documents + + .doc + .dot + .wiz + + + + Microsoft Access Database Compatible + + .mdb + .mda + .mde + .mpd + .mdt + + + + Microsoft PowerPoint Presentation + + .ppt + .pot + .pps + + + + Microsoft Publisher Files + + .pub + + + + Microsoft Excel Workbooks + + .xls + .xlt + + + + Pure Binary Files + + .com + .bin + .tlb + .drv + .fon + .blg + .gif + .png + .icns + .ico + .bmp + .pfx + + + + Localization resource databases + + .edb + .lcl + .xlf + .xliff + + + + Microsoft Project Files + + .mpp + .mpt + + + + Microsoft Visio Files + + .vsd + .vdx + .vss + .vst + + + + Windows Installer databases + + .msi + .msm + + + + Zip Files + + .zip + .accdt + .axtr + + + + Cabinet / MS Compression Files + + .cab + + + + Table driven IME lexicons + + .mb + + + + IME ( IMD ) Files + + .imd + + + + TrueType Font Files + + .ttf + + + + Microsoft Outlook Mail Files + + .msg + .oft + + + + HTML Help 2.0 Files / InfoTech5.x Storage System Files + + .its + .hxh + .hxr + .hxw + .hxi + .hxs + .hxq + + + + Adobe Acrobat PDF Files + + .pdf + + + + HTML Files / Web Page + + .htm + .dtd + .hhk + .htw + .asp + .htc + .htx + .html + .hhc + .css + .stm + + + + Rich Text Files + + .rtf + + + + Windows 3.x Write Files + + .wri + + + + MHTML Files + + .eml + .nws + .mht + + + + Word 2007 Files + + .docx + .docm + .dotx + .dotm + + + + Excel 2007 Files + + .xlsx + .xlsm + .xltx + .xltm + .xlsb + .xlam + + + + Power Point 2007 Files + + .pptx + .pptm + .potx + .potm + .ppsx + .ppsm + .ppam + + + + Access 2007 Files + + .accdb + .accde + .accdr + + + + Win32/64-based executable (image) Files + + .exe + .dll + .ocx + .scr + .acm + .rll + .cpl + .mui + .ax + .ime + + + + HTML Help 1.0 Files + + .chm + + + + LocStudio lsg + + .lsg + + + + Microsoft Office OneNote Files + + .one + .onepkg + + + + Custom Parsers + + + + + Visio 2011 Files + + .vstx + .vsdx + .vssx + + + + + From e5cdcd17f4ce85737ea292825b14b86a5db6dd26 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 17 Sep 2019 16:27:42 -0700 Subject: [PATCH 03/14] add codebasename --- .vsts-ci/templates/release-general.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vsts-ci/templates/release-general.yml b/.vsts-ci/templates/release-general.yml index 712758529..4cca3652e 100644 --- a/.vsts-ci/templates/release-general.yml +++ b/.vsts-ci/templates/release-general.yml @@ -111,7 +111,7 @@ inputs: tsaVersion: 'TsaV2' codebase: 'Existing' tsaEnvironment: 'PROD' - codeBaseName: 'PowerShell_GraphicalTools_20190809' + codeBaseName: 'PowerShell_PowerShellEditorServices_20190917' uploadAPIScan: false uploadBinSkim: true uploadCredScan: true From 9bdaa714449e703ee1ec059469578d867dd25821 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 17 Sep 2019 16:29:35 -0700 Subject: [PATCH 04/14] whitespace --- .vsts-ci/templates/release-general.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.vsts-ci/templates/release-general.yml b/.vsts-ci/templates/release-general.yml index 4cca3652e..b39edc490 100644 --- a/.vsts-ci/templates/release-general.yml +++ b/.vsts-ci/templates/release-general.yml @@ -1,8 +1,8 @@ steps: - pwsh: | - Get-ChildItem -Path env: - displayName: Capture environment - condition: succeededOrFailed() + Get-ChildItem -Path env: + displayName: Capture environment + condition: succeededOrFailed() - task: PkgESSetupBuild@10 displayName: 'Package ES - Setup Build' From fd975d59aa217bcf56cb0e3dceadbea4238c0fcb Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 17 Sep 2019 16:31:09 -0700 Subject: [PATCH 05/14] whitespace --- .vsts-ci/templates/release-general.yml | 38 +++++++++++++------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.vsts-ci/templates/release-general.yml b/.vsts-ci/templates/release-general.yml index b39edc490..35ab368fa 100644 --- a/.vsts-ci/templates/release-general.yml +++ b/.vsts-ci/templates/release-general.yml @@ -25,13 +25,13 @@ steps: $psesZip | Remove-Item -Recurse -Force - task: PkgESCodeSign@10 - displayName: 'CodeSign tools/releaseBuild/signing.xml' - env: - SYSTEM_ACCESSTOKEN: $(System.AccessToken) - inputs: - signConfigXml: tools/releaseBuild/signing.xml - inPathRoot: '$(Build.ArtifactStagingDirectory)' - outPathRoot: '$(Build.ArtifactStagingDirectory)\Signed' + displayName: 'CodeSign tools/releaseBuild/signing.xml' + env: + SYSTEM_ACCESSTOKEN: $(System.AccessToken) + inputs: + signConfigXml: tools/releaseBuild/signing.xml + inPathRoot: '$(Build.ArtifactStagingDirectory)' + outPathRoot: '$(Build.ArtifactStagingDirectory)\Signed' - task: PowerShell@1 displayName: 'Copy signed items into output' @@ -61,10 +61,10 @@ steps: outPathRoot: '$(System.ArtifactsDirectory)' - task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0 - displayName: 'Component Detection' + displayName: 'Component Detection' - task: AntiMalware@3 -inputs: + inputs: InputType: 'Basic' ScanType: 'CustomScan' FileDirPath: '$(Build.ArtifactStagingDirectory)' @@ -75,8 +75,8 @@ inputs: TreatStaleSignatureAs: 'Error' - task: PoliCheck@1 -condition: succeededOrFailed() -inputs: + condition: succeededOrFailed() + inputs: targetType: F optionsFC: 0 optionsXS: 0 @@ -86,11 +86,11 @@ inputs: # toolVersion: 5.8.2.1 - task: CredScan@2 -condition: succeededOrFailed() + condition: succeededOrFailed() - task: BinSkim@3 -condition: succeededOrFailed() -inputs: + condition: succeededOrFailed() + inputs: InputType: 'Basic' Function: 'analyze' AnalyzeRecurse: true @@ -98,16 +98,16 @@ inputs: # Publish results as artifacts - task: PublishSecurityAnalysisLogs@3 -condition: succeededOrFailed() -inputs: + condition: succeededOrFailed() + inputs: ArtifactName: 'CodeAnalysisLogs' ArtifactType: 'Container' # Publish to TSA server - task: TSAUpload@1 -condition: succeededOrFailed() -continueOnError: true -inputs: + condition: succeededOrFailed() + continueOnError: true + inputs: tsaVersion: 'TsaV2' codebase: 'Existing' tsaEnvironment: 'PROD' From f9a50c363ee02f95b8aa1a56e50f504bf4ad6965 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 17 Sep 2019 16:32:14 -0700 Subject: [PATCH 06/14] jobs --- .vsts-ci/azure-pipelines-release.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.vsts-ci/azure-pipelines-release.yml b/.vsts-ci/azure-pipelines-release.yml index 5817542b0..93ebf460a 100644 --- a/.vsts-ci/azure-pipelines-release.yml +++ b/.vsts-ci/azure-pipelines-release.yml @@ -40,13 +40,7 @@ jobs: vmImage: 'vs2017-win2016' steps: - template: templates/ci-general.yml -- job: - dependsOn: 'Build' - displayName: 'Sign release and package' - pool: - vmImage: 'vs2017-win2016' - steps: - - template: templates/release-general.yml + - job: 'SignBuild' displayName: Signing Build dependsOn: 'ReleaseBuild' From eeafe4faa6e89f366e9b426726cfc45540189646 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 17 Sep 2019 16:45:49 -0700 Subject: [PATCH 07/14] skip binskim for now --- .vsts-ci/templates/release-general.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.vsts-ci/templates/release-general.yml b/.vsts-ci/templates/release-general.yml index 35ab368fa..e63301064 100644 --- a/.vsts-ci/templates/release-general.yml +++ b/.vsts-ci/templates/release-general.yml @@ -88,13 +88,13 @@ steps: - task: CredScan@2 condition: succeededOrFailed() -- task: BinSkim@3 - condition: succeededOrFailed() - inputs: - InputType: 'Basic' - Function: 'analyze' - AnalyzeRecurse: true - AnalyzeTarget: '$(Build.ArtifactStagingDirectory)\Microsoft.PowerShell.GraphicalTools.dll;$(Build.ArtifactStagingDirectory)\OutGridView*.dll' +# - task: BinSkim@3 +# condition: succeededOrFailed() +# inputs: +# InputType: 'Basic' +# Function: 'analyze' +# AnalyzeRecurse: true +# AnalyzeTarget: '$(Build.ArtifactStagingDirectory)\release;$(Build.ArtifactStagingDirectory)\OutGridView*.dll' # Publish results as artifacts - task: PublishSecurityAnalysisLogs@3 @@ -113,7 +113,7 @@ steps: tsaEnvironment: 'PROD' codeBaseName: 'PowerShell_PowerShellEditorServices_20190917' uploadAPIScan: false - uploadBinSkim: true + uploadBinSkim: false uploadCredScan: true uploadFortifySCA: false uploadFxCop: false From f7d843391adb98134d7683ae7e55c8f8c29a5830 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 17 Sep 2019 16:52:18 -0700 Subject: [PATCH 08/14] fix extract script --- .vsts-ci/templates/release-general.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.vsts-ci/templates/release-general.yml b/.vsts-ci/templates/release-general.yml index e63301064..193a647b4 100644 --- a/.vsts-ci/templates/release-general.yml +++ b/.vsts-ci/templates/release-general.yml @@ -19,9 +19,9 @@ steps: inputs: scriptType: inlineScript inlineScript: | - New-Item -ItemType Directory $env:BUILD_ARTIFACTSTAGINGDIRECTORY/release/out + $dest = New-Item -ItemType Directory $env:BUILD_ARTIFACTSTAGINGDIRECTORY/release/out/PowerShellEditorServices $psesZip = Get-ChildItem $env:BUILD_ARTIFACTSTAGINGDIRECTORY/PowerShellEditorServices*.zip - $psesZip | Expand-Archive -Path $env:BUILD_ARTIFACTSTAGINGDIRECTORY/release/out + $psesZip | Expand-Archive -DestinationPath $dest -Force $psesZip | Remove-Item -Recurse -Force - task: PkgESCodeSign@10 From ca33bd04d3e40ecc0bfcd56908ea106a5f21963e Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 17 Sep 2019 16:54:25 -0700 Subject: [PATCH 09/14] fix all env vars --- .vsts-ci/templates/release-general.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.vsts-ci/templates/release-general.yml b/.vsts-ci/templates/release-general.yml index 193a647b4..78ba5156c 100644 --- a/.vsts-ci/templates/release-general.yml +++ b/.vsts-ci/templates/release-general.yml @@ -38,8 +38,8 @@ steps: inputs: scriptType: inlineScript inlineScript: | - $signed="$(System.ArtifactsDirectory)\Signed\PowerShellEditorServices\*" - $notSigned="$(System.ArtifactsDirectory)\release\out\PowerShellEditorServices" + $signed="$(Build.ArtifactStagingDirectory)\Signed\PowerShellEditorServices\*" + $notSigned="$(Build.ArtifactStagingDirectory)\release\out\PowerShellEditorServices" Copy-Item $signed $notSigned -Recurse -Force - task: PowerShell@1 @@ -47,18 +47,18 @@ steps: inputs: scriptType: inlineScript inlineScript: | - $dir = "$(System.ArtifactsDirectory)\release\out\PowerShellEditorServices\PowerShellEditorServices" - New-FileCatalog -CatalogFilePath "$(System.ArtifactsDirectory)\PowerShellEditorServices.cat" -Path $dir + $dir = "$(Build.ArtifactStagingDirectory)\release\out\PowerShellEditorServices\PowerShellEditorServices" + New-FileCatalog -CatalogFilePath "$(Build.ArtifactStagingDirectory)\PowerShellEditorServices.cat" -Path $dir - $dir = "$(System.ArtifactsDirectory)\release\out\PowerShellEditorServices\PowerShellEditorServices.VSCode" - New-FileCatalog -CatalogFilePath "$(System.ArtifactsDirectory)\PowerShellEditorServices.VSCode.cat" -Path $dir + $dir = "$(Build.ArtifactStagingDirectory)\release\out\PowerShellEditorServices\PowerShellEditorServices.VSCode" + New-FileCatalog -CatalogFilePath "$(Build.ArtifactStagingDirectory)\PowerShellEditorServices.VSCode.cat" -Path $dir - task: PkgESCodeSign@10 displayName: 'CodeSign tools/releaseBuild/FileCatalogSigning.xml' inputs: signConfigXml: tools/releaseBuild/FileCatalogSigning.xml - inPathRoot: '$(System.ArtifactsDirectory)' - outPathRoot: '$(System.ArtifactsDirectory)' + inPathRoot: '$(Build.ArtifactStagingDirectory)' + outPathRoot: '$(Build.ArtifactStagingDirectory)' - task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0 displayName: 'Component Detection' @@ -128,4 +128,4 @@ steps: displayName: 'Upload artifacts' inputs: scriptType: inlineScript - inlineScript: 'Write-Host "##vso[artifact.upload containerfolder=PowerShellEditorServices;artifactname=PowerShellEditorServices]$(System.ArtifactsDirectory)\release\out\PowerShellEditorServices"' + inlineScript: 'Write-Host "##vso[artifact.upload containerfolder=PowerShellEditorServices;artifactname=PowerShellEditorServices]$(Build.ArtifactStagingDirectory)\release\out\PowerShellEditorServices"' From 650004baddd40feb410b8aa0e8fbec4d9cfbb78c Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 17 Sep 2019 17:09:21 -0700 Subject: [PATCH 10/14] paths are hard --- .vsts-ci/templates/release-general.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vsts-ci/templates/release-general.yml b/.vsts-ci/templates/release-general.yml index 78ba5156c..4793ab949 100644 --- a/.vsts-ci/templates/release-general.yml +++ b/.vsts-ci/templates/release-general.yml @@ -19,7 +19,7 @@ steps: inputs: scriptType: inlineScript inlineScript: | - $dest = New-Item -ItemType Directory $env:BUILD_ARTIFACTSTAGINGDIRECTORY/release/out/PowerShellEditorServices + $dest = New-Item -ItemType Directory $env:BUILD_ARTIFACTSTAGINGDIRECTORY/../release/out/PowerShellEditorServices $psesZip = Get-ChildItem $env:BUILD_ARTIFACTSTAGINGDIRECTORY/PowerShellEditorServices*.zip $psesZip | Expand-Archive -DestinationPath $dest -Force $psesZip | Remove-Item -Recurse -Force From 27cfc192d30b398fa014615c350283ad7e76fc4e Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 17 Sep 2019 17:17:57 -0700 Subject: [PATCH 11/14] better zip --- .vsts-ci/templates/release-general.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.vsts-ci/templates/release-general.yml b/.vsts-ci/templates/release-general.yml index 4793ab949..d441abd3c 100644 --- a/.vsts-ci/templates/release-general.yml +++ b/.vsts-ci/templates/release-general.yml @@ -19,9 +19,9 @@ steps: inputs: scriptType: inlineScript inlineScript: | - $dest = New-Item -ItemType Directory $env:BUILD_ARTIFACTSTAGINGDIRECTORY/../release/out/PowerShellEditorServices - $psesZip = Get-ChildItem $env:BUILD_ARTIFACTSTAGINGDIRECTORY/PowerShellEditorServices*.zip - $psesZip | Expand-Archive -DestinationPath $dest -Force + $dest = New-Item -ItemType Directory $env:BUILD_ARTIFACTSTAGINGDIRECTORY/release/out/PowerShellEditorServices + $psesZip = Get-ChildItem $env:BUILD_ARTIFACTSTAGINGDIRECTORY/PowerShellEditorServices/PowerShellEditorServices*.zip -ErrorAction Stop + $psesZip | Expand-Archive -DestinationPath $dest -Force -Verbose $psesZip | Remove-Item -Recurse -Force - task: PkgESCodeSign@10 From 3e0997481ec76f8f88c7120cf7b3a3aa6b341a84 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Thu, 19 Sep 2019 15:03:11 -0700 Subject: [PATCH 12/14] forgot access token --- .vsts-ci/templates/release-general.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.vsts-ci/templates/release-general.yml b/.vsts-ci/templates/release-general.yml index d441abd3c..89c93a843 100644 --- a/.vsts-ci/templates/release-general.yml +++ b/.vsts-ci/templates/release-general.yml @@ -55,6 +55,8 @@ steps: - task: PkgESCodeSign@10 displayName: 'CodeSign tools/releaseBuild/FileCatalogSigning.xml' + env: + SYSTEM_ACCESSTOKEN: $(System.AccessToken) inputs: signConfigXml: tools/releaseBuild/FileCatalogSigning.xml inPathRoot: '$(Build.ArtifactStagingDirectory)' From 8fecd1c56f017260e3f4f75f0092220f90f1817a Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Thu, 19 Sep 2019 15:30:24 -0700 Subject: [PATCH 13/14] move ci to a PSES-CI folder --- .vsts-ci/templates/ci-general.yml | 2 +- .vsts-ci/templates/release-general.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.vsts-ci/templates/ci-general.yml b/.vsts-ci/templates/ci-general.yml index 664d41d9e..905802378 100644 --- a/.vsts-ci/templates/ci-general.yml +++ b/.vsts-ci/templates/ci-general.yml @@ -21,5 +21,5 @@ steps: condition: succeededOrFailed() - task: PublishBuildArtifacts@1 inputs: - ArtifactName: PowerShellEditorServices + ArtifactName: PowerShellEditorServices-CI PathtoPublish: '$(Build.ArtifactStagingDirectory)' diff --git a/.vsts-ci/templates/release-general.yml b/.vsts-ci/templates/release-general.yml index 89c93a843..fd477c057 100644 --- a/.vsts-ci/templates/release-general.yml +++ b/.vsts-ci/templates/release-general.yml @@ -20,7 +20,7 @@ steps: scriptType: inlineScript inlineScript: | $dest = New-Item -ItemType Directory $env:BUILD_ARTIFACTSTAGINGDIRECTORY/release/out/PowerShellEditorServices - $psesZip = Get-ChildItem $env:BUILD_ARTIFACTSTAGINGDIRECTORY/PowerShellEditorServices/PowerShellEditorServices*.zip -ErrorAction Stop + $psesZip = Get-ChildItem $env:BUILD_ARTIFACTSTAGINGDIRECTORY/PowerShellEditorServices-CI/PowerShellEditorServices*.zip -ErrorAction Stop $psesZip | Expand-Archive -DestinationPath $dest -Force -Verbose $psesZip | Remove-Item -Recurse -Force From e790983eb2794938d593226eede42aced5e0aa36 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Thu, 19 Sep 2019 16:58:21 -0700 Subject: [PATCH 14/14] delete leftover release build stuff --- tools/releaseBuild/Image/DockerFile | 30 ------ tools/releaseBuild/Image/build.ps1 | 23 ---- tools/releaseBuild/Image/dockerInstall.psm1 | 114 -------------------- tools/releaseBuild/build.json | 19 ---- tools/releaseBuild/vstsbuild.ps1 | 78 -------------- 5 files changed, 264 deletions(-) delete mode 100644 tools/releaseBuild/Image/DockerFile delete mode 100644 tools/releaseBuild/Image/build.ps1 delete mode 100644 tools/releaseBuild/Image/dockerInstall.psm1 delete mode 100644 tools/releaseBuild/build.json delete mode 100644 tools/releaseBuild/vstsbuild.ps1 diff --git a/tools/releaseBuild/Image/DockerFile b/tools/releaseBuild/Image/DockerFile deleted file mode 100644 index e250a6795..000000000 --- a/tools/releaseBuild/Image/DockerFile +++ /dev/null @@ -1,30 +0,0 @@ -# escape=` -#0.3.6 (no powershell 6) -FROM microsoft/dotnet-framework:4.7.1 -LABEL maintainer='PowerShell Team ' -LABEL description="Build's PowerShell Editor Services" - -SHELL ["C:\\windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-command"] - -COPY dockerInstall.psm1 containerFiles/dockerInstall.psm1 - -RUN Import-Module PackageManagement; ` - Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force; ` - Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | Out-Null; ` - Invoke-WebRequest -Uri https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.ps1 -outfile C:/dotnet-install.ps1; ` - C:/dotnet-install.ps1 -Channel Release -Version 2.1.4; ` - Add-Path C:/Users/ContainerAdministrator/AppData/Local/Microsoft/dotnet; ` - Install-Module InvokeBuild -MaximumVersion 5.1.0 -Scope CurrentUser -Force; ` - Install-Module platyPS -RequiredVersion 0.9.0 -Scope CurrentUser -Force; - -RUN Install-Module -Name PowerShellGet -Force; - -# Copy build script over -COPY build.ps1 containerFiles/build.ps1 - -# Uncomment to debug locally -# RUN Import-Module ./containerFiles/dockerInstall.psm1; ` -# Install-ChocolateyPackage -PackageName git -Executable git.exe; ` -# git clone https://github.com/PowerShell/PowerShellEditorServices; - -ENTRYPOINT ["C:\\windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-command"] diff --git a/tools/releaseBuild/Image/build.ps1 b/tools/releaseBuild/Image/build.ps1 deleted file mode 100644 index ca98b4d73..000000000 --- a/tools/releaseBuild/Image/build.ps1 +++ /dev/null @@ -1,23 +0,0 @@ -param ( [string]$target ) - -# Test that we have allocated enough memory -$memoryMB = (Get-CimInstance win32_computersystem).TotalPhysicalMemory /1MB -$requiredMemoryMB = 2048 -if($memoryMB -lt $requiredMemoryMB) -{ - throw "Building powershell requires at least $requiredMemoryMB MiB of memory and only $memoryMB MiB is present." -} - -# Create the target directory. Delete if it already exists -if ( ! (test-path ${target} ) ) { - new-item -type directory ${target} -} -else { - if ( test-path -pathtype leaf ${target} ) { - remove-item -force ${target} - new-item -type directory ${target} - } -} -push-location C:/PowerShellEditorServices -Invoke-Build GetProductVersion,Clean,Build,BuildCmdletHelp,PackageNuget,PackageModule,UploadArtifacts -Configuration Release -Copy-Item -Verbose -Recurse "C:/PowerShellEditorServices/module" "${target}/PowerShellEditorServices" diff --git a/tools/releaseBuild/Image/dockerInstall.psm1 b/tools/releaseBuild/Image/dockerInstall.psm1 deleted file mode 100644 index 143334e27..000000000 --- a/tools/releaseBuild/Image/dockerInstall.psm1 +++ /dev/null @@ -1,114 +0,0 @@ -function Install-ChocolateyPackage -{ - param( - [Parameter(Mandatory=$true)] - [string] - $PackageName, - - [Parameter(Mandatory=$false)] - [string] - $Executable, - - [string[]] - $ArgumentList, - - [switch] - $Cleanup, - - [int] - $ExecutionTimeout = 2700, - - [string] - $Version - ) - - if(-not(Get-Command -name Choco -ErrorAction SilentlyContinue)) - { - Write-Verbose "Installing Chocolatey provider..." -Verbose - Invoke-WebRequest https://chocolatey.org/install.ps1 -UseBasicParsing | Invoke-Expression - } - - Write-Verbose "Installing $PackageName..." -Verbose - $extraCommand = @() - if($Version) - { - $extraCommand += '--version', $version - } - choco install -y $PackageName --no-progress --execution-timeout=$ExecutionTimeout $ArgumentList $extraCommands - - if($executable) - { - Write-Verbose "Verifing $Executable is in path..." -Verbose - $exeSource = $null - $exeSource = Get-ChildItem -path "$env:ProgramFiles\$Executable" -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty FullName - if(!$exeSource) - { - Write-Verbose "Falling back to x86 program files..." -Verbose - $exeSource = Get-ChildItem -path "${env:ProgramFiles(x86)}\$Executable" -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty FullName - } - - # Don't search the chocolatey program data until more official locations have been searched - if(!$exeSource) - { - Write-Verbose "Falling back to chocolatey..." -Verbose - $exeSource = Get-ChildItem -path "$env:ProgramData\chocolatey\$Executable" -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty FullName - } - - # all obvious locations are exhausted, use brute force and search from the root of the filesystem - if(!$exeSource) - { - Write-Verbose "Falling back to the root of the drive..." -Verbose - $exeSource = Get-ChildItem -path "/$Executable" -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty FullName - } - - if(!$exeSource) - { - throw "$Executable not found" - } - - $exePath = Split-Path -Path $exeSource - Add-Path -path $exePath - } - - if($Cleanup.IsPresent) - { - Remove-Folder -Folder "$env:temp\chocolatey" - } -} - -function Add-Path -{ - param - ( - $path - ) - $machinePathString = [System.Environment]::GetEnvironmentVariable('path',[System.EnvironmentVariableTarget]::Machine) - $machinePath = $machinePathString -split ';' - - if($machinePath -inotcontains $path) - { - $newPath = "$machinePathString;$path" - Write-Verbose "Adding $path to path..." -Verbose - [System.Environment]::SetEnvironmentVariable('path',$newPath,[System.EnvironmentVariableTarget]::Machine) - Write-Verbose "Added $path to path." -Verbose - $env:Path += ";$newPath" - } - else - { - Write-Verbose "$path already in path." -Verbose - } -} - -function Remove-Folder -{ - param( - [string] - $Folder - ) - - Write-Verbose "Cleaning up $Folder..." -Verbose - $filter = Join-Path -Path $Folder -ChildPath * - [int]$measuredCleanupMB = (Get-ChildItem $filter -Recurse | Measure-Object -Property Length -Sum).Sum / 1MB - Remove-Item -recurse -force $filter -ErrorAction SilentlyContinue - Write-Verbose "Cleaned up $measuredCleanupMB MB from $Folder" -Verbose -} diff --git a/tools/releaseBuild/build.json b/tools/releaseBuild/build.json deleted file mode 100644 index 21e118aa2..000000000 --- a/tools/releaseBuild/build.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "Windows": { - "Name": "win7-x64", - "RepoDestinationPath": "C:\\PowerShellEditorServices", - "BuildCommand": "C:\\containerFiles\\build.ps1 -target _DockerVolume_", - "DockerFile": ".\\tools\\releaseBuild\\Image\\DockerFile", - "DockerImageName": "powershelleditorservices", - "BinaryBucket": "release", - "PublishAsFolder": true, - "BuildDockerOptions": [ - "-m", - "4096m" - ], - "AdditionalContextFiles" : [ - ".\\tools\\releaseBuild\\Image\\build.ps1", - ".\\tools\\releaseBuild\\Image\\dockerInstall.psm1" - ] - } -} diff --git a/tools/releaseBuild/vstsbuild.ps1 b/tools/releaseBuild/vstsbuild.ps1 deleted file mode 100644 index 15f5a5343..000000000 --- a/tools/releaseBuild/vstsbuild.ps1 +++ /dev/null @@ -1,78 +0,0 @@ -[cmdletbinding()] -param() - -Begin -{ - $ErrorActionPreference = 'Stop' - - $gitBinFullPath = (Get-Command -Name git -CommandType Application).Path | Select-Object -First 1 - if ( ! $gitBinFullPath ) - { - throw "Git is missing! Install from 'https://git-scm.com/download/win'" - } - - # clone the release tools - $releaseToolsDirName = "PSRelease" - $releaseToolsLocation = Join-Path -Path $PSScriptRoot -ChildPath PSRelease - if ( Test-Path $releaseToolsLocation ) - { - Remove-Item -Force -Recurse -Path $releaseToolsLocation - } - & $gitBinFullPath clone -b master --quiet https://github.com/PowerShell/${releaseToolsDirName}.git $releaseToolsLocation - Import-Module "$releaseToolsLocation/vstsBuild" -Force - Import-Module "$releaseToolsLocation/dockerBasedBuild" -Force -Prefix DockerBased - - # Get the update signing script and update the signing XML file - $updateSigningPath = Join-Path $releaseToolsLocation 'updateSigning.ps1' - Invoke-WebRequest -Uri 'https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/releaseBuild/updateSigning.ps1' -OutFile $updateSigningPath - & $updateSigningPath -SigningXmlPath (Join-Path $PSScriptRoot 'signing.xml') -} - -End { - - $AdditionalFiles = .{ - Join-Path $PSScriptRoot -child "Image/build.ps1" - Join-Path $PSScriptRoot -child "Image/dockerInstall.psm1" - } - $buildPackageName = $null - - # defined if building in VSTS - if($env:BUILD_STAGINGDIRECTORY) - { - # Use artifact staging if running in VSTS - $destFolder = $env:BUILD_STAGINGDIRECTORY - } - else - { - # Use temp as destination if not running in VSTS - $destFolder = $env:temp - } - - $resolvedRepoRoot = (Resolve-Path (Join-Path -Path $PSScriptRoot -ChildPath "../../")).Path - - try - { - Write-Verbose "Starting build at $resolvedRepoRoot ..." -Verbose - Clear-VstsTaskState - - $buildParameters = @{ - ReleaseTag = $ReleaseTag - } - $buildArgs = @{ - RepoPath = $resolvedRepoRoot - BuildJsonPath = './tools/releaseBuild/build.json' - Parameters = $buildParameters - AdditionalFiles = $AdditionalFiles - Name = "win7-x64" - } - Invoke-DockerBasedBuild @buildArgs - } - catch - { - Write-VstsError -Error $_ - } - finally{ - Write-VstsTaskState - exit 0 - } -}