Skip to content

Commit

Permalink
Merge remote-tracking branch 'libtemplate/main' into libtemplateUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
AArnott committed Mar 12, 2023
2 parents 9eeee78 + 54bd19a commit efa8bbb
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 37 deletions.
1 change: 0 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.CodeFix.Testing.XUnit" Version="1.1.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces" version="$(MicrosoftCodeAnalysisVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="$(MicrosoftCodeAnalysisVersion)" />
<PackageVersion Include="Microsoft.CodeCoverage" Version="17.5.0" />
<PackageVersion Include="Microsoft.NET.StringTools" Version="17.4.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageVersion Include="Microsoft.NETCore.Portable.Compatibility" Version="1.0.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeCoverage" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Nerdbank.Streams" />
<PackageReference Include="xunit" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeCoverage" />
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Nerdbank.Streams" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeCoverage" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" />
Expand Down
84 changes: 51 additions & 33 deletions tools/Install-DotNetSdk.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<#
.SYNOPSIS
Installs the .NET SDK specified in the global.json file at the root of this repository,
along with supporting .NET Core runtimes used for testing.
along with supporting .NET runtimes used for testing.
.DESCRIPTION
This MAY not require elevation, as the SDK and runtimes are installed locally to this repo location,
unless `-InstallLocality machine` is specified.
Expand All @@ -15,14 +15,20 @@
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 SdkOnly
Skips installing the runtime.
.PARAMETER IncludeX86
Installs a x86 SDK and runtimes in addition to the x64 ones. Only supported on Windows. Ignored on others.
.PARAMETER IncludeAspNetCore
Installs the ASP.NET Core runtime along with the .NET runtime.
#>
[CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='Medium')]
Param (
[ValidateSet('repo','user','machine')]
[string]$InstallLocality='user',
[switch]$IncludeX86
[switch]$SdkOnly,
[switch]$IncludeX86,
[switch]$IncludeAspNetCore=$true
)

$DotNetInstallScriptRoot = "$PSScriptRoot/../obj/tools"
Expand All @@ -45,40 +51,46 @@ if (!$arch) { # Windows Powershell leaves this blank
if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { $arch = 'ARM64' }
}

# Search for all .NET Core runtime versions referenced from MSBuild projects and arrange to install them.
# Search for all .NET runtime versions referenced from MSBuild projects and arrange to install them.
$runtimeVersions = @()
$windowsDesktopRuntimeVersions = @()
$aspnetRuntimeVersions = @()
Get-ChildItem "$PSScriptRoot\..\src\*.*proj","$PSScriptRoot\..\tests\*.*proj","$PSScriptRoot\..\Directory.Build.props" -Recurse |% {
$projXml = [xml](Get-Content -Path $_)
$pg = $projXml.Project.PropertyGroup
if ($pg) {
$targetFrameworks = @()
$tf = $pg.TargetFramework
$targetFrameworks += $tf
$tfs = $pg.TargetFrameworks
if ($tfs) {
$targetFrameworks = $tfs -Split ';'
if (!$SdkOnly) {
Get-ChildItem "$PSScriptRoot\..\src\*.*proj","$PSScriptRoot\..\tests\*.*proj","$PSScriptRoot\..\Directory.Build.props" -Recurse |% {
$projXml = [xml](Get-Content -Path $_)
$pg = $projXml.Project.PropertyGroup
if ($pg) {
$targetFrameworks = @()
$tf = $pg.TargetFramework
$targetFrameworks += $tf
$tfs = $pg.TargetFrameworks
if ($tfs) {
$targetFrameworks = $tfs -Split ';'
}
}
}
$targetFrameworks |? { $_ -match 'net(?:coreapp)?(\d+\.\d+)' } |% {
$v = $Matches[1]
$runtimeVersions += $v
$aspnetRuntimeVersions += $v
if ($v -ge '3.0' -and -not ($IsMacOS -or $IsLinux)) {
$windowsDesktopRuntimeVersions += $v
$targetFrameworks |? { $_ -match 'net(?:coreapp)?(\d+\.\d+)' } |% {
$v = $Matches[1]
$runtimeVersions += $v
$aspnetRuntimeVersions += $v
if ($v -ge '3.0' -and -not ($IsMacOS -or $IsLinux)) {
$windowsDesktopRuntimeVersions += $v
}
}
}

# Add target frameworks of the form: netXX
$targetFrameworks |? { $_ -match 'net(\d+\.\d+)' } |% {
$v = $Matches[1]
$runtimeVersions += $v
$aspnetRuntimeVersions += $v
if (-not ($IsMacOS -or $IsLinux)) {
$windowsDesktopRuntimeVersions += $v
# Add target frameworks of the form: netXX
$targetFrameworks |? { $_ -match 'net(\d+\.\d+)' } |% {
$v = $Matches[1]
$runtimeVersions += $v
$aspnetRuntimeVersions += $v
if (-not ($IsMacOS -or $IsLinux)) {
$windowsDesktopRuntimeVersions += $v
}
}
}
}
}

if (!$IncludeAspNetCore) {
$aspnetRuntimeVersions = @()
}

if (!$IncludeAspNetCore) {
Expand All @@ -101,18 +113,24 @@ Function Get-FileFromWeb([Uri]$Uri, $OutDir) {
}

Function Get-InstallerExe(
[Version]$Version,
$Version,
$Architecture,
[ValidateSet('Sdk','Runtime','WindowsDesktop')]
[string]$sku
) {
# Get the latest/actual version for the specified one
if ($Version.Build -eq -1) {
$TypedVersion = $null
if (![Version]::TryParse($Version, [ref] $TypedVersion)) {
Write-Error "Unable to parse $Version into an a.b.c.d version. This version cannot be installed machine-wide."
exit 1
}

if ($TypedVersion.Build -eq -1) {
$versionInfo = -Split (Invoke-WebRequest -Uri "https://dotnetcli.blob.core.windows.net/dotnet/$sku/$Version/latest.version" -UseBasicParsing)
$Version = $versionInfo[-1]
}

$majorMinor = "$($Version.Major).$($Version.Minor)"
$majorMinor = "$($TypedVersion.Major).$($TypedVersion.Minor)"
$ReleasesFile = Join-Path $DotNetInstallScriptRoot "$majorMinor\releases.json"
if (!(Test-Path $ReleasesFile)) {
Get-FileFromWeb -Uri "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/$majorMinor/releases.json" -OutDir (Split-Path $ReleasesFile) | Out-Null
Expand Down Expand Up @@ -205,7 +223,7 @@ if ($InstallLocality -eq 'machine') {
}

$aspnetRuntimeVersions | Sort-Object | Get-Unique |% {
if ($PSCmdlet.ShouldProcess(".NET Windows Desktop $_", "Install")) {
if ($PSCmdlet.ShouldProcess("ASP.NET Core $_", "Install")) {
Install-DotNet -Version $_ -sku AspNetCore -Architecture $arch
$restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010)

Expand Down

0 comments on commit efa8bbb

Please sign in to comment.