Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit e3acf5a

Browse files
author
Bettina Heim
committed
first draft for build setup
1 parent 37981a0 commit e3acf5a

File tree

11 files changed

+291
-14
lines changed

11 files changed

+291
-14
lines changed

bootstrap.cmd

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
:: Initializes the current repo
2+
:: and prepares it for build
3+
@echo off
4+
5+
dotnet --info || GOTO missingDotnet
6+
git --version || GOTO missingGit
7+
8+
:: Set Build number on all files that uses it
9+
CALL setVersionNumber.cmd
10+
11+
:: Initialize the compiler's nuspec file
12+
CALL :nuspecBootstrap
13+
14+
:: Done
15+
GOTO EOF
16+
17+
:: Bootstrap the compiler nuspec
18+
:nuspecBootstrap
19+
pushd src\QsCompiler\Compiler
20+
call powershell -NoProfile .\FindNuspecReferences.ps1
21+
popd
22+
EXIT /B
23+
24+
:missingGit
25+
echo.
26+
echo This script depends on git.
27+
echo.
28+
echo Make sure you install it as part of Visual Studio, and then run this
29+
echo script inside the "Developer Command Prompt for VS 2017"
30+
echo.
31+
EXIT /B 1001
32+
33+
:missingDotnet
34+
echo.
35+
echo You need to install dotnet core to use/build Solid:
36+
echo https://www.microsoft.com/net/download
37+
echo.
38+
EXIT /B 1002
39+
40+
:EOF

build/ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: $(Build.Major).$(Build.Minor).$(date:yyMM).$(DayOfMonth)$(rev:rr)
2+
trigger: none
3+
4+
variables:
5+
- template: vars-common.yml
6+
7+
8+
jobs:
9+
- job: "QsCompiler"
10+
steps:
11+
- template: steps.yml

build/init.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
steps:
2+
3+
##
4+
# Pre-reqs
5+
##
6+
- task: Npm@1
7+
displayName: 'npm install -g vsce'
8+
inputs:
9+
command: custom
10+
verbose: false
11+
customCommand: 'install -g vsce'
12+
13+
- task: NuGetToolInstaller@0
14+
displayName: 'Use NuGet 4.9.3'
15+
inputs:
16+
versionSpec: '4.9.3'
17+
18+
##
19+
# Bootstrap
20+
##
21+
- task: BatchScript@1
22+
displayName: 'Run bootstrap.cmd'
23+
inputs:
24+
filename: bootstrap.cmd
25+
modifyEnvironment: true

build/pack.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
steps:
2+
3+
- task: NuGetCommand@2
4+
displayName: 'Pack Q# compiler'
5+
inputs:
6+
command: pack
7+
packagesToPack: >
8+
src\QsCompiler\Compiler\QsCompiler.csproj;
9+
versioningScheme: byEnvVar
10+
versionEnvVar: NUGET_VERSION
11+
packDestination: '$(System.DefaultWorkingDirectory)'
12+
includeReferencedProjects: true
13+
14+
- task: CmdLine@1
15+
displayName: 'Pack VS Code extension'
16+
inputs:
17+
filename: vsce
18+
arguments: package
19+
workingFolder: $(VSCodeExtensionSrcDir)
20+
21+
- task: MSBuild@1
22+
displayName: 'Pack Visual Studio extension'
23+
inputs:
24+
solution: '$(VSExtensionSrcDir)/../VisualStudioExtension.sln'
25+
configuration: '$(BuildConfiguration)'
26+
msbuildArguments: >
27+
/t:CreateVsixContainer
28+
/p:AssemblyVersion=$(Assembly.Version)
29+
30+
- task: NuGetCommand@2
31+
displayName: 'Pack project templates'
32+
inputs:
33+
command: pack
34+
packagesToPack: >
35+
src\Nuspecs\Microsoft.Quantum.ProjectTemplates.nuspec;
36+
versioningScheme: byEnvVar
37+
versionEnvVar: NUGET_VERSION
38+
packDestination: '$(System.DefaultWorkingDirectory)'
39+
includeReferencedProjects: false

