mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-24 04:00:02 +01:00
Adding extensions SDK nuget generation (#184)
## Summary of the Pull Request Packing the SDK into a nuget package and creating the build scripts and pipeline to build it. Pipeline: will auto build the SDK and publish it to ADO artifacts in that build. Script: Devs can build nuget locally by running BuildSDKHelper.ps1. This will build and pack the SDK nuget and place it in src\modules\cmdpal\extensionsdk\_build. This directory has been added to the nuget.config as well.
This commit is contained in:
51
.pipelines/ESRPSigning_sdk.json
Normal file
51
.pipelines/ESRPSigning_sdk.json
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"Version": "1.0.0",
|
||||
"UseMinimatch": false,
|
||||
"SignBatches": [
|
||||
{
|
||||
"MatchedPath": [
|
||||
"Microsoft.CmdPal.Extensions.dll",
|
||||
"Microsoft.CmdPal.Extensions.Helpers.dll"
|
||||
],
|
||||
"SigningInfo": {
|
||||
"Operations": [
|
||||
{
|
||||
"KeyCode": "CP-230012",
|
||||
"OperationSetCode": "SigntoolSign",
|
||||
"Parameters": [
|
||||
{
|
||||
"parameterName": "OpusName",
|
||||
"parameterValue": "Microsoft"
|
||||
},
|
||||
{
|
||||
"parameterName": "OpusInfo",
|
||||
"parameterValue": "http://www.microsoft.com"
|
||||
},
|
||||
{
|
||||
"parameterName": "FileDigest",
|
||||
"parameterValue": "/fd \"SHA256\""
|
||||
},
|
||||
{
|
||||
"parameterName": "PageHash",
|
||||
"parameterValue": "/NPH"
|
||||
},
|
||||
{
|
||||
"parameterName": "TimeStamp",
|
||||
"parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256"
|
||||
}
|
||||
],
|
||||
"ToolName": "sign",
|
||||
"ToolVersion": "1.0"
|
||||
},
|
||||
{
|
||||
"KeyCode": "CP-230012",
|
||||
"OperationSetCode": "SigntoolVerify",
|
||||
"Parameters": [],
|
||||
"ToolName": "sign",
|
||||
"ToolVersion": "1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -105,6 +105,25 @@ extends:
|
||||
move /Y "Microsoft.PowerToys.Telemetry.2.0.2\build\include\TelemetryBase.cs" "src\common\Telemetry\TelemetryBase.cs" || exit /b 1
|
||||
displayName: Emplace telemetry files
|
||||
|
||||
- stage: Build_SDK
|
||||
displayName: Build SDK
|
||||
dependsOn: []
|
||||
jobs:
|
||||
- template: .pipelines/v2/templates/job-build-sdk.yml@self
|
||||
parameters:
|
||||
pool:
|
||||
name: SHINE-INT-L
|
||||
image: SHINE-VS17-Latest
|
||||
os: windows
|
||||
codeSign: true
|
||||
signingIdentity:
|
||||
serviceName: $(SigningServiceName)
|
||||
appId: $(SigningAppId)
|
||||
tenantId: $(SigningTenantId)
|
||||
akvName: $(SigningAKVName)
|
||||
authCertName: $(SigningAuthCertName)
|
||||
signCertName: $(SigningSignCertName)
|
||||
|
||||
- stage: Publish
|
||||
displayName: Publish
|
||||
dependsOn: [Build]
|
||||
|
||||
@@ -228,6 +228,45 @@ jobs:
|
||||
batchSignPolicyFile: '$(build.sourcesdirectory)\.pipelines\ESRPSigning_abstracted_utils_dll.json'
|
||||
ciPolicyFile: '$(build.sourcesdirectory)\.pipelines\CIPolicy.xml'
|
||||
|
||||
- task: CopyFiles@2
|
||||
displayName: Stage SDK/build
|
||||
inputs:
|
||||
contents: |-
|
||||
"**/cmdpal/extensionsdk/nuget/Microsoft.CmdPal.Extensions.SDK.props"
|
||||
"**/cmdpal/extensionsdk/nuget/Microsoft.CmdPal.Extensions.SDK.targets"
|
||||
flattenFolders: True
|
||||
targetFolder: $(JobOutputDirectory)/sdk/build
|
||||
|
||||
- task: CopyFiles@2
|
||||
displayName: Stage SDK/lib
|
||||
inputs:
|
||||
contents: |-
|
||||
"**/Microsoft.CmdPal.Extensions.Helpers/$(BuildPlatform)/release/WinUI3Apps/CmdPal/Microsoft.CmdPal.Extensions.Helpers.dll"
|
||||
"**/Microsoft.CmdPal.Extensions.Helpers/$(BuildPlatform)/release/WinUI3Apps/CmdPal/Microsoft.CmdPal.Extensions.Helpers.deps.json"
|
||||
flattenFolders: True
|
||||
targetFolder: $(JobOutputDirectory)/sdk/lib/net8.0-windows10.0.19041.0
|
||||
|
||||
- task: CopyFiles@2
|
||||
displayName: Stage SDK/runtimes
|
||||
inputs:
|
||||
flattenFolders: True
|
||||
${{ if eq(variables['BuildPlatform'],'x64') }}:
|
||||
contents: |-
|
||||
"**/Microsoft.CmdPal.Extensions/$(BuildPlatform)/release/Microsoft.CmdPal.Extensions/Microsoft.CmdPal.Extensions.dll"
|
||||
targetFolder: $(JobOutputDirectory)/sdk/runtimes/win-$(BuildPlatform)/native/
|
||||
${{ if eq(variables['BuildPlatform'],'arm64') }}:
|
||||
contents: |-
|
||||
"**/Microsoft.CmdPal.Extensions/$(BuildPlatform)/release/WinUI3Apps/CmdPal/Microsoft.CmdPal.Extensions.dll"
|
||||
targetFolder: $(JobOutputDirectory)/sdk/runtimes/win-$(BuildPlatform)/native/
|
||||
|
||||
- task: CopyFiles@2
|
||||
displayName: Stage SDK/winmd
|
||||
inputs:
|
||||
contents: |-
|
||||
"**/Microsoft.CmdPal.Extensions/$(BuildPlatform)/release/Microsoft.CmdPal.Extensions/Microsoft.CmdPal.Extensions.winmd"
|
||||
flattenFolders: True
|
||||
targetFolder: $(JobOutputDirectory)/sdk/winmd
|
||||
|
||||
- task: VSBuild@1
|
||||
displayName: Create Hosts File Editor package
|
||||
inputs:
|
||||
|
||||
91
.pipelines/v2/templates/job-build-sdk.yml
Normal file
91
.pipelines/v2/templates/job-build-sdk.yml
Normal file
@@ -0,0 +1,91 @@
|
||||
parameters:
|
||||
- name: buildConfigurations
|
||||
type: object
|
||||
default:
|
||||
- Release
|
||||
- name: codeSign
|
||||
type: boolean
|
||||
default: false
|
||||
- name: pool
|
||||
type: object
|
||||
default: []
|
||||
- name: signingIdentity
|
||||
type: object
|
||||
default: {}
|
||||
- name: sdkVersionNumber
|
||||
type: string
|
||||
default: '0.0.1'
|
||||
|
||||
jobs:
|
||||
- job: "BuildSDK"
|
||||
${{ if ne(length(parameters.pool), 0) }}:
|
||||
pool: ${{ parameters.pool }}
|
||||
displayName: Build SDK
|
||||
timeoutInMinutes: 240
|
||||
cancelTimeoutInMinutes: 1
|
||||
templateContext: # Required when this template is hosted in 1ES PT
|
||||
outputs:
|
||||
- output: pipelineArtifact
|
||||
artifactName: SDK
|
||||
targetPath: $(Build.ArtifactStagingDirectory)
|
||||
steps:
|
||||
- checkout: self
|
||||
clean: true
|
||||
submodules: true
|
||||
persistCredentials: True
|
||||
fetchTags: false
|
||||
fetchDepth: 1
|
||||
|
||||
- pwsh: |-
|
||||
& "$(build.sourcesdirectory)\src\modules\cmdpal\extensionsdk\nuget\BuildSDKHelper.ps1" -Configuration "Release" -VersionOfSDK ${{ parameters.sdkVersionNumber }} -BuildStep "build" -IsAzurePipelineBuild
|
||||
displayName: Build SDK
|
||||
|
||||
- ${{ if eq(parameters.codeSign, true) }}:
|
||||
- template: steps-esrp-signing.yml
|
||||
parameters:
|
||||
displayName: Sign SDK
|
||||
signingIdentity: ${{ parameters.signingIdentity }}
|
||||
inputs:
|
||||
FolderPath: 'src/modules'
|
||||
signType: batchSigning
|
||||
batchSignPolicyFile: '$(build.sourcesdirectory)\.pipelines\ESRPSigning_sdk.json'
|
||||
ciPolicyFile: '$(build.sourcesdirectory)\.pipelines\CIPolicy.xml'
|
||||
|
||||
- pwsh: |-
|
||||
& "$(build.sourcesdirectory)\src\modules\cmdpal\extensionsdk\nuget\BuildSDKHelper.ps1" -Configuration "Release" -VersionOfSDK ${{ parameters.sdkVersionNumber }} -BuildStep "pack" -IsAzurePipelineBuild
|
||||
displayName: Pack SDK
|
||||
|
||||
- task: CopyFiles@2
|
||||
displayName: Copy Nuget to Artifact Staging
|
||||
inputs:
|
||||
sourceFolder: "$(build.sourcesdirectory)/src/modules/cmdpal/extensionsdk/_build"
|
||||
contents: '*.nupkg'
|
||||
targetFolder: '$(Build.ArtifactStagingDirectory)'
|
||||
|
||||
- ${{ if eq(parameters.codeSign, true) }}:
|
||||
- template: steps-esrp-signing.yml
|
||||
parameters:
|
||||
displayName: Sign NuGet packages
|
||||
signingIdentity: ${{ parameters.signingIdentity }}
|
||||
inputs:
|
||||
FolderPath: $(Build.ArtifactStagingDirectory)
|
||||
Pattern: '*.nupkg'
|
||||
UseMinimatch: true
|
||||
signConfigType: inlineSignParams
|
||||
inlineOperation: >-
|
||||
[
|
||||
{
|
||||
"KeyCode": "CP-401405",
|
||||
"OperationCode": "NuGetSign",
|
||||
"Parameters": {},
|
||||
"ToolName": "sign",
|
||||
"ToolVersion": "1.0"
|
||||
},
|
||||
{
|
||||
"KeyCode": "CP-401405",
|
||||
"OperationCode": "NuGetVerify",
|
||||
"Parameters": {},
|
||||
"ToolName": "sign",
|
||||
"ToolVersion": "1.0"
|
||||
}
|
||||
]
|
||||
@@ -30,6 +30,7 @@
|
||||
<PackageVersion Include="Markdig.Signed" Version="0.34.0" />
|
||||
<!-- Including MessagePack to force version, since it's used by StreamJsonRpc but contains vulnerabilities. After StreamJsonRpc updates the version of MessagePack, we can upgrade StreamJsonRpc instead. -->
|
||||
<PackageVersion Include="MessagePack" Version="2.5.187" />
|
||||
<PackageVersion Include="Microsoft.CmdPal.Extensions.SDK" Version="0.0.1" />
|
||||
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0-preview.24508.2" />
|
||||
<PackageVersion Include="Microsoft.Data.Sqlite" Version="9.0.0" />
|
||||
<PackageVersion Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="3.1.16" />
|
||||
|
||||
@@ -3,10 +3,14 @@
|
||||
<packageSources>
|
||||
<clear />
|
||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
|
||||
<add key="SDKLocalSource" value=".\src\modules\cmdpal\extensionsdk\_build" />
|
||||
</packageSources>
|
||||
<packageSourceMapping>
|
||||
<packageSource key="nuget.org">
|
||||
<package pattern="*" />
|
||||
</packageSource>
|
||||
<packageSource key="SDKLocalSource">
|
||||
<package pattern="Microsoft.CmdPal.Extensions.SDK" />
|
||||
</packageSource>
|
||||
</packageSourceMapping>
|
||||
</configuration>
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\WinUI3Apps\CmdPal</OutDir>
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\Microsoft.CmdPal.Extensions</OutDir>
|
||||
<IntDir>obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Configuration">
|
||||
@@ -189,7 +189,4 @@
|
||||
<Error Condition="!Exists('$(WasdkNuget)\build\native\Microsoft.WindowsAppSDK.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(WasdkNuget)\build\native\Microsoft.WindowsAppSDK.targets'))" />
|
||||
<Error Condition="!Exists('$(WebView2Nuget)\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(WebView2Nuget)\build\native\Microsoft.Web.WebView2.targets'))" />
|
||||
</Target>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="version.rc" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
102
src/modules/cmdpal/extensionsdk/nuget/BuildSDKHelper.ps1
Normal file
102
src/modules/cmdpal/extensionsdk/nuget/BuildSDKHelper.ps1
Normal file
@@ -0,0 +1,102 @@
|
||||
Param(
|
||||
[string]$Configuration = "release",
|
||||
[string]$VersionOfSDK = "0.0.0",
|
||||
[string]$BuildStep = "all",
|
||||
[switch]$IsAzurePipelineBuild = $false,
|
||||
[switch]$Help = $false
|
||||
)
|
||||
|
||||
$StartTime = Get-Date
|
||||
|
||||
if ($Help) {
|
||||
Write-Host @"
|
||||
Copyright (c) Microsoft Corporation.
|
||||
Licensed under the MIT License.
|
||||
|
||||
Syntax:
|
||||
Build.cmd [options]
|
||||
|
||||
Description:
|
||||
Builds the Command Palette SDK
|
||||
|
||||
Options:
|
||||
|
||||
-Configuration <configuration>
|
||||
Only build the selected configuration(s)
|
||||
Example: -Configuration Release
|
||||
Example: -Configuration "Debug,Release"
|
||||
|
||||
-VersionOfSDK <version>
|
||||
Set the version number of the build sdk nuget package
|
||||
Example: -VersionOfSDK "1.0.0"
|
||||
|
||||
-Help
|
||||
Display this usage message.
|
||||
"@
|
||||
Exit
|
||||
}
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$buildPlatforms = "x64","arm64"
|
||||
|
||||
$msbuildPath = &"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe
|
||||
if ($IsAzurePipelineBuild) {
|
||||
$nugetPath = "nuget.exe";
|
||||
} else {
|
||||
$nugetPath = (Join-Path $PSScriptRoot "NugetWrapper.cmd")
|
||||
}
|
||||
|
||||
if (($BuildStep -ieq "all") -Or ($BuildStep -ieq "build")) {
|
||||
& $nugetPath restore (Join-Path $PSScriptRoot "..\..\..\..\..\PowerToys.sln")
|
||||
|
||||
Try {
|
||||
foreach ($config in $Configuration.Split(",")) {
|
||||
foreach ($platform in $buildPlatforms) {
|
||||
$msbuildArgs = @(
|
||||
("$PSScriptRoot\..\Microsoft.CmdPal.Extensions.Helpers\Microsoft.CmdPal.Extensions.Helpers.csproj"),
|
||||
("/p:Platform="+$platform),
|
||||
("/p:Configuration="+$config),
|
||||
("/binaryLogger:CmdPal.Extensions.$platform.$config.binlog"),
|
||||
("/p:VersionNumber="+$VersionOfSDK)
|
||||
)
|
||||
|
||||
& $msbuildPath $msbuildArgs
|
||||
}
|
||||
}
|
||||
} Catch {
|
||||
$formatString = "`n{0}`n`n{1}`n`n"
|
||||
$fields = $_, $_.ScriptStackTrace
|
||||
Write-Host ($formatString -f $fields) -ForegroundColor RED
|
||||
Exit 1
|
||||
}
|
||||
}
|
||||
|
||||
if (($BuildStep -ieq "all") -Or ($BuildStep -ieq "pack")) {
|
||||
foreach ($config in $Configuration.Split(",")) {
|
||||
if ($config -eq "release")
|
||||
{
|
||||
New-Item -ItemType Directory -Force -Path "$PSScriptRoot\..\_build"
|
||||
& $nugetPath pack (Join-Path $PSScriptRoot "Microsoft.CmdPal.Extensions.SDK.nuspec") -Version $VersionOfSDK -OutputDirectory "$PSScriptRoot\..\_build"
|
||||
} else {
|
||||
Write-Host @"
|
||||
WARNING: You are currently building as '$config' configuration.
|
||||
CmdPalSDK nuget creation only supports 'release' configuration right now.
|
||||
"@ -ForegroundColor YELLOW
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($IsAzurePipelineBuild) {
|
||||
Write-Host "##vso[task.setvariable variable=VersionOfSDK;]$VersionOfSDK"
|
||||
Write-Host "##vso[task.setvariable variable=VersionOfSDK;isOutput=true;]$VersionOfSDK"
|
||||
}
|
||||
|
||||
$TotalTime = (Get-Date)-$StartTime
|
||||
$TotalMinutes = [math]::Floor($TotalTime.TotalMinutes)
|
||||
$TotalSeconds = [math]::Ceiling($TotalTime.TotalSeconds)
|
||||
|
||||
Write-Host @"
|
||||
Total Running Time:
|
||||
$TotalMinutes minutes and $TotalSeconds seconds
|
||||
"@ -ForegroundColor CYAN
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0"?>
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
|
||||
<metadata minClientVersion="2.5">
|
||||
<id>Microsoft.CmdPal.Extensions.SDK</id>
|
||||
<version>0.0.0</version>
|
||||
<title>Command Palette SDK</title>
|
||||
<authors>Microsoft</authors>
|
||||
<owners>Microsoft</owners>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<description>Command Palette SDK provides support for creating Command Palette extensions on Windows.</description>
|
||||
<releaseNotes>Release notes are available in the Power Toys repository.</releaseNotes>
|
||||
<tags>Command Palette Extension SDK</tags>
|
||||
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
|
||||
<!-- TODO! : <license type="file">LICENSE</license> -->
|
||||
<projectUrl>https://github.com/microsoft/powertoys</projectUrl>
|
||||
<dependencies>
|
||||
<group targetFramework="net8.0-windows10.0.19041.0">
|
||||
<dependency id="Microsoft.Windows.CsWinRT" version="2.1.1" />
|
||||
</group>
|
||||
</dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
<!-- TODO : Add NOTICE.txt and LICENSE files -->
|
||||
<file src="Microsoft.CmdPal.Extensions.SDK.props" target="build\"/>
|
||||
<file src="Microsoft.CmdPal.Extensions.SDK.targets" target="build\"/>
|
||||
<!-- AnyCPU Managed dlls from SDK.Lib project -->
|
||||
<file src="..\Microsoft.CmdPal.Extensions.Helpers\x64\release\Microsoft.CmdPal.Extensions.Helpers\Microsoft.CmdPal.Extensions.Helpers.dll" target="lib\net8.0-windows10.0.19041.0\"/>
|
||||
<file src="..\Microsoft.CmdPal.Extensions.Helpers\x64\release\Microsoft.CmdPal.Extensions.Helpers\Microsoft.CmdPal.Extensions.Helpers.deps.json" target="lib\net8.0-windows10.0.19041.0\"/>
|
||||
<!-- Native dlls and winmd from SDK cpp project -->
|
||||
<file src="..\Microsoft.CmdPal.Extensions\x64\release\Microsoft.CmdPal.Extensions\Microsoft.CmdPal.Extensions.dll" target="runtimes\win-x64\native\"/>
|
||||
<file src="..\Microsoft.CmdPal.Extensions\arm64\release\WinUI3Apps\CmdPal\Microsoft.CmdPal.Extensions.dll" target="runtimes\win-arm64\native\"/>
|
||||
<!-- Not putting in the following the lib folder because we don't want plugin project to directly reference the winmd -->
|
||||
<file src="..\Microsoft.CmdPal.Extensions\x64\release\Microsoft.CmdPal.Extensions\Microsoft.CmdPal.Extensions.winmd" target="winmd\"/>
|
||||
</files>
|
||||
</package>
|
||||
@@ -0,0 +1,5 @@
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<CmdPalSDKPackageDir>$([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', '..'))</CmdPalSDKPackageDir>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,7 @@
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<None Include="$(CmdPalSDKPackageDir)\winmd\*.winmd" Visible="false">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
13
src/modules/cmdpal/extensionsdk/nuget/NugetWrapper.cmd
Normal file
13
src/modules/cmdpal/extensionsdk/nuget/NugetWrapper.cmd
Normal file
@@ -0,0 +1,13 @@
|
||||
@echo OFF
|
||||
setlocal
|
||||
|
||||
if "%VisualStudioVersion%" == "" set VisualStudioVersion=15.0
|
||||
|
||||
if not exist %TEMP%\nuget.6.4.0.exe (
|
||||
echo Nuget.exe not found in the temp dir, downloading.
|
||||
powershell -Command "& { Invoke-WebRequest https://dist.nuget.org/win-x86-commandline/v6.4.0/nuget.exe -outfile $env:TEMP\nuget.6.4.0.exe }"
|
||||
)
|
||||
|
||||
%TEMP%\nuget.6.4.0.exe %*
|
||||
|
||||
exit /B %ERRORLEVEL%
|
||||
Reference in New Issue
Block a user