Skip to content

Commit deab984

Browse files
committed
Added scripts for VSTS build
Updated docker file and releasemaker module
1 parent 7052583 commit deab984

File tree

7 files changed

+169
-3
lines changed

7 files changed

+169
-3
lines changed

Utils/ReleaseMaker.psm1

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function New-ReleaseBuild
9292
Push-Location $solutionPath
9393
try
9494
{
95-
remove-item out/ -recurse -force
95+
if ( test-path out ) { remove-item out/ -recurse -force }
9696
.\buildCoreClr.ps1 -Framework net451 -Configuration Release -Build
9797
.\buildCoreClr.ps1 -Framework net451 -Configuration PSV3Release -Build
9898
.\buildCoreClr.ps1 -Framework netstandard2.0 -Configuration Release -Build
@@ -196,4 +196,4 @@ function Set-ContentUtf8NoBom {
196196
}
197197

198198
Export-ModuleMember -Function New-Release
199-
Export-ModuleMember -Function New-ReleaseBuild
199+
Export-ModuleMember -Function New-ReleaseBuild

tools/releaseBuild/Image/DockerFile

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ SHELL ["C:\\windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-comma
1010
# Git installs to C:\Program Files\Git
1111
# nuget installs to C:\ProgramData\chocolatey\bin\NuGet.exe
1212
COPY dockerInstall.psm1 containerFiles/dockerInstall.psm1
13+
1314
RUN Import-Module PackageManagement; `
1415
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force; `
1516
Import-Module ./containerFiles/dockerInstall.psm1; `
@@ -21,11 +22,13 @@ RUN Import-Module PackageManagement; `
2122
Add-Path C:/Users/ContainerAdministrator/AppData/Local/Microsoft/dotnet;
2223

2324
RUN Import-Module ./containerFiles/dockerInstall.psm1; `
24-
git clone https://Github.com/PowerShell/PSScriptAnalyzer; `
25+
# git clone https://Github.com/PowerShell/PSScriptAnalyzer; `
2526
Install-ChocolateyPackage -PackageName dotnet4.5;
2627

2728
RUN Import-Module ./containerFiles/dockerInstall.psm1; `
2829
Install-ChocolateyPackage -PackageName netfx-4.5.1-devpack;
2930

31+
COPY buildPSSA.ps1 containerFiles/buildPSSA.ps1
32+
3033
ENTRYPOINT ["C:\\windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-command"]
3134

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
push-location C:/PSScriptAnalyzer
2+
import-module C:/PSScriptAnalyzer/Utils/ReleaseMaker.psm1
3+
New-ReleaseBuild
4+
Copy-Item -Recurse C:/PSScriptAnalyzer/out C:/

tools/releaseBuild/build.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"Windows": {
3+
"Name": "win7-x64",
4+
"RepoDestinationPath": "C:\\PSScriptAnalyzer",
5+
"BuildCommand": "C:\\containerFiles\\buildPSSA.ps1",
6+
"DockerFile": ".\\tools\\releaseBuild\\Image\\DockerFile",
7+
"DockerImageName": "pssa",
8+
"BinaryBucket": "release",
9+
"PublishAsFolder": true,
10+
"AdditionalContextFiles" : [
11+
".\\tools\\releaseBuild\\Image\\buildPSSA.ps1",
12+
".\\tools\\releaseBuild\\Image\\dockerInstall.psm1"
13+
]
14+
}
15+
}

tools/releaseBuild/signing.xml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<SignConfigXML>
3+
<!-- ****Begin**** BothDual - Dual (Sha256 and Sha1) AuthenticodeDual) and should be StrongName, but we will add this in 6.1.0 ******** -->
4+
<job platform="" configuration="" dest="__OUTPATHROOT__\signed" jobname="PowerShell Script Analyzer" approvers="vigarg;gstolt">
5+
<file src="__INPATHROOT__\PSScriptAnalyzer\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" signType="AuthenticodeDual" dest="__OUTPATHROOT__\PSScriptAnalyzer\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" />
6+
<file src="__INPATHROOT__\PSScriptAnalyzer\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" signType="AuthenticodeDual" dest="__OUTPATHROOT__\PSScriptAnalyzer\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" />
7+
<file src="__INPATHROOT__\PSScriptAnalyzer\PSScriptAnalyzer.psd1" signType="Authenticode" dest="__OUTPATHROOT__\PSScriptAnalyzer\PSScriptAnalyzer.psd1" />
8+
<file src="__INPATHROOT__\PSScriptAnalyzer\PSScriptAnalyzer.psm1" signType="Authenticode" dest="__OUTPATHROOT__\PSScriptAnalyzer\PSScriptAnalyzer.psm1" />
9+
<file src="__INPATHROOT__\PSScriptAnalyzer\ScriptAnalyzer.format.ps1xml" signType="Authenticode" dest="__OUTPATHROOT__\PSScriptAnalyzer\ScriptAnalyzer.format.ps1xml" />
10+
<file src="__INPATHROOT__\PSScriptAnalyzer\ScriptAnalyzer.types.ps1xml" signType="Authenticode" dest="__OUTPATHROOT__\PSScriptAnalyzer\ScriptAnalyzer.types.ps1xml" />
11+
<file src="__INPATHROOT__\PSScriptAnalyzer\Settings\CmdletDesign.psd1" signType="Authenticode" dest="__OUTPATHROOT__\PSScriptAnalyzer\Settings\CmdletDesign.psd1" />
12+
<file src="__INPATHROOT__\PSScriptAnalyzer\Settings\CodeFormatting.psd1" signType="Authenticode" dest="__OUTPATHROOT__\PSScriptAnalyzer\Settings\CodeFormatting.psd1" />
13+
<file src="__INPATHROOT__\PSScriptAnalyzer\Settings\CodeFormattingAllman.psd1" signType="Authenticode" dest="__OUTPATHROOT__\PSScriptAnalyzer\Settings\CodeFormattingAllman.psd1" />
14+
<file src="__INPATHROOT__\PSScriptAnalyzer\Settings\CodeFormattingOTBS.psd1" signType="Authenticode" dest="__OUTPATHROOT__\PSScriptAnalyzer\Settings\CodeFormattingOTBS.psd1" />
15+
<file src="__INPATHROOT__\PSScriptAnalyzer\Settings\CodeFormattingStroustrup.psd1" signType="Authenticode" dest="__OUTPATHROOT__\PSScriptAnalyzer\Settings\CodeFormattingStroustrup.psd1" />
16+
<file src="__INPATHROOT__\PSScriptAnalyzer\Settings\DSC.psd1" signType="Authenticode" dest="__OUTPATHROOT__\PSScriptAnalyzer\Settings\DSC.psd1" />
17+
<file src="__INPATHROOT__\PSScriptAnalyzer\Settings\PSGallery.psd1" signType="Authenticode" dest="__OUTPATHROOT__\PSScriptAnalyzer\Settings\PSGallery.psd1" />
18+
<file src="__INPATHROOT__\PSScriptAnalyzer\Settings\ScriptFunctions.psd1" signType="Authenticode" dest="__OUTPATHROOT__\PSScriptAnalyzer\Settings\ScriptFunctions.psd1" />
19+
<file src="__INPATHROOT__\PSScriptAnalyzer\Settings\ScriptingStyle.psd1" signType="Authenticode" dest="__OUTPATHROOT__\PSScriptAnalyzer\Settings\ScriptingStyle.psd1" />
20+
<file src="__INPATHROOT__\PSScriptAnalyzer\Settings\ScriptSecurity.psd1" signType="Authenticode" dest="__OUTPATHROOT__\PSScriptAnalyzer\Settings\ScriptSecurity.psd1" />
21+
</job>
22+
<job platform="" configuration="" dest="__OUTPATHROOT__\signed" jobname="PowerShell Script Analyzer core" approvers="vigarg;gstolt">
23+
<file src="__INPATHROOT__\PSScriptAnalyzer\coreclr\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" signType="AuthenticodeDual" dest="__OUTPATHROOT__\PSScriptAnalyzer\coreclr\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" />
24+
<file src="__INPATHROOT__\PSScriptAnalyzer\coreclr\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" signType="AuthenticodeDual" dest="__OUTPATHROOT__\PSScriptAnalyzer\coreclr\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" />
25+
</job>
26+
<job platform="" configuration="" dest="__OUTPATHROOT__\signed" jobname="PowerShell Script Analyzer PSv3" approvers="vigarg;gstolt">
27+
<file src="__INPATHROOT__\PSScriptAnalyzer\PSv3\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" signType="AuthenticodeDual" dest="__OUTPATHROOT__\PSScriptAnalyzer\PSv3\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" />
28+
<file src="__INPATHROOT__\PSScriptAnalyzer\PSv3\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" signType="AuthenticodeDual" dest="__OUTPATHROOT__\PSScriptAnalyzer\PSv3\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" />
29+
</job>
30+
</SignConfigXML>

tools/releaseBuild/updateSigning.ps1

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
param(
4+
[string] $SigningXmlPath = (Join-Path -Path $PSScriptRoot -ChildPath 'signing.xml')
5+
)
6+
# Script for use in VSTS to update signing.xml
7+
8+
# Parse the signing xml
9+
$signingXml = [xml](Get-Content $signingXmlPath)
10+
11+
# Get any variables to updating 'signType' in the XML
12+
# Define a varabile named `<signTypeInXml>SignType' in VSTS to updating that signing type
13+
# Example: $env:AuthenticodeSignType='newvalue'
14+
# will cause all files with the 'Authenticode' signtype to be updated with the 'newvalue' signtype
15+
$signTypes = @{}
16+
Get-ChildItem -Path env:/*SignType | ForEach-Object -Process {
17+
$signType = $_.Name.ToUpperInvariant().Replace('SIGNTYPE','')
18+
Write-Host "Found SigningType $signType with value $($_.value)"
19+
$signTypes[$signType] = $_.Value
20+
}
21+
22+
# examine each job in the xml
23+
$signingXml.SignConfigXML.job | ForEach-Object -Process {
24+
# examine each file in the job
25+
$_.file | ForEach-Object -Process {
26+
# if the sign type is one of the variables we found, update it to the new value
27+
$signType = $_.SignType.ToUpperInvariant()
28+
if($signTypes.ContainsKey($signType))
29+
{
30+
$newSignType = $signTypes[$signType]
31+
Write-Host "Updating $($_.src) to $newSignType"
32+
$_.signType = $newSignType
33+
}
34+
}
35+
}
36+
37+
$signingXml.Save($signingXmlPath)

tools/releaseBuild/vstsbuild.ps1

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
[cmdletbinding()]
2+
param(
3+
[Parameter(Mandatory=$true,Position=0)]
4+
[ValidatePattern("^v\d+\.\d+\.\d+(-\w+(\.\d+)?)?$")]
5+
[string]$ReleaseTag
6+
)
7+
8+
Begin
9+
{
10+
$ErrorActionPreference = 'Stop'
11+
12+
$gitBinFullPath = (Get-Command -Name git -CommandType Application).Path | Select-Object -First 1
13+
if ( ! $gitBinFullPath )
14+
{
15+
throw "Git is missing! Install from 'https://git-scm.com/download/win'"
16+
}
17+
18+
# clone the release tools
19+
$releaseToolsDirName = "PSRelease"
20+
$releaseToolsLocation = Join-Path -Path $PSScriptRoot -ChildPath PSRelease
21+
if ( Test-Path $releaseToolsLocation )
22+
{
23+
Remove-Item -Force -Recurse -Path $releaseToolsLocation
24+
}
25+
& $gitBinFullPath clone -b master --quiet https://github.com/PowerShell/${releaseToolsDirName}.git $releaseToolsLocation
26+
Import-Module "$releaseToolsLocation/vstsBuild" -Force
27+
Import-Module "$releaseToolsLocation/dockerBasedBuild" -Force
28+
}
29+
30+
End {
31+
32+
$AdditionalFiles = .{
33+
Join-Path $PSScriptRoot -child "Image/buildPSSA.ps1"
34+
Join-Path $PSScriptRoot -child "Image/dockerInstall.psm1"
35+
}
36+
$buildPackageName = $null
37+
38+
# defined if building in VSTS
39+
if($env:BUILD_STAGINGDIRECTORY)
40+
{
41+
# Use artifact staging if running in VSTS
42+
$destFolder = $env:BUILD_STAGINGDIRECTORY
43+
}
44+
else
45+
{
46+
# Use temp as destination if not running in VSTS
47+
$destFolder = $env:temp
48+
}
49+
50+
$resolvedRepoRoot = (Resolve-Path (Join-Path -Path $PSScriptRoot -ChildPath "../../")).Path
51+
52+
try
53+
{
54+
Write-Verbose "Starting build at $resolvedRepoRoot ..." -Verbose
55+
Clear-VstsTaskState
56+
57+
$buildParameters = @{
58+
ReleaseTag = $ReleaseTag
59+
}
60+
$buildArgs = @{
61+
RepoPath = $resolvedRepoRoot
62+
BuildJsonPath = './tools/releaseBuild/build.json'
63+
Parameters = $buildParameters
64+
AdditionalFiles = $AdditionalFiles
65+
Name = "win7-x64"
66+
}
67+
Invoke-Build @buildArgs
68+
}
69+
catch
70+
{
71+
Write-VstsError -Error $_
72+
}
73+
finally{
74+
Write-VstsTaskState
75+
exit 0
76+
}
77+
}

0 commit comments

Comments
 (0)