Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/aspnet/MessagePack-CSharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2019-11-20 01:28:05 +0300
committerAndrew Arnott <andrewarnott@gmail.com>2019-11-20 01:59:07 +0300
commita81989f414b53f6ce91e169aa909643f0487a465 (patch)
tree59ffde5794c2685c42e4bc5b54c33d7602e1e308 /init.ps1
parent9a8bb438be9369dc4bbd85344c50e9c4a443a8c2 (diff)
Reduce number of build tasks
This moves some of the logic from YML to ps1 scripts where it can be reproduced locally and therefore is more diagnosable and maintainable. It also adds an init script to the repo root which installs whatever .NET Core SDK and runtimes are required to build and run tests in this repo.
Diffstat (limited to 'init.ps1')
-rw-r--r--init.ps161
1 files changed, 61 insertions, 0 deletions
diff --git a/init.ps1 b/init.ps1
new file mode 100644
index 00000000..256c5fb1
--- /dev/null
+++ b/init.ps1
@@ -0,0 +1,61 @@
+<#
+.SYNOPSIS
+Installs dependencies required to build and test the projects in this repository.
+.DESCRIPTION
+This MAY not require elevation, as the SDK and runtimes are installed locally to this repo location,
+unless `-InstallLocality machine` is specified.
+.PARAMETER InstallLocality
+A value indicating whether dependencies should be installed locally to the repo or at a per-user location.
+Per-user allows sharing the installed dependencies across repositories and allows use of a shared expanded package cache.
+Visual Studio will only notice and use these SDKs/runtimes if VS is launched from the environment that runs this script.
+Per-repo allows for high isolation, allowing for a more precise recreation of the environment within an Azure Pipelines build.
+When using 'repo', environment variables are set to cause the locally installed dotnet SDK to be used.
+Per-repo can lead to file locking issues when dotnet.exe is left running as a build server and can be mitigated by running `dotnet build-server shutdown`.
+Per-machine requires elevation and will download and install all SDKs and runtimes to machine-wide locations so all applications can find it.
+.PARAMETER NoPrerequisites
+Skips the installation of prerequisite software (e.g. SDKs, tools).
+.PARAMETER NoRestore
+Skips the package restore step.
+.PARAMETER AccessToken
+An optional access token for authenticating to Azure Artifacts authenticated feeds.
+#>
+[CmdletBinding(SupportsShouldProcess=$true)]
+Param (
+ [ValidateSet('repo','user','machine')]
+ [string]$InstallLocality='user',
+ [Parameter()]
+ [switch]$NoPrerequisites,
+ [Parameter()]
+ [switch]$NoRestore,
+ [Parameter()]
+ [string]$AccessToken
+)
+
+if (!$NoPrerequisites) {
+ & "$PSScriptRoot\tools\Install-NuGetCredProvider.ps1" -AccessToken $AccessToken
+ & "$PSScriptRoot\tools\Install-DotNetSdk.ps1" -InstallLocality $InstallLocality
+}
+
+# Workaround nuget credential provider bug that causes very unreliable package restores on Azure Pipelines
+$env:NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS=20
+$env:NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS=20
+
+Push-Location $PSScriptRoot
+try {
+ $HeaderColor = 'Green'
+
+ if (!$NoRestore) {
+ Write-Host "Restoring NuGet packages" -ForegroundColor $HeaderColor
+ dotnet restore
+ if ($lastexitcode -ne 0) {
+ throw "Failure while restoring packages."
+ }
+ }
+}
+catch {
+ Write-Error $error[0]
+ exit $lastexitcode
+}
+finally {
+ Pop-Location
+}