This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to install the .NET Core SDK
This works on local dev boxes and on Azure Pipeline agents so that the SDK version we need is always installed on-demand.
- Loading branch information
Showing
14 changed files
with
533 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Contributing | ||
|
||
This project has adopted the [Microsoft Open Source Code of | ||
Conduct](https://opensource.microsoft.com/codeofconduct/). | ||
For more information see the [Code of Conduct | ||
FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or | ||
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) | ||
with any additional questions or comments. | ||
|
||
For our general contributing guidelines please see [our dotnet/runtime contributing guide](https://github.com/dotnet/runtime/blob/master/CONTRIBUTING.md). | ||
|
||
## Best practices | ||
|
||
* Use Windows PowerShell or [PowerShell Core][pwsh] (including on Linux/OSX) to run .ps1 scripts. | ||
Some scripts set environment variables to help you, but they are only retained if you use PowerShell as your shell. | ||
|
||
## Prerequisites | ||
|
||
All dependencies can be installed by running the `init.ps1` script at the root of the repository | ||
using Windows PowerShell or [PowerShell Core][pwsh] (on any OS). | ||
|
||
The only prerequisite for building, testing, and deploying from this repository | ||
is the [.NET SDK](https://get.dot.net/). | ||
You should install the version specified in `global.json` or a later version within | ||
the same major.minor.Bxx "hundreds" band. | ||
For example if 2.2.300 is specified, you may install 2.2.300, 2.2.301, or 2.2.310 | ||
while the 2.2.400 version would not be considered compatible by .NET SDK. | ||
See [.NET Core Versioning](https://docs.microsoft.com/en-us/dotnet/core/versions/) for more information. | ||
|
||
The development experience is best with [Visual Studio][VisualStudio]. | ||
|
||
## Building | ||
|
||
This repository can be built on Windows, Linux, and OSX. | ||
|
||
Building, testing, and packing this repository can be done by using the standard dotnet CLI commands (e.g. `dotnet build`, `dotnet test`, `dotnet pack`, etc.). | ||
|
||
[pwsh]: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-6 | ||
[VisualStudio]: https://docs.microsoft.com/dotnet/core/install/sdk?pivots=os-windows#install-with-visual-studio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<# | ||
.SYNOPSIS | ||
Downloads the NuGet.exe tool and returns the path to it. | ||
.PARAMETER NuGetVersion | ||
The version of the NuGet tool to acquire. | ||
#> | ||
Param( | ||
[Parameter()] | ||
[string]$NuGetVersion='5.2.0' | ||
) | ||
|
||
$toolsPath = & "$PSScriptRoot\Get-TempToolsPath.ps1" | ||
$binaryToolsPath = Join-Path $toolsPath $NuGetVersion | ||
if (!(Test-Path $binaryToolsPath)) { $null = mkdir $binaryToolsPath } | ||
$nugetPath = Join-Path $binaryToolsPath nuget.exe | ||
|
||
if (!(Test-Path $nugetPath)) { | ||
Write-Host "Downloading nuget.exe $NuGetVersion..." -ForegroundColor Yellow | ||
(New-Object System.Net.WebClient).DownloadFile("https://dist.nuget.org/win-x86-commandline/v$NuGetVersion/NuGet.exe", $nugetPath) | ||
} | ||
|
||
return (Resolve-Path $nugetPath).Path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<# | ||
.SYNOPSIS | ||
Downloads 32-bit and 64-bit procdump executables and returns the path to where they were installed. | ||
#> | ||
$version = '0.0.1' | ||
$baseDir = "$PSScriptRoot\..\obj\tools" | ||
$procDumpToolPath = "$baseDir\procdump.$version\bin" | ||
if (-not (Test-Path $procDumpToolPath)) { | ||
if (-not (Test-Path $baseDir)) { New-Item -Type Directory -Path $baseDir | Out-Null } | ||
$baseDir = (Resolve-Path $baseDir).Path # Normalize it | ||
& (& $PSScriptRoot\Get-NuGetTool.ps1) install procdump -version $version -PackageSaveMode nuspec -OutputDirectory $baseDir -Source https://api.nuget.org/v3/index.json | Out-Null | ||
} | ||
|
||
(Resolve-Path $procDumpToolPath).Path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
if ($env:AGENT_TEMPDIRECTORY) { | ||
$path = "$env:AGENT_TEMPDIRECTORY\$env:BUILD_BUILDID" | ||
} elseif ($env:localappdata) { | ||
$path = "$env:localappdata\gitrepos\tools" | ||
} else { | ||
$path = "$PSScriptRoot\..\obj\tools" | ||
} | ||
|
||
if (!(Test-Path $path)) { | ||
New-Item -ItemType Directory -Path $Path | Out-Null | ||
} | ||
|
||
(Resolve-Path $path).Path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<# | ||
.SYNOPSIS | ||
Set environment variables in the environment. | ||
Azure Pipeline and CMD environments are considered. | ||
.PARAMETER Variables | ||
A hashtable of variables to be set. | ||
.OUTPUTS | ||
A boolean indicating whether the environment variables can be expected to propagate to the caller's environment. | ||
#> | ||
[CmdletBinding(SupportsShouldProcess=$true)] | ||
Param( | ||
[Parameter(Mandatory=$true, Position=1)] | ||
$Variables, | ||
[string[]]$PrependPath | ||
) | ||
|
||
if ($Variables.Count -eq 0) { | ||
return $true | ||
} | ||
|
||
$cmdInstructions = !$env:TF_BUILD -and !$env:GITHUB_ACTIONS -and $env:PS1UnderCmd -eq '1' | ||
if ($cmdInstructions) { | ||
Write-Warning "Environment variables have been set that will be lost because you're running under cmd.exe" | ||
Write-Host "Environment variables that must be set manually:" -ForegroundColor Blue | ||
} else { | ||
Write-Host "Environment variables set:" -ForegroundColor Blue | ||
Write-Host ($Variables | Out-String) | ||
if ($PrependPath) { | ||
Write-Host "Paths prepended to PATH: $PrependPath" | ||
} | ||
} | ||
|
||
if ($env:TF_BUILD) { | ||
Write-Host "Azure Pipelines detected. Logging commands will be used to propagate environment variables and prepend path." | ||
} | ||
|
||
if ($env:GITHUB_ACTIONS) { | ||
Write-Host "GitHub Actions detected. Logging commands will be used to propagate environment variables and prepend path." | ||
} | ||
|
||
$Variables.GetEnumerator() |% { | ||
Set-Item -Path env:$($_.Key) -Value $_.Value | ||
|
||
# If we're running in a cloud CI, set these environment variables so they propagate. | ||
if ($env:TF_BUILD) { | ||
Write-Host "##vso[task.setvariable variable=$($_.Key);]$($_.Value)" | ||
} | ||
if ($env:GITHUB_ACTIONS) { | ||
Write-Host "::set-env name=$($_.Key)::$($_.Value)" | ||
} | ||
|
||
if ($cmdInstructions) { | ||
Write-Host "SET $($_.Key)=$($_.Value)" | ||
} | ||
} | ||
|
||
$pathDelimiter = ';' | ||
if ($IsMacOS -or $IsLinux) { | ||
$pathDelimiter = ':' | ||
} | ||
|
||
if ($PrependPath) { | ||
$PrependPath |% { | ||
$newPathValue = "$_$pathDelimiter$env:PATH" | ||
Set-Item -Path env:PATH -Value $newPathValue | ||
if ($cmdInstructions) { | ||
Write-Host "SET PATH=$newPathValue" | ||
} | ||
|
||
if ($env:TF_BUILD) { | ||
Write-Host "##vso[task.prependpath]$_" | ||
} | ||
if ($env:GITHUB_ACTIONS) { | ||
Write-Host "::add-path::$_" | ||
} | ||
} | ||
} | ||
|
||
return !$cmdInstructions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
$globalJson = Get-Content -Path "$PSScriptRoot\..\..\global.json" | ConvertFrom-Json | ||
$globalJson.sdk.version |
Oops, something went wrong.