build/sdl-tools.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
##
2+
# Runs scanning tools from security team.
3+
# See https://www.1eswiki.com/wiki/Secure_Development_Tools_Extension_For_Azure_DevOps
4+
##
5+
steps:
6+
- task: ComponentGovernanceComponentDetection@0
7+
displayName: 'Components Detection'
8+
inputs:
9+
snapshotForceEnabled: true
10+
condition: and(succeededOrFailed(), variables.SDLScan)
11+
12+
13+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-antimalware.AntiMalware@3
14+
displayName: 'SDL: Anti-Malware scan of build sources and/or artifacts'
15+
continueOnError: true
16+
condition: and(succeededOrFailed(), variables.SDLScan)
17+
18+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-autoapplicability.AutoApplicability@1
19+
displayName: 'SDL: Run AutoApplicability'
20+
inputs:
21+
ExternalRelease: true
22+
continueOnError: true
23+
condition: and(succeededOrFailed(), variables.SDLScan)
24+
25+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-binskim.BinSkim@3
26+
displayName: 'SDL: Analyze managed and unmanaged binaries (exe, dll) for security vulnerabilities (BinSkim)'
27+
inputs:
28+
InputType: Basic
29+
AnalyzeTarget: '$(DllsToScan)'
30+
AnalyzeVerbose: true
31+
AnalyzeHashes: true
32+
continueOnError: true
33+
condition: and(succeededOrFailed(), variables.SDLScan)
34+
35+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-codemetrics.CodeMetrics@1
36+
displayName: 'SDL: Analyze complexity of managed C# code (CodeMetrics)'
37+
inputs:
38+
Files: '$(DllsToScan)'
39+
continueOnError: true
40+
condition: and(succeededOrFailed(), variables.SDLScan)
41+
42+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2
43+
displayName: 'SDL: Analyze source and build output text files for credentials (CredScan)'
44+
inputs:
45+
debugMode: false
46+
continueOnError: true
47+
condition: and(succeededOrFailed(), variables.SDLScan)
48+
49+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-fxcop.FxCop@2
50+
displayName: 'SDL: Analyze C# code (.NET framework only) for security vulnerabilities (FxCop)'
51+
inputs:
52+
inputType: Basic
53+
targets: '$(DllsToScan)'
54+
continueOnError: true
55+
condition: and(succeededOrFailed(), variables.SDLScan)
56+
57+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-prefast.SDLNativeRules@2
58+
displayName: 'SDL: Run the PREfast SDL Native Rules for MSBuild'
59+
continueOnError: true
60+
condition: and(succeededOrFailed(), variables.SDLScan)
61+
62+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-vulnerabilityassessment.VulnerabilityAssessment@0
63+
displayName: 'SDL: Create Vulnerability Assessment'
64+
continueOnError: true
65+
condition: and(succeededOrFailed(), variables.SDLScan)
66+
67+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-publishsecurityanalysislogs.PublishSecurityAnalysisLogs@2
68+
displayName: 'SDL: Publish Security Analysis Logs'
69+
continueOnError: true
70+
condition: and(succeededOrFailed(), variables.SDLScan)
71+
72+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-postanalysis.PostAnalysis@1
73+
displayName: 'SDL: Post Analysis'
74+
inputs:
75+
BinSkim: true
76+
CredScan: true
77+
SDLNativeRules: true
78+
continueOnError: true
79+
condition: and(succeededOrFailed(), variables.SDLScan)

build/steps.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
steps:
2+
- template: init.yml
3+
4+
##
5+
# Build the compiler, language server and VS extension
6+
##
7+
- template: ../src/QsCompiler/build-steps.yml
8+
- template: ../src/VisualStudioExtension/build-steps.yml
9+
10+
##
11+
# Create the corresponding packages and extensions
12+
##
13+
- template: pack.yml
14+
15+
##
16+
# Wrap-up
17+
##
18+
- template: sdl-tools.yml
19+
- template: step-wrap-up.yml

build/vars-common.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
parameters:
2+
major: 0
3+
minor: 0
4+
nuget_pre: -alpha
5+
signed: ""
6+
7+
variables:
8+
Signed: ${{ parameters.signed }}
9+
Build.Major: ${{ parameters.major }}
10+
Build.Minor: ${{ parameters.minor }}
11+
Build.Verbosity: 'n'
12+
Assembly.Constants: $(Signed)
13+
Assembly.Version: $(Build.BuildNumber)
14+
Nuget.Version: $(Assembly.Version)${{ parameters.nuget_pre }}
15+
DocsOutDir: $(build.artifactstagingdirectory)\Docs.build
16+
NugetsOutDir: $(build.artifactstagingdirectory)\Nugets.build
17+
CompilerSrcDir: $(System.DefaultWorkingDirectory)/src/QsCompiler
18+
VSCodeExtensionSrcDir: $(System.DefaultWorkingDirectory)/src/VSCodeExtension
19+
VSExtensionSrcDir: $(System.DefaultWorkingDirectory)/src/VisualStudioExtension

