|
| 1 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +# Licensed under the MIT License. |
| 3 | +param( |
| 4 | + [Parameter(Mandatory)] |
| 5 | + [string] $Path, |
| 6 | + [string[]] $AuthenticodeDualFiles, |
| 7 | + [string[]] $AuthenticodeFiles, |
| 8 | + [string[]] $NuPkgFiles, |
| 9 | + [string[]] $MacDeveloperFiles |
| 10 | +) |
| 11 | + |
| 12 | +if ((!$AuthenticodeDualFiles -or $AuthenticodeDualFiles.Count -eq 0) -and |
| 13 | + (!$AuthenticodeFiles -or $AuthenticodeFiles.Count -eq 0) -and |
| 14 | + (!$NuPkgFiles -or $NuPkgFiles.Count -eq 0) -and |
| 15 | + (!$MacDeveloperFiles -or $MacDeveloperFiles.Count -eq 0)) |
| 16 | +{ |
| 17 | + throw "At least one file must be specified" |
| 18 | +} |
| 19 | + |
| 20 | +function New-Attribute |
| 21 | +{ |
| 22 | + param( |
| 23 | + [Parameter(Mandatory)] |
| 24 | + [string]$Name, |
| 25 | + [Parameter(Mandatory)] |
| 26 | + [object]$Value, |
| 27 | + [Parameter(Mandatory)] |
| 28 | + [System.Xml.XmlElement]$Element |
| 29 | + ) |
| 30 | + |
| 31 | + $attribute = $signingXml.CreateAttribute($Name) |
| 32 | + $attribute.Value = $value |
| 33 | + $null = $fileElement.Attributes.Append($attribute) |
| 34 | +} |
| 35 | + |
| 36 | +function New-FileElement |
| 37 | +{ |
| 38 | + param( |
| 39 | + [Parameter(Mandatory)] |
| 40 | + [string]$File, |
| 41 | + [Parameter(Mandatory)] |
| 42 | + [string]$SignType, |
| 43 | + [Parameter(Mandatory)] |
| 44 | + [System.Xml.XmlDocument]$XmlDoc, |
| 45 | + [Parameter(Mandatory)] |
| 46 | + [System.Xml.XmlElement]$Job |
| 47 | + ) |
| 48 | + |
| 49 | + if(Test-Path -Path $file) |
| 50 | + { |
| 51 | + $name = Split-Path -Leaf -Path $File |
| 52 | + $fileElement = $XmlDoc.CreateElement("file") |
| 53 | + New-Attribute -Name 'src' -value $file -Element $fileElement |
| 54 | + New-Attribute -Name 'signType' -value $SignType -Element $fileElement |
| 55 | + New-Attribute -Name 'dest' -value "__OUTPATHROOT__\$name" -Element $fileElement |
| 56 | + $null = $job.AppendChild($fileElement) |
| 57 | + } |
| 58 | + else |
| 59 | + { |
| 60 | + Write-Warning -Message "Skipping $SignType; $File because it does not exist" |
| 61 | + } |
| 62 | +} |
| 63 | + |
| 64 | +[xml]$signingXml = get-content (Join-Path -Path $PSScriptRoot -ChildPath 'packagesigning.xml') |
| 65 | +$job = $signingXml.SignConfigXML.job |
| 66 | + |
| 67 | +foreach($file in $AuthenticodeDualFiles) |
| 68 | +{ |
| 69 | + New-FileElement -File $file -SignType 'AuthenticodeDual' -XmlDoc $signingXml -Job $job |
| 70 | +} |
| 71 | + |
| 72 | +foreach($file in $AuthenticodeFiles) |
| 73 | +{ |
| 74 | + New-FileElement -File $file -SignType 'AuthenticodeFormer' -XmlDoc $signingXml -Job $job |
| 75 | +} |
| 76 | + |
| 77 | +foreach($file in $NuPkgFiles) |
| 78 | +{ |
| 79 | + New-FileElement -File $file -SignType 'NuGet' -XmlDoc $signingXml -Job $job |
| 80 | +} |
| 81 | + |
| 82 | +foreach ($file in $MacDeveloperFiles) { |
| 83 | + New-FileElement -File $file -SignType 'MacDeveloper' -XmlDoc $signingXml -Job $job |
| 84 | +} |
| 85 | + |
| 86 | +$signingXml.Save($path) |
| 87 | +$updateScriptPath = Join-Path -Path $PSScriptRoot -ChildPath 'updateSigning.ps1' |
| 88 | +& $updateScriptPath -SigningXmlPath $path |
0 commit comments