2017-10-04 01:05:06 +03:00
|
|
|
# Copyright (c) Microsoft. All rights reserved.
|
|
|
|
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
|
|
|
|
<#
|
|
|
|
|
|
|
|
.SYNOPSIS
|
|
|
|
Microsoft Azure IoT SDK .NET build script.
|
|
|
|
|
|
|
|
.DESCRIPTION
|
|
|
|
Builds Azure IoT SDK binaries.
|
|
|
|
|
|
|
|
Parameters:
|
2020-02-05 02:49:41 +03:00
|
|
|
-configuration {Debug|Release}
|
|
|
|
-sign: (Internal use, requires signing toolset) Signs the binaries before release.
|
|
|
|
-package: Packs NuGets
|
2018-03-01 04:02:36 +03:00
|
|
|
-clean: Runs dotnet clean. Use `git clean -xdf` if this is not sufficient.
|
2020-02-05 02:49:41 +03:00
|
|
|
-build: Builds projects (use if re-running tests after a successful build).
|
|
|
|
-unittests: Runs unit tests
|
|
|
|
-prtests: Runs all tests selected for PR validation
|
2018-03-01 04:02:36 +03:00
|
|
|
-e2etests: Runs E2E tests. Requires prerequisites and environment variables.
|
|
|
|
-stresstests: Runs Stress tests.
|
2018-03-14 03:47:43 +03:00
|
|
|
-publish: (Internal use, requires nuget toolset) Publishes the nuget packages.
|
2017-10-04 01:05:06 +03:00
|
|
|
-verbosity: Sets the verbosity level of the command. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic].
|
2020-03-17 01:13:55 +03:00
|
|
|
-framework: Select which framework to run tests on. Allowed values examples include, but are not limited to, "netcoreapp3.1", "net47", "net451"
|
2020-02-06 22:42:55 +03:00
|
|
|
-skipIotHubTests: Provide this flag if you want to skip all IoT Hub integration tests
|
|
|
|
-skipDPSTests: Provide this flag if you want to skip all DPS integration tests
|
|
|
|
|
2018-03-12 22:20:48 +03:00
|
|
|
|
2018-03-01 04:02:36 +03:00
|
|
|
Build will automatically detect if the machine is Windows vs Unix. On Windows development boxes, additional testing on .NET Framework will be performed.
|
2017-10-04 01:05:06 +03:00
|
|
|
|
2018-03-12 22:20:48 +03:00
|
|
|
The following environment variables can tune the build behavior:
|
|
|
|
- AZURE_IOT_DONOTSIGN: disables delay-signing if set to 'TRUE'
|
|
|
|
- AZURE_IOT_LOCALPACKAGES: the path to the local nuget source.
|
|
|
|
Add a new source using: `nuget sources add -name MySource -Source <path>`
|
|
|
|
Remove a source using: `nuget sources remove -name MySource`
|
|
|
|
|
|
|
|
.EXAMPLE
|
2018-03-01 04:02:36 +03:00
|
|
|
.\build
|
2017-10-04 01:05:06 +03:00
|
|
|
|
2018-03-01 04:02:36 +03:00
|
|
|
Builds a Debug version of the SDK.
|
2017-10-04 01:05:06 +03:00
|
|
|
.EXAMPLE
|
2020-02-05 02:49:41 +03:00
|
|
|
.\build -configuration Release -build
|
2017-10-04 01:05:06 +03:00
|
|
|
|
2018-03-01 04:02:36 +03:00
|
|
|
Builds a Release version of the SDK.
|
|
|
|
.EXAMPLE
|
2020-02-05 02:49:41 +03:00
|
|
|
.\build -clean -build -unittests
|
2017-10-04 01:05:06 +03:00
|
|
|
|
2020-02-05 02:49:41 +03:00
|
|
|
Builds and runs unit tests (requires prerequisites).
|
2018-03-01 04:02:36 +03:00
|
|
|
.EXAMPLE
|
2020-02-05 02:49:41 +03:00
|
|
|
.\build -configuration Release -sign -package -e2etests
|
2018-03-01 04:02:36 +03:00
|
|
|
|
2020-02-05 02:49:41 +03:00
|
|
|
Runs E2E tests with already built binaries.
|
2017-10-04 01:05:06 +03:00
|
|
|
.LINK
|
|
|
|
https://github.com/azure/azure-iot-sdk-csharp
|
|
|
|
|
|
|
|
#>
|
|
|
|
|
|
|
|
Param(
|
2020-02-05 02:49:41 +03:00
|
|
|
[string] $configuration = "Debug",
|
|
|
|
[switch] $sign,
|
|
|
|
[switch] $package,
|
2017-10-04 01:05:06 +03:00
|
|
|
[switch] $clean,
|
2020-02-05 02:49:41 +03:00
|
|
|
[switch] $build,
|
|
|
|
[switch] $unittests,
|
|
|
|
[switch] $prtests,
|
2017-10-17 22:49:19 +03:00
|
|
|
[switch] $e2etests,
|
2018-03-01 04:02:36 +03:00
|
|
|
[switch] $stresstests,
|
2018-03-14 03:47:43 +03:00
|
|
|
[switch] $publish,
|
2020-02-06 22:42:55 +03:00
|
|
|
[string] $verbosity = "q",
|
|
|
|
[string] $framework = "*",
|
|
|
|
[switch] $skipIotHubTests,
|
2020-07-11 00:02:16 +03:00
|
|
|
[switch] $skipDPSTests,
|
|
|
|
[switch] $noBuildBeforeTesting
|
2017-10-04 01:05:06 +03:00
|
|
|
)
|
|
|
|
|
2018-03-12 22:20:48 +03:00
|
|
|
Function CheckSignTools()
|
|
|
|
{
|
|
|
|
$commands = $("SignDotNetBinary", "SignBinary", "SignNuGetPackage", "SignMSIPackage")
|
2018-03-14 03:47:43 +03:00
|
|
|
CheckTools $commands
|
|
|
|
}
|
|
|
|
|
|
|
|
Function CheckPublishTools()
|
|
|
|
{
|
|
|
|
$commands = $("PushNuGet")
|
|
|
|
CheckTools $commands
|
|
|
|
}
|
2018-03-12 22:20:48 +03:00
|
|
|
|
2018-03-14 03:47:43 +03:00
|
|
|
Function CheckTools($commands)
|
|
|
|
{
|
2020-02-05 02:49:41 +03:00
|
|
|
foreach ($command in $commands)
|
2018-03-12 22:20:48 +03:00
|
|
|
{
|
|
|
|
$info = Get-Command $command -ErrorAction SilentlyContinue
|
2020-02-05 02:49:41 +03:00
|
|
|
if (-not $info)
|
2018-03-12 22:20:48 +03:00
|
|
|
{
|
2018-03-14 03:47:43 +03:00
|
|
|
throw "Toolset not found: '$command' is missing."
|
2018-03-12 22:20:48 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-15 00:51:39 +03:00
|
|
|
Function CheckLocalPackagesAvailableForTesting()
|
2020-07-17 21:28:40 +03:00
|
|
|
{
|
2020-08-15 00:51:39 +03:00
|
|
|
$localPackagesAvailableForTesting = (-not [string]::IsNullOrWhiteSpace($env:AZURE_IOT_LOCALPACKAGES))
|
2020-07-17 21:28:40 +03:00
|
|
|
}
|
|
|
|
|
2020-02-05 02:49:41 +03:00
|
|
|
Function BuildProject($path, $message)
|
|
|
|
{
|
2018-02-06 02:59:07 +03:00
|
|
|
$label = "BUILD: --- $message $configuration ---"
|
|
|
|
|
2017-10-04 01:05:06 +03:00
|
|
|
Write-Host
|
2018-02-06 02:59:07 +03:00
|
|
|
Write-Host -ForegroundColor Cyan $label
|
2017-10-04 01:05:06 +03:00
|
|
|
|
2020-02-05 02:49:41 +03:00
|
|
|
$projectPath = Join-Path $rootDir $path
|
|
|
|
|
|
|
|
if ($clean)
|
|
|
|
{
|
|
|
|
& dotnet clean $projectPath --verbosity $verbosity --configuration $configuration
|
|
|
|
if ($LASTEXITCODE -ne 0)
|
|
|
|
{
|
2018-02-06 02:59:07 +03:00
|
|
|
throw "Clean failed: $label"
|
2017-10-04 01:05:06 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-05 02:49:41 +03:00
|
|
|
& dotnet build $projectPath --verbosity $verbosity --configuration $configuration
|
2017-10-04 01:05:06 +03:00
|
|
|
|
2020-02-05 02:49:41 +03:00
|
|
|
if ($LASTEXITCODE -ne 0)
|
|
|
|
{
|
2018-02-06 02:59:07 +03:00
|
|
|
throw "Build failed: $label"
|
2017-10-04 01:05:06 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-05 02:49:41 +03:00
|
|
|
Function BuildPackage($path, $message)
|
|
|
|
{
|
2018-03-01 04:02:36 +03:00
|
|
|
$label = "PACK: --- $message $configuration ---"
|
2018-02-06 02:59:07 +03:00
|
|
|
|
2017-10-04 01:05:06 +03:00
|
|
|
Write-Host
|
2018-02-06 02:59:07 +03:00
|
|
|
Write-Host -ForegroundColor Cyan $label
|
2017-10-04 01:05:06 +03:00
|
|
|
|
2018-03-12 22:20:48 +03:00
|
|
|
$projectPath = Join-Path $rootDir $path
|
2020-02-05 02:49:41 +03:00
|
|
|
$projectName = (Get-ChildItem (Join-Path $projectPath *.csproj))[0].BaseName
|
2018-03-12 22:20:48 +03:00
|
|
|
|
|
|
|
if ($sign)
|
|
|
|
{
|
2020-02-05 02:49:41 +03:00
|
|
|
Set-Location $projectPath
|
|
|
|
Write-Host -ForegroundColor Magenta "`tSigning binaries for: $projectName"
|
|
|
|
$filesToSign = Get-ChildItem -Path "$projectPath\bin\$configuration\*\$projectName.dll" -Recurse
|
2018-03-12 22:20:48 +03:00
|
|
|
SignDotNetBinary $filesToSign
|
|
|
|
}
|
2017-10-04 01:05:06 +03:00
|
|
|
|
2018-03-12 22:20:48 +03:00
|
|
|
& dotnet pack --verbosity $verbosity --configuration $configuration --no-build --include-symbols --include-source --output $localPackages
|
2018-03-14 03:47:43 +03:00
|
|
|
|
2020-02-05 02:49:41 +03:00
|
|
|
if ($LASTEXITCODE -ne 0)
|
|
|
|
{
|
2018-03-12 22:20:48 +03:00
|
|
|
throw "Package failed: $label"
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($sign)
|
|
|
|
{
|
|
|
|
Write-Host -ForegroundColor Magenta "`tSigning package: $projectName"
|
2020-02-05 02:49:41 +03:00
|
|
|
$filesToSign = Get-ChildItem (Join-Path $localPackages "$projectName.*.nupkg")
|
2018-03-12 22:20:48 +03:00
|
|
|
SignNuGetPackage $filesToSign
|
2017-10-04 01:05:06 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-05 02:49:41 +03:00
|
|
|
Function RunTests($message, $framework = "*", $filterTestCategory = "*")
|
|
|
|
{
|
2020-02-06 22:42:55 +03:00
|
|
|
$label = "TEST: --- $message $configuration $framework $filterTestCategory ---"
|
2018-02-06 02:59:07 +03:00
|
|
|
|
2017-10-04 01:05:06 +03:00
|
|
|
Write-Host
|
2018-02-06 02:59:07 +03:00
|
|
|
Write-Host -ForegroundColor Cyan $label
|
2017-10-04 01:05:06 +03:00
|
|
|
|
2020-07-11 00:02:16 +03:00
|
|
|
$runTestCmd = "dotnet test -s test.runsettings --verbosity $verbosity --configuration $configuration --logger trx"
|
|
|
|
|
|
|
|
if ($noBuildBeforeTesting)
|
|
|
|
{
|
|
|
|
$runTestCmd += " --no-build"
|
|
|
|
}
|
2020-02-05 02:49:41 +03:00
|
|
|
if ($filterTestCategory -ne "*")
|
2018-10-26 20:17:32 +03:00
|
|
|
{
|
2020-02-05 02:49:41 +03:00
|
|
|
$runTestCmd += " --filter '$filterTestCategory'"
|
2018-10-26 20:17:32 +03:00
|
|
|
}
|
2020-02-05 02:49:41 +03:00
|
|
|
if ($framework -ne "*")
|
2018-10-26 20:17:32 +03:00
|
|
|
{
|
2020-02-05 02:49:41 +03:00
|
|
|
$runTestCmd += " --framework $framework"
|
2018-10-26 20:17:32 +03:00
|
|
|
}
|
2017-10-04 01:05:06 +03:00
|
|
|
|
2020-02-05 02:49:41 +03:00
|
|
|
# By specifying the root dir, the test runner will run all tests in test projects in the VS solution there
|
|
|
|
Set-Location $rootDir
|
|
|
|
|
2020-02-12 22:33:08 +03:00
|
|
|
Write-Host "Invoking expression: $runTestCmd ----------"
|
2020-02-05 02:49:41 +03:00
|
|
|
Invoke-Expression $runTestCmd
|
|
|
|
|
|
|
|
if ($LASTEXITCODE -ne 0)
|
|
|
|
{
|
2020-01-17 05:25:20 +03:00
|
|
|
throw "Tests failed: $label"
|
2017-10-04 01:05:06 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-17 01:13:55 +03:00
|
|
|
Function RunApp($path, $message, $framework = "netcoreapp3.1")
|
2020-02-05 02:49:41 +03:00
|
|
|
{
|
2018-03-01 04:02:36 +03:00
|
|
|
$label = "RUN: --- $message $configuration ---"
|
2018-02-06 02:59:07 +03:00
|
|
|
|
2017-12-05 06:07:13 +03:00
|
|
|
Write-Host
|
2018-02-06 02:59:07 +03:00
|
|
|
Write-Host -ForegroundColor Cyan $label
|
2020-02-05 02:49:41 +03:00
|
|
|
$appPath = (Join-Path $rootDir $path)
|
2017-12-05 06:07:13 +03:00
|
|
|
|
2020-02-05 02:49:41 +03:00
|
|
|
& dotnet run --project $appPath --framework $framework --verbosity $verbosity --configuration $configuration --logger "trx"
|
2017-12-05 06:07:13 +03:00
|
|
|
|
2020-02-05 02:49:41 +03:00
|
|
|
if ($LASTEXITCODE -ne 0)
|
|
|
|
{
|
2018-02-06 02:59:07 +03:00
|
|
|
throw "Tests failed: $label"
|
2017-12-05 06:07:13 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-01 04:02:36 +03:00
|
|
|
$rootDir = (Get-Item -Path ".\" -Verbose).FullName
|
|
|
|
$localPackages = Join-Path $rootDir "bin\pkg"
|
2017-10-04 01:05:06 +03:00
|
|
|
$startTime = Get-Date
|
|
|
|
$buildFailed = $true
|
2018-02-06 02:59:07 +03:00
|
|
|
$errorMessage = ""
|
2020-08-15 00:51:39 +03:00
|
|
|
$localPackagesAvailableForTesting = $false
|
2017-10-04 01:05:06 +03:00
|
|
|
|
2020-02-05 02:49:41 +03:00
|
|
|
try
|
|
|
|
{
|
2018-03-12 22:20:48 +03:00
|
|
|
if ($sign)
|
|
|
|
{
|
2020-08-15 00:51:39 +03:00
|
|
|
CheckLocalPackagesAvailableForTesting
|
|
|
|
if ($localPackagesAvailableForTesting)
|
2018-04-05 04:48:21 +03:00
|
|
|
{
|
|
|
|
throw "Local NuGet package source path is not set, required when signing packages."
|
|
|
|
}
|
|
|
|
|
2020-02-05 02:49:41 +03:00
|
|
|
if ($configuration -ne "Release")
|
|
|
|
{
|
|
|
|
throw "Do not sign assemblies that aren't release."
|
|
|
|
}
|
|
|
|
|
2018-03-12 22:20:48 +03:00
|
|
|
CheckSignTools
|
|
|
|
}
|
2018-03-14 03:47:43 +03:00
|
|
|
|
|
|
|
if ($publish)
|
|
|
|
{
|
|
|
|
CheckPublishTools
|
|
|
|
}
|
2018-08-22 19:52:01 +03:00
|
|
|
|
2020-02-05 02:49:41 +03:00
|
|
|
if ($build)
|
2017-12-05 06:07:13 +03:00
|
|
|
{
|
2019-04-09 03:57:00 +03:00
|
|
|
# We must disable package testing here as the E2E csproj may reference new APIs that are not available in existing NuGet packages.
|
|
|
|
$packageTempPath = $env:AZURE_IOT_LOCALPACKAGES
|
|
|
|
$env:AZURE_IOT_LOCALPACKAGES = ""
|
2018-03-01 04:02:36 +03:00
|
|
|
# SDK binaries
|
2018-08-22 19:52:01 +03:00
|
|
|
BuildProject . "Azure IoT C# SDK Solution"
|
2019-04-09 03:57:00 +03:00
|
|
|
$env:AZURE_IOT_LOCALPACKAGES = $packageTempPath
|
2017-10-04 01:05:06 +03:00
|
|
|
}
|
|
|
|
|
2017-12-05 06:07:13 +03:00
|
|
|
# Unit Tests require InternalsVisibleTo and can only run in Debug builds.
|
2020-02-05 02:49:41 +03:00
|
|
|
if ($unittests)
|
2017-10-04 01:05:06 +03:00
|
|
|
{
|
2020-02-05 02:49:41 +03:00
|
|
|
if ($configuration -ne "Debug")
|
|
|
|
{
|
|
|
|
Write-Host -ForegroundColor Magenta "Unit tests must be run in Debug configuration"
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Write-Host
|
|
|
|
Write-Host -ForegroundColor Cyan "Unit Test execution"
|
|
|
|
Write-Host
|
2017-10-04 01:05:06 +03:00
|
|
|
|
2020-02-06 22:42:55 +03:00
|
|
|
RunTests "Unit tests" -filterTestCategory "TestCategory=Unit" -framework $framework
|
2020-02-05 02:49:41 +03:00
|
|
|
}
|
2017-10-04 01:05:06 +03:00
|
|
|
}
|
2018-03-12 22:20:48 +03:00
|
|
|
|
2020-02-05 02:49:41 +03:00
|
|
|
if ($prtests)
|
2018-03-01 04:02:36 +03:00
|
|
|
{
|
2020-02-05 02:49:41 +03:00
|
|
|
Write-Host
|
|
|
|
Write-Host -ForegroundColor Cyan "PR validation tests"
|
|
|
|
Write-Host
|
|
|
|
|
|
|
|
# Tests categories to include
|
|
|
|
$testCategory = "("
|
|
|
|
$testCategory += "TestCategory=Unit"
|
|
|
|
$testCategory += "|"
|
|
|
|
$testCategory += "TestCategory=E2E"
|
|
|
|
$testCategory += "|"
|
|
|
|
$testCategory += "TestCategory=InvalidServiceCertificate"
|
|
|
|
$testCategory += ")"
|
|
|
|
|
|
|
|
# test categories to exclude
|
|
|
|
$testCategory += "&TestCategory!=LongRunning"
|
|
|
|
$testCategory += "&TestCategory!=FaultInjection"
|
|
|
|
$testCategory += "&TestCategory!=Flaky"
|
|
|
|
|
2020-02-06 22:42:55 +03:00
|
|
|
if ($skipIotHubTests)
|
|
|
|
{
|
|
|
|
$testCategory += "&TestCategory!=IoTHub"
|
|
|
|
}
|
2020-03-11 03:10:26 +03:00
|
|
|
|
2020-02-06 22:42:55 +03:00
|
|
|
if ($skipDPSTests)
|
|
|
|
{
|
|
|
|
$testCategory += "&TestCategory!=DPS"
|
|
|
|
}
|
|
|
|
|
|
|
|
RunTests "PR tests" -filterTestCategory $testCategory -framework $framework
|
2018-03-01 04:02:36 +03:00
|
|
|
}
|
2017-10-04 01:05:06 +03:00
|
|
|
|
2020-02-12 10:21:28 +03:00
|
|
|
if ($package)
|
|
|
|
{
|
|
|
|
BuildPackage shared\src "Shared Assembly"
|
|
|
|
BuildPackage iothub\device\src "IoT Hub DeviceClient SDK"
|
|
|
|
BuildPackage iothub\service\src "IoT Hub ServiceClient SDK"
|
|
|
|
BuildPackage security\tpm\src "SecurityProvider for TPM"
|
|
|
|
BuildPackage provisioning\device\src "Provisioning Device Client SDK"
|
|
|
|
BuildPackage provisioning\transport\amqp\src "Provisioning Transport for AMQP"
|
|
|
|
BuildPackage provisioning\transport\http\src "Provisioning Transport for HTTP"
|
|
|
|
BuildPackage provisioning\transport\mqtt\src "Provisioning Transport for MQTT"
|
|
|
|
BuildPackage provisioning\service\src "Provisioning Service Client SDK"
|
|
|
|
}
|
2020-03-11 03:10:26 +03:00
|
|
|
|
2020-08-15 00:51:39 +03:00
|
|
|
if ($localPackagesAvailableForTesting)
|
2018-03-12 22:20:48 +03:00
|
|
|
{
|
|
|
|
Write-Host
|
|
|
|
Write-Host -ForegroundColor Cyan "Preparing local package source"
|
|
|
|
Write-Host
|
|
|
|
|
|
|
|
if (-not (Test-Path $env:AZURE_IOT_LOCALPACKAGES))
|
|
|
|
{
|
|
|
|
throw "Local NuGet package source path invalid: $($env:AZURE_IOT_LOCALPACKAGES)"
|
|
|
|
}
|
2018-08-22 19:52:01 +03:00
|
|
|
|
2020-07-11 00:02:16 +03:00
|
|
|
Write-Host Following local packages found:
|
|
|
|
Get-ChildItem -Path $env:AZURE_IOT_LOCALPACKAGES
|
2020-02-05 02:49:41 +03:00
|
|
|
}
|
|
|
|
|
2017-10-17 22:49:19 +03:00
|
|
|
if ($e2etests)
|
|
|
|
{
|
|
|
|
Write-Host
|
|
|
|
Write-Host -ForegroundColor Cyan "End-to-end Test execution"
|
|
|
|
Write-Host
|
|
|
|
|
2020-08-15 00:51:39 +03:00
|
|
|
if ($localPackagesAvailableForTesting)
|
2019-04-09 03:57:00 +03:00
|
|
|
{
|
|
|
|
Write-Host -ForegroundColor Magenta "IMPORTANT: Using local packages."
|
|
|
|
}
|
|
|
|
|
2018-03-06 05:40:54 +03:00
|
|
|
# Override verbosity to display individual test execution.
|
|
|
|
$oldVerbosity = $verbosity
|
|
|
|
$verbosity = "normal"
|
2018-03-12 22:20:48 +03:00
|
|
|
|
2020-02-06 22:42:55 +03:00
|
|
|
RunTests "E2E tests" -framework $framework "TestCategory=E2E"
|
2018-03-06 05:40:54 +03:00
|
|
|
|
|
|
|
$verbosity = $oldVerbosity
|
2018-03-12 22:20:48 +03:00
|
|
|
|
|
|
|
# Samples
|
|
|
|
BuildProject security\tpm\samples "SecurityProvider for TPM Samples"
|
2018-03-01 04:02:36 +03:00
|
|
|
}
|
2017-12-21 06:19:23 +03:00
|
|
|
|
2018-03-01 04:02:36 +03:00
|
|
|
if ($stresstests)
|
|
|
|
{
|
|
|
|
Write-Host
|
|
|
|
Write-Host -ForegroundColor Cyan "Stress Test execution"
|
|
|
|
Write-Host
|
|
|
|
|
|
|
|
RunApp e2e\stress\MemoryLeakTest "MemoryLeakTest test"
|
|
|
|
}
|
|
|
|
|
2018-03-14 03:47:43 +03:00
|
|
|
if ($publish)
|
|
|
|
{
|
2020-02-05 02:49:41 +03:00
|
|
|
$files = Get-ChildItem $rootDir\bin\pkg\*.nupkg | Where-Object { -not ($_.Name -match "symbols") }
|
2018-04-05 04:48:21 +03:00
|
|
|
$publishResult = PushNuGet $files
|
|
|
|
|
2020-02-05 02:49:41 +03:00
|
|
|
foreach ( $result in $publishResult)
|
2018-04-05 04:48:21 +03:00
|
|
|
{
|
2020-02-05 02:49:41 +03:00
|
|
|
if ($result.success)
|
2018-04-05 04:48:21 +03:00
|
|
|
{
|
2020-03-11 03:10:26 +03:00
|
|
|
Write-Host -ForegroundColor Green "OK: $($result.file.FullName)"
|
2018-08-22 19:52:01 +03:00
|
|
|
}
|
|
|
|
else
|
2018-04-05 04:48:21 +03:00
|
|
|
{
|
|
|
|
Write-Host -ForegroundColor Red "FAILED: $($result.file.FullName)"
|
|
|
|
}
|
|
|
|
}
|
2018-03-14 03:47:43 +03:00
|
|
|
}
|
|
|
|
|
2017-10-04 01:05:06 +03:00
|
|
|
$buildFailed = $false
|
|
|
|
}
|
2020-02-05 02:49:41 +03:00
|
|
|
catch [Exception]
|
|
|
|
{
|
2017-10-04 01:05:06 +03:00
|
|
|
$buildFailed = $true
|
2018-02-06 02:59:07 +03:00
|
|
|
$errorMessage = $Error[0]
|
2017-10-04 01:05:06 +03:00
|
|
|
}
|
2020-02-05 02:49:41 +03:00
|
|
|
finally
|
|
|
|
{
|
|
|
|
Set-Location $rootDir
|
2017-10-04 01:05:06 +03:00
|
|
|
$endTime = Get-Date
|
|
|
|
}
|
|
|
|
|
2020-02-05 02:49:41 +03:00
|
|
|
Write-Host ("`n`nTime Elapsed {0:c}" -f ($endTime - $startTime))
|
2017-12-05 06:07:13 +03:00
|
|
|
|
2020-02-05 02:49:41 +03:00
|
|
|
if ($buildFailed)
|
|
|
|
{
|
2018-02-06 02:59:07 +03:00
|
|
|
Write-Host -ForegroundColor Red "Build failed ($errorMessage)"
|
2017-12-05 06:07:13 +03:00
|
|
|
exit 1
|
2017-10-04 01:05:06 +03:00
|
|
|
}
|
2020-02-05 02:49:41 +03:00
|
|
|
else
|
|
|
|
{
|
2017-10-04 01:05:06 +03:00
|
|
|
Write-Host -ForegroundColor Green "Build succeeded."
|
2017-12-05 06:07:13 +03:00
|
|
|
exit 0
|
2017-10-04 01:05:06 +03:00
|
|
|
}
|