Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✒️ Enable ESRP Signing on the .VSIX #1885

Merged
merged 58 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
58da0f6
Add fake MSBuild project to allow signing VSIX and JS
nagilson Jul 16, 2024
bd68765
Sign JS
nagilson Jul 16, 2024
cca7004
Add step to pipeline
nagilson Jul 16, 2024
5db97af
Restrict signing package version
nagilson Jul 16, 2024
47bc92c
Add scripts to install signing tool locally
nagilson Jul 16, 2024
d74bcf1
only go up 1 directory
nagilson Jul 16, 2024
488d940
Merge branch 'main' into nagilson-esrp
nagilson Jul 16, 2024
95dad8c
fix display name
nagilson Jul 22, 2024
f3beffe
fix whitespace -__-
nagilson Jul 22, 2024
c2291cc
add build step for installing microbuild
nagilson Jul 22, 2024
bf1f762
add sign type parameter
nagilson Jul 22, 2024
abec014
dont produce alpha package in official drop
nagilson Jul 22, 2024
9369a4b
Merge branch 'nagilson-esrp' of https://github.com/nagilson/vscode-do…
nagilson Jul 22, 2024
8870ff1
add sign type parameter to default pipeline
nagilson Jul 22, 2024
f95af03
dont publish package in another directory as this causes other issues…
nagilson Jul 23, 2024
76f007b
acknowledge the existence of a document explaining the release and ot…
nagilson Jul 23, 2024
e94fc63
change internal stream to a different signing stream
nagilson Jul 23, 2024
a881878
add dotnet public for notargets sdk
nagilson Jul 24, 2024
f298bd5
reduce to 1 feed
nagilson Jul 24, 2024
9d5cdb7
use a different feed
nagilson Jul 24, 2024
67acca9
Use dotnet team
nagilson Jul 24, 2024
8fbf695
use explicit feed source
nagilson Jul 24, 2024
c6e17cb
add feed auth
nagilson Jul 24, 2024
458d83b
fix comment
nagilson Jul 24, 2024
824a81a
rename unsigned vsix so both can get dropped
nagilson Jul 25, 2024
7390e4a
Merge branch 'nagilson-esrp' of https://github.com/nagilson/vscode-do…
nagilson Jul 25, 2024
05c9e94
use the other type of slash for REN -__-
nagilson Jul 25, 2024
44280e6
try to fix path
nagilson Jul 26, 2024
486adbe
add packages folder with empty gitignore
nagilson Jul 29, 2024
b1320b4
figure out dir
nagilson Jul 29, 2024
4bb1b34
fix rename command
nagilson Jul 29, 2024
b341ab4
Fix rename
nagilson Jul 30, 2024
0305e03
Merge remote-tracking branch 'upstream/main' into nagilson-esrp
nagilson Jul 30, 2024
93f0cd0
Fix JS File Sign
nagilson Jul 30, 2024
982552e
Merge branch 'main' into nagilson-esrp
nagilson Jul 30, 2024
cf33eaa
produce binlogs and try to fix the path
nagilson Jul 31, 2024
e58a5aa
Merge remote-tracking branch 'upstream/main' into nagilson-esrp
nagilson Jul 31, 2024
8311c0d
Publish SDK Extension Logs
nagilson Jul 31, 2024
f1647a6
fix signing
nagilson Jul 31, 2024
8433ef7
remove bad slash in path that gets parsed incorrectly
nagilson Jul 31, 2024
e006cbf
remove \
nagilson Jul 31, 2024
76f9482
fix microbuild to be installed b5 js signing
nagilson Jul 31, 2024
ad4c55d
update gitignore
nagilson Jul 31, 2024
6771dfd
fix gitignore again
nagilson Jul 31, 2024
48c5068
Merge branch 'main' into nagilson-esrp
nagilson Jul 31, 2024
1ab6ea1
[REVERT THIS] Add a file A.ts to see if files are signed alphabetical…
nagilson Aug 1, 2024
ecacc68
[REVERT THIS] Add content to js to see if minify changes signing
nagilson Aug 1, 2024
ef00b9d
sign js after webpack
nagilson Aug 2, 2024
dedd011
Merge branch 'main' into nagilson-esrp
nagilson Aug 5, 2024
1cad5cb
Revert "[REVERT THIS] Add content to js to see if minify changes sign…
nagilson Aug 5, 2024
9a25086
Revert "[REVERT THIS] Add a file A.ts to see if files are signed alph…
nagilson Aug 5, 2024
7e2bfd9
Merge branch 'nagilson-esrp' of https://github.com/nagilson/vscode-do…
nagilson Aug 5, 2024
16e3e5f
Update name of incorrect task.
nagilson Aug 5, 2024
fb2c34f
Merge branch 'main' into nagilson-esrp
nagilson Aug 12, 2024
2642520
only run package job in internal because signing tasks do not exist i…
nagilson Aug 12, 2024
473b380
use the right yaml synxtax
nagilson Aug 12, 2024
bb61479
Since parameter expansion happens before condition evaluation, you ne…
nagilson Aug 12, 2024
57daede
dont run package on 1pr pipeline
nagilson Aug 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
TestResults/
.nuget/
.build/
msbuild/signJs/*.log
.testPublish/
*.sln.ide/
_ReSharper.*/
packages/
artifacts/
.build/
PublishProfiles/
Expand Down Expand Up @@ -34,7 +34,6 @@ project.lock.json
.build/
.vs/
launchSettings.json
global.json
BenchmarkDotNet.Artifacts/
msbuild.binlog
msbuild.log
Expand Down
6 changes: 5 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ node_modules/**
dist/test/**
src/**
tslint.json
*.vsix
*.vsix
packages/
msbuild/**
global.json
nuget.config
6 changes: 6 additions & 0 deletions 1es-azure-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ parameters:
- name: NetCore1ESPool-Internal
image: 1es-windows-2022
os: windows
- name: SignType
displayName: Sign type
type: string
default: Test
values: [ 'Test', 'Real' ]

extends:
template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines
Expand Down Expand Up @@ -91,6 +96,7 @@ extends:
image: 1es-windows-2022
os: windows
useOneEngineeringPool: true
SignType: ${{ parameters.SignType }}
- template: pipeline-templates/sbom.yaml@self
parameters:
pool:
Expand Down
1 change: 1 addition & 0 deletions Documentation/release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
See a copy of this file in the `internal-documentation` branch in our internal repository. Or instead, check out our team one note's 'VSCode Extension' --> 'release.md' file for further information.
23 changes: 22 additions & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,25 @@ popd
#################### Copy Library Artifacts ####################
& "$(Split-Path $MyInvocation.MyCommand.Path)/mock-webpack.ps1"

Write-Host "Build Succeeded" -ForegroundColor $successColor
Write-Host "Build Succeeded" -ForegroundColor $successColor

#################### Install Signing Tool ####################

try
{
$InstallNuGetPkgScriptPath = ".\signing\Install-NuGetPackage.ps1"
$nugetVerbosity = 'quiet'
if ($Verbose) { $nugetVerbosity = 'normal' }
$MicroBuildPackageSource = 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json'
if ($Signing)
{
Write-Host "Installing MicroBuild signing plugin" -ForegroundColor $successColor
Invoke-Expression "& `"$InstallNuGetPkgScriptPath`" MicroBuild.Plugins.Signing -source $MicroBuildPackageSource -Verbosity $nugetVerbosity"
$EnvVars['SignType'] = "Test"
}

& ".\signing\Set-EnvVars.ps1" -Variables $EnvVars -PrependPath $PrependPath | Out-Null
} catch {
Write-Host "Failed to install signing tool" -ForegroundColor $errorColor
Write-Host $_.Exception.Message
}
5 changes: 5 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"msbuild-sdks": {
"Microsoft.Build.NoTargets": "3.7.0"
}
}
5 changes: 5 additions & 0 deletions msbuild/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>
<PropertyGroup>
<RepoRoot>$(MSBuildThisFileDirectory)../</RepoRoot>
</PropertyGroup>
</Project>
16 changes: 16 additions & 0 deletions msbuild/Directory.Build.rsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#------------------------------------------------------------------------------
# This file contains command-line options that MSBuild will process as part of
# every build, unless the "/noautoresponse" switch is specified.
#
# MSBuild processes the options in this file first, before processing the
# options on the command line. As a result, options on the command line can
# override the options in this file. However, depending on the options being
# set, the overriding can also result in conflicts.
#
# NOTE: The "/noautoresponse" switch cannot be specified in this file, nor in
# any response file that is referenced by this file.
#------------------------------------------------------------------------------
/nr:false
/m
/verbosity:minimal
/clp:Summary;ForceNoAlign
10 changes: 10 additions & 0 deletions msbuild/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project>
<!-- https://learn.microsoft.com/nuget/consume-packages/central-package-management -->
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
</PropertyGroup>
<ItemGroup>
<GlobalPackageReference Include="Microsoft.VisualStudioEng.MicroBuild.Core" Version="1.0.0" />
</ItemGroup>
</Project>
21 changes: 21 additions & 0 deletions msbuild/signJs/signJs.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.Build.NoTargets">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<GenerateAssemblyVersionInfo>false</GenerateAssemblyVersionInfo>
<EnableDefaultSignFiles>false</EnableDefaultSignFiles>
<MicroBuild_DoNotStrongNameSign>true</MicroBuild_DoNotStrongNameSign>
<IsPackable>false</IsPackable>
<OutDir>$(MSBuildProjectDirectory)\$(JSOutputPath)\</OutDir>
<MicroBuild_SigningEnabled>true</MicroBuild_SigningEnabled>
</PropertyGroup>

<PropertyGroup Condition="'$(SignType)' == ''">
<SignType>test</SignType>
</PropertyGroup>

<ItemGroup>
<FilesToSign Include="$(OutDir)*.js">
<Authenticode>MicrosoftSHA2</Authenticode>
</FilesToSign>
</ItemGroup>
</Project>
15 changes: 15 additions & 0 deletions msbuild/signVsix/signVsix.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.Build.NoTargets">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<GenerateAssemblyVersionInfo>false</GenerateAssemblyVersionInfo>
<EnableDefaultSignFiles>false</EnableDefaultSignFiles>
<MicroBuild_DoNotStrongNameSign>true</MicroBuild_DoNotStrongNameSign>
<IsPackable>false</IsPackable>
<OutDir>$(RepoRoot)packages\</OutDir>
</PropertyGroup>
<ItemGroup>
<FilesToSign Include="$(OutDir)*.vsix">
<Authenticode>VsixSHA2</Authenticode>
</FilesToSign>
</ItemGroup>
</Project>
15 changes: 15 additions & 0 deletions nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositorypath" value="packages" />
</config>
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear />
<add key="dotnet-public" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" />
</packageSources>
<disabledPackageSources>
<!-- Defend against user or machine level disabling of sources that we list in this file. -->
<clear />
</disabledPackageSources>
</configuration>
2 changes: 2 additions & 0 deletions packages/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
9 changes: 7 additions & 2 deletions pipeline-templates/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ jobs:
templateContext:
outputs:
- output: pipelineArtifact
displayName: '🌐 Publish Logs'
displayName: '🌐 Publish Install Tool Logs'
condition: always()
targetPath: '$(Build.SourcesDirectory)/vscode-dotnet-runtime-extension/dist/test/functional/logs'
artifactName: '${{ parameters.pool.os }} logs'
artifactName: '${{ parameters.pool.os }} Install Tool logs'
- output: pipelineArtifact
displayName: '👜 Publish SDK Logs'
condition: always()
targetPath: '$(Build.SourcesDirectory)/vscode-dotnet-sdk-extension/dist/test/functional/logs'
artifactName: '${{ parameters.pool.os }} SDK logs'
steps:
- template: install-node.yaml
- ${{ if eq(parameters.pool.os, 'windows') }}:
Expand Down
41 changes: 39 additions & 2 deletions pipeline-templates/package-vsix.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
parameters:
pool: ''
SignType: ''

jobs:
- job: ${{ parameters.pool.os }}_Package
Expand Down Expand Up @@ -34,23 +35,59 @@ jobs:
VERSION=`node -p "require('./package.json').version"`
else
VERSION_NUM=`node -p "require('./package.json').version"`
VERSION="$VERSION_NUM-alpha-$(Build.BuildId)"
VERSION="$VERSION_NUM"
fi
npm version $VERSION --allow-same-version
echo "##vso[task.setvariable variable=version;isOutput=true]$VERSION"
name: GetVersion
displayName: '❓ Get Version'
workingDirectory: $(dir-name)
- task: UseDotNet@2
displayName: 🔮 Use .NET SDK
inputs:
packageType: sdk
useGlobalJson: true
# This is necessary whenever we want to publish/restore to an AzDO private feed
# otherwise it'll complain about accessing a private feed.
- task: NuGetAuthenticate@1
displayName: '🔏 Authenticate to AzDO Feeds'
- task: MicroBuildSigningPlugin@4
displayName: 🔧 Install MicroBuild Signing Plugin
inputs:
signType: ${{ parameters.SignType }}
zipSources: false
feedSource: https://dnceng.pkgs.visualstudio.com/_packaging/MicroBuildToolset/nuget/v3/index.json
env:
SignType: ${{ parameters.SignType }}
TeamName: DotNetCore
- bash: |
npm install rimraf --reg https://registry.npmjs.org/ --verbose
npm install @vscode/vsce@latest -g --reg https://registry.npmjs.org/ --verbose
vsce package -o $(package-name)-$(GetVersion.version).vsix --ignoreFile ../.vscodeignore --yarn
cp $(package-name)-$(GetVersion.version).vsix ../packages/$(package-name)-$(GetVersion.version).vsix
displayName: 📦 Package Artifact
workingDirectory: $(dir-name)
env:
SignType: ${{ parameters.SignType }}
- script: dotnet build msbuild/signVsix -v:normal
displayName: 🖊️ Sign VSIXes
env:
SignType: ${{ parameters.SignType }}
- task: CmdLine@2
displayName: 🤌 Rename Unsigned VSIX
nagilson marked this conversation as resolved.
Show resolved Hide resolved
inputs:
script: rename ".\packages\$(package-name)-$(GetVersion.version).vsix" $(package-name)-$(GetVersion.version)-signed.vsix
- task: CopyFiles@2
displayName: '📩 Copy Artifact'
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: '**\*.vsix'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
flattenFolders: true
flattenFolders: true
- task: CopyFiles@2
displayName: '🏗️ Copy Binlog'
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: '**\*.binlog'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
flattenFolders: false
2 changes: 1 addition & 1 deletion sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
]
},
"scripts": {
"vscode:prepublish": "npm install && npm run compile",
"vscode:prepublish": "npm install && npm run compile && dotnet build ../msbuild/signJs --property jsOutputPath=..\\..\\sample\\dist -bl -v:normal",
"compile": "npm run clean && tsc -p ./",
"watch": "npm run clean && tsc -watch -p ./",
"test": "npm run compile && node ./node_modules/vscode/bin/test",
Expand Down
22 changes: 22 additions & 0 deletions signing/Get-NuGetTool.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<#
.SYNOPSIS
Downloads the NuGet.exe tool and returns the path to it.
.PARAMETER NuGetVersion
The version of the NuGet tool to acquire.
#>
Param(
[Parameter()]
[string]$NuGetVersion='6.4.0'
)

$toolsPath = & "$PSScriptRoot\Get-TempToolsPath.ps1"
$binaryToolsPath = Join-Path $toolsPath $NuGetVersion
if (!(Test-Path $binaryToolsPath)) { $null = mkdir $binaryToolsPath }
$nugetPath = Join-Path $binaryToolsPath nuget.exe

if (!(Test-Path $nugetPath)) {
Write-Host "Downloading nuget.exe $NuGetVersion..." -ForegroundColor Yellow
(New-Object System.Net.WebClient).DownloadFile("https://dist.nuget.org/win-x86-commandline/v$NuGetVersion/NuGet.exe", $nugetPath)
}

return (Resolve-Path $nugetPath).Path
13 changes: 13 additions & 0 deletions signing/Get-TempToolsPath.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
if ($env:AGENT_TEMPDIRECTORY) {
$path = "$env:AGENT_TEMPDIRECTORY\$env:BUILD_BUILDID"
} elseif ($env:localappdata) {
$path = "$env:localappdata\gitrepos\tools"
} else {
$path = "$PSScriptRoot\..\obj\tools"
}

if (!(Test-Path $path)) {
New-Item -ItemType Directory -Path $Path | Out-Null
}

(Resolve-Path $path).Path
55 changes: 55 additions & 0 deletions signing/Install-NuGetPackage.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<#
.SYNOPSIS
Installs a NuGet package.
.PARAMETER PackageID
The Package ID to install.
.PARAMETER Version
The version of the package to install. If unspecified, the latest stable release is installed.
.PARAMETER Source
The package source feed to find the package to install from.
.PARAMETER PackagesDir
The directory to install the package to. By default, it uses the Packages folder at the root of the repo.
.PARAMETER ConfigFile
The nuget.config file to use. By default, it uses :/nuget.config.
.OUTPUTS
System.String. The path to the installed package.
#>
[CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='Low')]
Param(
[Parameter(Position=1,Mandatory=$true)]
[string]$PackageId,
[Parameter()]
[string]$Version,
[Parameter()]
[string]$Source,
[Parameter()]
[switch]$Prerelease,
[Parameter()]
[string]$PackagesDir="$PSScriptRoot\..\packages",
[Parameter()]
[string]$ConfigFile="$PSScriptRoot\..\nuget.config",
[Parameter()]
[ValidateSet('Quiet','Normal','Detailed')]
[string]$Verbosity='normal'
)

$nugetPath = & "$PSScriptRoot\Get-NuGetTool.ps1"

try {
Write-Verbose "Installing $PackageId..."
$nugetArgs = "Install",$PackageId,"-OutputDirectory",$PackagesDir,'-ConfigFile',$ConfigFile
if ($Version) { $nugetArgs += "-Version",$Version }
if ($Source) { $nugetArgs += "-FallbackSource",$Source }
if ($Prerelease) { $nugetArgs += "-Prerelease" }
$nugetArgs += '-Verbosity',$Verbosity

if ($PSCmdlet.ShouldProcess($PackageId, 'nuget install')) {
$p = Start-Process $nugetPath $nugetArgs -NoNewWindow -Wait -PassThru
if ($p.ExitCode -ne 0) { throw }
}

# Provide the path to the installed package directory to our caller.
Write-Output (Get-ChildItem "$PackagesDir\$PackageId.*")[0].FullName
} finally {
Pop-Location
}
Loading