diff --git a/.vsts-ci/azure-pipelines-release.yml b/.vsts-ci/azure-pipelines-release.yml new file mode 100644 index 0000000000..31e1b812ef --- /dev/null +++ b/.vsts-ci/azure-pipelines-release.yml @@ -0,0 +1,43 @@ +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: 'ReleaseBuild' + displayName: 'Build release' + 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 new file mode 100644 index 0000000000..263cf4f8fb --- /dev/null +++ b/.vsts-ci/templates/release-general.yml @@ -0,0 +1,121 @@ +steps: +- pwsh: Write-Host "##vso[build.updatebuildnumber]$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhmmss"))" + displayName: Set Build Name for Non-PR + condition: ne(variables['Build.Reason'], 'PullRequest') + +- pwsh: | + Get-ChildItem -Path env: + displayName: Capture environment + condition: succeededOrFailed() + +- task: PkgESSetupBuild@10 + displayName: 'Package ES - Setup Build' + inputs: + productName: vscode-powershell + +- task: PowerShell@2 + displayName: 'Set environment variables for VSTS (Phase 1)' + inputs: + targetType: filePath + filePath: ./tools/releaseBuild/setVstsVariables.ps1 + +- task: PowerShell@2 + displayName: 'Find PowerShellEditorServices build' + env: + SYSTEM_ACCESSTOKEN: $(System.AccessToken) + inputs: + targetType: filePath + filePath: ./tools/releaseBuild/findPsesBuild.ps1 + +- task: DownloadBuildArtifacts@0 + displayName: 'Download Build Artifacts from PowerShell Editor Services' + inputs: + buildType: specific + project: '8e2735c1-3674-408a-bcab-87f089ea29d5' + pipeline: 1056 + buildVersionToDownload: specific + buildId: '$(PSES_BUILDID)' + downloadType: single + artifactName: 'PowerShellEditorServices' + downloadPath: '$(Build.SourcesDirectory)' + +- pwsh: | + Install-Module InvokeBuild -Force + Invoke-Build Release + +- task: PublishTestResults@2 + inputs: + testRunner: JUnit + testResultsFiles: '**/test-results.xml' + condition: succeededOrFailed() + +- 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' + +- 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() + +# 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_PowerShellEditorServices_20190917' + uploadAPIScan: false + uploadBinSkim: false + 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: + scriptType: inlineScript + inlineScript: 'Write-Host "##vso[artifact.upload containerfolder=vscode-powershell;artifactname=vscode-powershell]$(System.ArtifactsDirectory)\Signed"' diff --git a/tools/releaseBuild/Image/DockerFile b/tools/releaseBuild/Image/DockerFile deleted file mode 100644 index 5ef5718610..0000000000 --- a/tools/releaseBuild/Image/DockerFile +++ /dev/null @@ -1,34 +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; ` - Install-Module InvokeBuild -MaximumVersion 5.1.0 -Scope CurrentUser -Force; ` - Install-Module platyPS -RequiredVersion 0.9.0 -Scope CurrentUser -Force; - -# Install Nodejs -RUN Import-Module ./containerFiles/dockerInstall.psm1; ` - Install-ChocolateyPackage -PackageName nodejs-lts -Executable node.exe; - -# Copy build script over -COPY build.ps1 containerFiles/build.ps1 - -# Add an environment variable for build versioning -ENV VSTS_BUILD=1 -ENV VSTS_BUILD_VERSION=1.12.1 - -# 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 b4014d7f3e..0000000000 --- a/tools/releaseBuild/Image/build.ps1 +++ /dev/null @@ -1,13 +0,0 @@ -param ( [string]$target ) -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:/vscode-powershell -Invoke-Build Release -Copy-Item -Verbose -Recurse "C:/vscode-powershell/PowerShell-insiders.vsix" "${target}/PowerShell-insiders.vsix" diff --git a/tools/releaseBuild/Image/dockerInstall.psm1 b/tools/releaseBuild/Image/dockerInstall.psm1 deleted file mode 100644 index 143334e273..0000000000 --- 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 2115a64f63..0000000000 --- a/tools/releaseBuild/build.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "Windows": { - "Name": "win7-x64", - "RepoDestinationPath": "C:\\vscode-powershell", - "BuildCommand": "C:\\containerFiles\\build.ps1 -target _DockerVolume_", - "DockerFile": ".\\tools\\releaseBuild\\Image\\DockerFile", - "DockerImageName": "vscodepowershell", - "BinaryBucket": "release", - "PublishAsFolder": true, - "AdditionalContextFiles" : [ - ".\\tools\\releaseBuild\\Image\\build.ps1", - ".\\tools\\releaseBuild\\Image\\dockerInstall.psm1" - ] - } -} diff --git a/tools/releaseBuild/findPsesBuild.ps1 b/tools/releaseBuild/findPsesBuild.ps1 index 01df27b3e3..bc575b7feb 100644 --- a/tools/releaseBuild/findPsesBuild.ps1 +++ b/tools/releaseBuild/findPsesBuild.ps1 @@ -1,9 +1,21 @@ $branch = [uri]::EscapeDataString($env:PSES_BRANCH) -$buildsUrl = $env:VSTS_PSES_URL_TEMPLATE -f $branch $headers = @{Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"} -$builds = Invoke-RestMethod -ContentType application/json -Uri $buildsUrl -Headers $headers -Write-Host "Got PSES_BRANCH: ${env:PSES_BRANCH}" + +$buildsUrl = $env:VSTS_PSES_URL_TEMPLATE -f $branch, "succeeded" +$succeededBuilds = Invoke-RestMethod -ContentType application/json -Uri $buildsUrl -Headers $headers +Write-Host "Requested URL: $buildsUrl" +Write-Host "Got response:`n$(ConvertTo-Json $succeededBuilds)" + +$buildsUrl = $env:VSTS_PSES_URL_TEMPLATE -f $branch, "partiallySucceeded" +$partiallySucceededBuilds = Invoke-RestMethod -ContentType application/json -Uri $buildsUrl -Headers $headers Write-Host "Requested URL: $buildsUrl" -Write-Host "Got response:`n$(ConvertTo-Json $builds)" -Write-Host "setting PSES_BUILDID to $($builds.value[0].Id)" -Write-Host "##vso[task.setvariable variable=PSES_BUILDID]$($builds.value[0].Id)" \ No newline at end of file +Write-Host "Got response:`n$(ConvertTo-Json $partiallySucceededBuilds)" + +$builds = @( + $succeededBuilds.value + $partiallySucceededBuilds.value + ) | Sort-Object finishTime -Descending + +Write-Host "Got PSES_BRANCH: ${env:PSES_BRANCH}" +Write-Host "setting PSES_BUILDID to $($builds[0].Id)" +Write-Host "##vso[task.setvariable variable=PSES_BUILDID]$($builds[0].Id)" diff --git a/tools/releaseBuild/signing.xml b/tools/releaseBuild/signing.xml index ae9af1aa5a..89bd6d853f 100644 --- a/tools/releaseBuild/signing.xml +++ b/tools/releaseBuild/signing.xml @@ -1,7 +1,7 @@ - diff --git a/tools/releaseBuild/vstsbuild.ps1 b/tools/releaseBuild/vstsbuild.ps1 deleted file mode 100644 index 1d78994f7b..0000000000 --- a/tools/releaseBuild/vstsbuild.ps1 +++ /dev/null @@ -1,79 +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" - "$env:BUILD_ARTIFACTSTAGINGDIRECTORY\PowerShellEditorServices" - } - $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 - } -} diff --git a/tools/terms/FileTypeSet.xml b/tools/terms/FileTypeSet.xml new file mode 100644 index 0000000000..82f9f4d09e --- /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 + + + + + diff --git a/vscode-powershell.build.ps1 b/vscode-powershell.build.ps1 index 8b8e448a96..704c281f2d 100644 --- a/vscode-powershell.build.ps1 +++ b/vscode-powershell.build.ps1 @@ -188,11 +188,15 @@ task Package UpdateReadme, { # Change the package to have a static name for automation purposes Move-Item -Force .\$($script:PackageJson.name)-$($script:PackageJson.version).vsix .\PowerShell-insiders.vsix + + if ($env:TF_BUILD) { + Copy-Item -Path PowerShell-insiders.vsix -Destination $env:BUILD_ARTIFACTSTAGINGDIRECTORY + } } #endregion # The set of tasks for a release -task Release Clean, Build, Test, Package +task Release Clean, Build, Package # The default task is to run the entire CI build task . Clean, BuildAll, Test, UpdatePackageJson, Package, UploadArtifacts