build/wrap-up.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
##
2+
# Wrap-up, publish symbols and drop folder.
3+
##
4+
steps:
5+
- task: PublishSymbols@1
6+
displayName: 'Publish symbols path: '
7+
inputs:
8+
SearchPattern: '**\bin\**\*.pdb'
9+
continueOnError: true
10+
11+
- task: CopyFiles@2
12+
displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
13+
inputs:
14+
SourceFolder: '$(build.sourcesdirectory)'
15+
Contents: |
16+
src\**\*.vsix
17+
*.nupkg
18+
*.build\**
19+
TargetFolder: '$(build.artifactstagingdirectory)'
20+
condition: succeededOrFailed()
21+
22+
- task: PublishBuildArtifacts@1
23+
displayName: 'Publish Artifact: drop'
24+
inputs:
25+
PathtoPublish: '$(build.artifactstagingdirectory)'
26+
condition: succeededOrFailed()
27+
28+

setVersionNumber.cmd

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
::
2+
:: This script finds all *.v.template files and replaces
3+
:: their build tokens (e.g: #NUGET_VERSION#) with a valid value
4+
:: based on the MAJOR.MINOR.BUILDNUMBER
5+
::
6+
SET DATE=%date:~12,2%%date:~4,2%
7+
SET TIME=%time:~0,2%%time:~3,2%
8+
IF "%BUILD_MAJOR%" == "" SET BUILD_MAJOR=0
9+
IF "%BUILD_MINOR%" == "" SET BUILD_MINOR=0
10+
IF "%BUILD_BUILDNUMBER%" == "" SET BUILD_BUILDNUMBER=%BUILD_MAJOR%.%BUILD_MINOR%.%DATE%.%TIME%
11+
12+
SET REVISION=%BUILD_BUILDNUMBER:~-9%
13+
IF "%REVISION:~0,1%" == "." SET REVISION=%REVISION:~1%
14+
15+
IF "%ASSEMBLY_VERSION%" == "" SET ASSEMBLY_VERSION=%BUILD_MAJOR%.%BUILD_MINOR%.%REVISION%
16+
IF "%VSIX_VERSION%" == "" SET VSIX_VERSION=%ASSEMBLY_VERSION%
17+
IF "%PYTHON_VERSION%" == "" SET PYTHON_VERSION=%ASSEMBLY_VERSION%a1
18+
IF "%SEMVER_VERSION%" == "" SET SEMVER_VERSION=%BUILD_MAJOR%.%BUILD_MINOR%.%REVISION:.=%
19+
IF "%NUGET_VERSION%" == "" SET NUGET_VERSION=%VSIX_VERSION%-alpha
20+
21+
FOR /R %%F IN (*.v.template) DO CALL :updateOne %%F
22+
GOTO :done
23+
24+
:updateOne
25+
set original=%1
26+
SET target=%original:~0,-11%
27+
powershell -NoProfile -Command "(Get-Content %original% -Raw) | ForEach-Object { $_.replace('#ASSEMBLY_VERSION#', '%ASSEMBLY_VERSION%').replace('#NUGET_VERSION#', '%NUGET_VERSION%').replace('#VSIX_VERSION#', '%VSIX_VERSION%').replace('#SEMVER_VERSION#', '%SEMVER_VERSION%') } | Set-Content %target% -NoNewline"
28+
29+
:done

src/QsCompiler/build-steps.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,6 @@ steps:
99
command: test
1010
arguments: '-c $(BuildConfiguration) -v $(Build.Verbosity) /p:DefineConstants=$(Assembly.Constants) /p:Version=$(Assembly.Version)'
1111
projects: '$(CompilerSrcDir)/../QsCompiler.sln'
12-
13-
14-
- task: NuGetCommand@2
15-
displayName: 'Pack Q# compiler'
16-
inputs:
17-
command: pack
18-
packagesToPack: >
19-
src\QsCompiler\Compiler\QsCompiler.csproj;
20-
versioningScheme: byEnvVar
21-
versionEnvVar: NUGET_VERSION
22-
packDestination: '$(System.DefaultWorkingDirectory)'
23-
includeReferencedProjects: true
2412

2513

2614
- task: DotNetCoreCLI@2

0 commit comments

Comments
 (0)