diff --git a/.vsts-ci/azure-pipelines-release.yml b/.vsts-ci/azure-pipelines-release.yml new file mode 100644 index 000000000..93ebf460a --- /dev/null +++ b/.vsts-ci/azure-pipelines-release.yml @@ -0,0 +1,51 @@ +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: + vmImage: 'vs2017-win2016' + steps: + - template: templates/ci-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/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 new file mode 100644 index 000000000..fd477c057 --- /dev/null +++ b/.vsts-ci/templates/release-general.yml @@ -0,0 +1,133 @@ +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' + inputs: + downloadType: specific + +- task: PowerShell@1 + displayName: 'Extract build zip' + inputs: + scriptType: inlineScript + inlineScript: | + $dest = New-Item -ItemType Directory $env:BUILD_ARTIFACTSTAGINGDIRECTORY/release/out/PowerShellEditorServices + $psesZip = Get-ChildItem $env:BUILD_ARTIFACTSTAGINGDIRECTORY/PowerShellEditorServices-CI/PowerShellEditorServices*.zip -ErrorAction Stop + $psesZip | Expand-Archive -DestinationPath $dest -Force -Verbose + $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' + +- task: PowerShell@1 + displayName: 'Copy signed items into output' + inputs: + scriptType: inlineScript + inlineScript: | + $signed="$(Build.ArtifactStagingDirectory)\Signed\PowerShellEditorServices\*" + $notSigned="$(Build.ArtifactStagingDirectory)\release\out\PowerShellEditorServices" + Copy-Item $signed $notSigned -Recurse -Force + +- task: PowerShell@1 + displayName: 'Create catalog files' + inputs: + scriptType: inlineScript + inlineScript: | + $dir = "$(Build.ArtifactStagingDirectory)\release\out\PowerShellEditorServices\PowerShellEditorServices" + New-FileCatalog -CatalogFilePath "$(Build.ArtifactStagingDirectory)\PowerShellEditorServices.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' + env: + SYSTEM_ACCESSTOKEN: $(System.AccessToken) + inputs: + signConfigXml: tools/releaseBuild/FileCatalogSigning.xml + inPathRoot: '$(Build.ArtifactStagingDirectory)' + outPathRoot: '$(Build.ArtifactStagingDirectory)' + +- 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)\release;$(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_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=PowerShellEditorServices;artifactname=PowerShellEditorServices]$(Build.ArtifactStagingDirectory)\release\out\PowerShellEditorServices"' 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 - } -} 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 + + + + +