Convert builds into a psake build script (#61)
* Create psake build script and modify existing scripts to use it * Add option to build standalone executables for sestest
This commit is contained in:
Родитель
8776b4d553
Коммит
0f022a6669
|
@ -8,13 +8,5 @@ param (
|
|||
$configuration = "Debug"
|
||||
)
|
||||
|
||||
. $PSScriptRoot\scripts\includes.ps1
|
||||
|
||||
$msbuildExe = resolve-path "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe"
|
||||
Write-Output "MSBuild executable: $msbuildExe"
|
||||
|
||||
Write-Header "Build Native Library for Windows"
|
||||
& $msbuildExe .\src\Microsoft.Azure.Batch.SoftwareEntitlement.Client.Native\ /property:Configuration=$configuration /property:Platform=$platform
|
||||
|
||||
Write-Header "Build Native console tool for Windows"
|
||||
& $msbuildExe .\src\sesclient.native\ /property:Configuration=$configuration /property:Platform=$platform
|
||||
. .\scripts\bootstrap.ps1
|
||||
invoke-psake -buildFile .\scripts\psake-build.ps1 -taskList Request.$platform, Request.$configuration, Build.Windows
|
||||
|
|
|
@ -1,19 +1,6 @@
|
|||
#
|
||||
# Build the cross-platform parts of the SDK using dotnet.exe
|
||||
#
|
||||
. $PSScriptRoot\scripts\includes.ps1
|
||||
|
||||
$dotnetExe = (get-command dotnet).Path
|
||||
Write-Host "Dotnet executable: $dotnetExe"
|
||||
|
||||
Write-Header "Restoring Nuget packages"
|
||||
& $dotnetExe restore .\src\sestest
|
||||
|
||||
Write-Header "Building SESTEST"
|
||||
& $dotnetExe build .\src\sestest
|
||||
|
||||
Write-Header "Running Unit Tests"
|
||||
foreach ($project in (resolve-path .\tests\*\*.csproj))
|
||||
{
|
||||
& $dotnetExe test $project
|
||||
}
|
||||
. .\scripts\bootstrap.ps1
|
||||
invoke-psake -buildFile .\scripts\psake-build.ps1 -taskList Build.Xplat
|
||||
|
|
|
@ -1,20 +1,5 @@
|
|||
#
|
||||
# Clean out all files from the .\out\ build artifacts directory
|
||||
#
|
||||
. $PSScriptRoot\scripts\includes.ps1
|
||||
|
||||
$srcFolder = resolve-path $PSScriptRoot\src
|
||||
$testsFolder = resolve-path $PSScriptRoot\tests
|
||||
$outFolder = resolve-path $PSScriptRoot\out
|
||||
|
||||
Write-Header "Cleaning"
|
||||
|
||||
Write-Output $srcFolder.Path
|
||||
remove-item $srcFolder\*\obj\* -recurse -ErrorAction SilentlyContinue
|
||||
|
||||
Write-Output $testsFolder.Path
|
||||
remove-item $testsFolder\*\obj\* -recurse -ErrorAction SilentlyContinue
|
||||
|
||||
Write-Output $outFolder.Path
|
||||
remove-item $outFolder\* -recurse -ErrorAction SilentlyContinue
|
||||
|
||||
. .\scripts\bootstrap.ps1
|
||||
invoke-psake -buildFile .\scripts\psake-build.ps1 -taskList Clean
|
||||
|
|
|
@ -10,6 +10,8 @@ The `sestest` command line utility and associated libraries are written in C#7 a
|
|||
|
||||
The C++ source for the client library requires [libcurl](https://curl.haxx.se/libcurl/) and [OpenSSL](https://www.openssl.org/) libraries as installed by [vcpkg](https://blogs.msdn.microsoft.com/vcblog/2016/09/19/vcpkg-a-tool-to-acquire-and-build-c-open-source-libraries-on-windows/). The library was also written with Visual Studio 2017; it will compile with any modern C++ compiler. For more information (including details of configuration and use of `vcpkg`) see the [Software entitlement service native client library](../src/Microsoft.Azure.Batch.SoftwareEntitlement.Client.Native)
|
||||
|
||||
Build scripts and other tooling are written in PowerShell using the [Psake](https://github.com/psake/psake) make tool. Preinstallation of Psake is optional; if it isn't already available, the build scripts will attempt to use a local version downloaded via NuGet. (See `scripts/bootstrap.ps1` for details.)
|
||||
|
||||
## Building `sestest`
|
||||
|
||||
*The console application `sestest` is a utility for generating and verifying software entitlement tokens during development and test.*
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
#
|
||||
# Publish the cross-platform parts of the SDK as standalone executables
|
||||
#
|
||||
. .\scripts\bootstrap.ps1
|
||||
invoke-psake -buildFile .\scripts\psake-build.ps1 -taskList Publish.Xplat
|
|
@ -0,0 +1,34 @@
|
|||
#
|
||||
# Run a build using Psake
|
||||
#
|
||||
|
||||
# Bootstrap - make sure we have Psake available
|
||||
|
||||
$psakeModule = get-module psake
|
||||
|
||||
if ($psakeModule -eq $null) {
|
||||
# Don't already have psake loaded, try to load it from a default location
|
||||
import-module psake -ErrorAction SilentlyContinue
|
||||
$psakeModule = get-module psake
|
||||
}
|
||||
|
||||
if ($psakeModule -eq $null) {
|
||||
# Still don't have psake loaded, try find it through NuGet
|
||||
$path = Resolve-Path $env:USERPROFILE\.nuget\psake\*\psake.psm1
|
||||
if ($path -eq $null) {
|
||||
$path = Resolve-Path $env:NugetMachineInstallRoot\psake\*\psake.psm1
|
||||
}
|
||||
|
||||
if ($path -ne $null) {
|
||||
import-module $path -ErrorAction SilentlyContinue
|
||||
$psakeModule = get-module psake
|
||||
}
|
||||
}
|
||||
|
||||
$psakePath = $psakeModule.Path
|
||||
|
||||
Write-Host "Using psake from $psakePath"
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,188 @@
|
|||
##
|
||||
## Psake build file for the Software Entitlement Service SDK
|
||||
##
|
||||
|
||||
properties {
|
||||
$baseDir = resolve-path ..\
|
||||
$buildDir = join-path $baseDir build
|
||||
$srcDir = resolve-path $baseDir\src
|
||||
$testsDir = resolve-path $baseDir\tests
|
||||
$outDir = join-path $baseDir out
|
||||
$publishDir = join-path $baseDir publish
|
||||
}
|
||||
|
||||
Task Clean -Depends Clean.SourceFolder, Clean.OutFolder, Clean.PublishFolder
|
||||
|
||||
Task Build.Xplat -Depends Build.SesTest, Unit.Tests
|
||||
|
||||
Task Publish.Xplat -Depends Clean.Publish, Publish.SesTest.Win64, Publish.SesTest.Linux64
|
||||
|
||||
Task Build.Windows -Depends Build.SesLibrary, Build.SesClient
|
||||
|
||||
## --------------------------------------------------------------------------------
|
||||
## Preparation Targets
|
||||
## --------------------------------------------------------------------------------
|
||||
## Tasks used to prepare for the actual build
|
||||
|
||||
Task Restore.NuGetPackages -Depends Requires.DotNetExe {
|
||||
exec {
|
||||
& $dotnetExe restore $baseDir\src\sestest
|
||||
}
|
||||
}
|
||||
|
||||
Task Clean.SourceFolder {
|
||||
remove-item $srcDir\*\obj\* -recurse -ErrorAction SilentlyContinue
|
||||
remove-item $testsDir\*\obj\* -recurse -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
Task Clean.OutFolder {
|
||||
remove-item $outDir\* -recurse -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
Task Clean.PublishFolder {
|
||||
remove-item $publishDir -Force -Recurse
|
||||
}
|
||||
|
||||
## --------------------------------------------------------------------------------
|
||||
## Build Targets
|
||||
## --------------------------------------------------------------------------------
|
||||
## Tasks used to perform steps of the actual build
|
||||
|
||||
Task Build.SesTest -Depends Requires.DotNetExe, Restore.NuGetPackages {
|
||||
exec {
|
||||
& $dotnetExe build $srcDir\sestest
|
||||
}
|
||||
}
|
||||
|
||||
Task Build.SesLibrary -Depends Requires.MsBuild, Requires.Configuration, Requires.Platform {
|
||||
exec {
|
||||
& $msbuildExe $srcDir\Microsoft.Azure.Batch.SoftwareEntitlement.Client.Native\ /property:Configuration=$configuration /property:Platform=$targetPlatform
|
||||
}
|
||||
}
|
||||
|
||||
Task Build.SesClient -Depends Requires.MsBuild, Requires.Configuration, Requires.Platform {
|
||||
exec {
|
||||
& $msbuildExe $srcDir\sesclient.native\ /property:Configuration=$configuration /property:Platform=$targetPlatform
|
||||
}
|
||||
}
|
||||
|
||||
Task Unit.Tests -Depends Requires.DotNetExe, Build.SesTest {
|
||||
foreach ($project in (resolve-path $testsDir\*\*.csproj)){
|
||||
Write-SubtaskName (split-path $project -Leaf)
|
||||
exec {
|
||||
& $dotnetExe test $project
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Task Publish.SesTest.Win64 -Depends Requires.DotNetExe, Restore.NuGetPackages {
|
||||
exec {
|
||||
& $dotnetExe publish $srcDir\sestest\sestest.csproj --self-contained --output $publishDir\sestest\win10-x64 --runtime win10-x64
|
||||
}
|
||||
|
||||
exec {
|
||||
compress-archive $publishDir\sestest\win10-x64\* $publishDir\sestest-win10-x64.zip
|
||||
}
|
||||
}
|
||||
|
||||
Task Publish.SesTest.Linux64 -Depends Requires.DotNetExe, Restore.NuGetPackages {
|
||||
exec {
|
||||
& $dotnetExe publish $srcDir\sestest\sestest.csproj --self-contained --output $publishDir\sestest\linux-x64 --runtime linux-x64
|
||||
}
|
||||
|
||||
exec {
|
||||
compress-archive $publishDir\sestest\linux-x64\* $publishDir\sestest-linux-x64.zip
|
||||
}
|
||||
}
|
||||
|
||||
## --------------------------------------------------------------------------------
|
||||
## Configuration Targets
|
||||
## --------------------------------------------------------------------------------
|
||||
## Tasks used to configure the build
|
||||
|
||||
Task Request.x64 {
|
||||
$script:targetPlatform = "x64"
|
||||
}
|
||||
|
||||
Task Request.x86 {
|
||||
$script:targetPlatform = "x86"
|
||||
}
|
||||
|
||||
Task Request.Debug {
|
||||
$script:configuration = "Debug"
|
||||
}
|
||||
|
||||
Task Request.Release {
|
||||
$script:configuration = "Release"
|
||||
}
|
||||
|
||||
## --------------------------------------------------------------------------------
|
||||
## Prerequisite Targets
|
||||
## --------------------------------------------------------------------------------
|
||||
## Tasks used to ensure that prerequisites are available when needed.
|
||||
|
||||
Task Requires.Configuration {
|
||||
if ($configuration -eq $null) {
|
||||
$script:configuration = "Debug"
|
||||
}
|
||||
|
||||
Write-Host "Build configuration is $configuration"
|
||||
}
|
||||
|
||||
Task Requires.DotNetExe {
|
||||
$script:dotnetExe = (get-command dotnet).Path
|
||||
|
||||
if ($dotnetExe -eq $null)
|
||||
{
|
||||
$script:dotnetExe = resolve-path $env:ProgramFiles\dotnet\dotnet.exe -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
if ($dotnetExe -eq $null)
|
||||
{
|
||||
throw "Failed to find dotnet.exe"
|
||||
}
|
||||
|
||||
Write-Host "Dotnet executable: $dotnetExe"
|
||||
}
|
||||
|
||||
Task Requires.MsBuild {
|
||||
# prefer MSBuild from VS2017 if its there
|
||||
$script:msbuildExe = resolve-path "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\*\MSBuild\*\Bin\MSBuild.exe" -ErrorAction SilentlyContinue
|
||||
|
||||
if ($msbuildExe -eq $null)
|
||||
{
|
||||
$script:msbuildExe = (get-command msbuild).Path
|
||||
}
|
||||
|
||||
if ($msbuildExe -eq $null)
|
||||
{
|
||||
throw "Failed to find msbuild.exe"
|
||||
}
|
||||
|
||||
Write-Host "MSBuild executable: $msbuildExe"
|
||||
}
|
||||
|
||||
Task Requires.Platform {
|
||||
|
||||
if ($targetPlatform -eq $null) {
|
||||
$script:targetPlatform = "Debug"
|
||||
}
|
||||
|
||||
Write-Host "Target platform is $targetPlatform"
|
||||
}
|
||||
|
||||
## --------------------------------------------------------------------------------
|
||||
## Support Functions
|
||||
## --------------------------------------------------------------------------------
|
||||
|
||||
formatTaskName {
|
||||
param($taskName)
|
||||
|
||||
$divider = "-" * ((get-host).UI.RawUI.WindowSize.Width - 2)
|
||||
return "`r`n$divider`r`n $taskName`r`n$divider`r`n"
|
||||
}
|
||||
|
||||
function Write-SubtaskName($subtaskName) {
|
||||
$divider = "-" * ($subtaskName.Length + 4)
|
||||
Write-Host "`r`n$divider`r`n $subtaskName`r`n$divider"
|
||||
}
|
Загрузка…
Ссылка в новой задаче