Merge remote-tracking branch 'libtemplate/microbuild' into dev/andarno/libtemplateUpdate
This commit is contained in:
Коммит
4f2e88b4f1
|
@ -0,0 +1,9 @@
|
|||
# Please see the documentation for all configuration options:
|
||||
# https://eng.ms/docs/products/dependabot/configuration/version_updates
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: nuget
|
||||
directory: /
|
||||
schedule:
|
||||
interval: monthly
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"powershell": {
|
||||
"version": "7.3.4",
|
||||
"commands": [
|
||||
"pwsh"
|
||||
]
|
||||
},
|
||||
"dotnet-format": {
|
||||
"version": "5.1.250801",
|
||||
"commands": [
|
||||
"dotnet-format"
|
||||
]
|
||||
},
|
||||
"dotnet-coverage": {
|
||||
"version": "17.7.1",
|
||||
"commands": [
|
||||
"dotnet-coverage"
|
||||
]
|
||||
},
|
||||
"nbgv": {
|
||||
"version": "3.6.133",
|
||||
"commands": [
|
||||
"nbgv"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -176,5 +176,8 @@ dotnet_diagnostic.DOC108.severity = warning
|
|||
dotnet_diagnostic.DOC200.severity = warning
|
||||
dotnet_diagnostic.DOC202.severity = warning
|
||||
|
||||
# CA1062: Validate arguments of public methods
|
||||
dotnet_diagnostic.CA1062.severity = warning
|
||||
|
||||
[*.sln]
|
||||
indent_style = tab
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# Please see the documentation for all configuration options:
|
||||
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: nuget
|
||||
directory: /
|
||||
schedule:
|
||||
interval: monthly
|
||||
interval: weekly
|
||||
|
|
|
@ -4,21 +4,20 @@
|
|||
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
||||
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
|
||||
|
||||
<MicroBuildVersion>2.0.113</MicroBuildVersion>
|
||||
<MicroBuildVersion>2.0.125</MicroBuildVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageVersion Include="Microsoft.CodeCoverage" Version="17.5.0" />
|
||||
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
|
||||
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.6.2" />
|
||||
<PackageVersion Include="Microsoft.VisualStudio.Internal.MicroBuild.NonShipping" Version="$(MicroBuildVersion)" />
|
||||
<PackageVersion Include="Moq" Version="4.18.4" />
|
||||
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.5" />
|
||||
<PackageVersion Include="xunit" Version="2.4.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<GlobalPackageReference Include="CSharpIsNullAnalyzer" Version="0.1.329" />
|
||||
<GlobalPackageReference Include="CSharpIsNullAnalyzer" Version="0.1.495" />
|
||||
<GlobalPackageReference Include="DotNetAnalyzers.DocumentationAnalyzers" Version="1.0.0-beta.59" />
|
||||
<GlobalPackageReference Include="Microsoft.VisualStudio.Internal.MicroBuild.VisualStudio" Version="$(MicroBuildVersion)" />
|
||||
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.5.119" />
|
||||
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.6.133" />
|
||||
<GlobalPackageReference Include="Nullable" Version="1.3.1" />
|
||||
<GlobalPackageReference Include="StyleCop.Analyzers.Unstable" Version="1.2.0.435" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -24,7 +24,6 @@ parameters:
|
|||
default: true
|
||||
|
||||
variables:
|
||||
MSBuildTreatWarningsAsErrors: true
|
||||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
|
||||
BuildConfiguration: Release
|
||||
codecov_token: 1c079a51-729f-4e18-9792-2a75f2e074e0
|
||||
|
|
|
@ -135,7 +135,7 @@ if (!$Requester) {
|
|||
$Requester = $env:USERNAME
|
||||
}
|
||||
if (!$Requester) {
|
||||
Write-Error "Unable to determine default value for -Requester."
|
||||
$Requester = $OwnerAlias
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ if (!$RepoUrl) {
|
|||
}
|
||||
|
||||
Push-Location $PSScriptRoot
|
||||
$versionsObj = & (& "$PSScriptRoot/Get-nbgv.ps1") get-version -f json | ConvertFrom-Json
|
||||
$versionsObj = dotnet tool run nbgv get-version -f json | ConvertFrom-Json
|
||||
Pop-Location
|
||||
|
||||
$ReleaseDateString = $ReleaseDate.ToShortDateString()
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Gets the path to the nbgv CLI tool, installing it if necessary.
|
||||
#>
|
||||
Param(
|
||||
)
|
||||
|
||||
$existingTool = Get-Command "nbgv" -ErrorAction SilentlyContinue
|
||||
if ($existingTool) {
|
||||
return $existingTool.Path
|
||||
}
|
||||
|
||||
$toolInstallDir = & "$PSScriptRoot/Get-TempToolsPath.ps1"
|
||||
|
||||
$toolPath = "$toolInstallDir/nbgv"
|
||||
if (!(Test-Path $toolInstallDir)) { New-Item -Path $toolInstallDir -ItemType Directory | Out-Null }
|
||||
|
||||
if (!(Get-Command $toolPath -ErrorAction SilentlyContinue)) {
|
||||
Write-Host "Installing nbgv to $toolInstallDir"
|
||||
dotnet tool install --tool-path "$toolInstallDir" nbgv --configfile "$PSScriptRoot/justnugetorg.nuget.config" | Out-Null
|
||||
}
|
||||
|
||||
# Normalize the path on the way out.
|
||||
return (Get-Command $toolPath).Path
|
|
@ -20,32 +20,32 @@ Param(
|
|||
)
|
||||
|
||||
$RepoRoot = [string](Resolve-Path $PSScriptRoot/..)
|
||||
Push-Location $RepoRoot
|
||||
try {
|
||||
Write-Verbose "Searching $Path for *.cobertura.xml files"
|
||||
$reports = Get-ChildItem -Recurse $Path -Filter *.cobertura.xml
|
||||
|
||||
if (!(Test-Path $RepoRoot/obj/dotnet-coverage*)) {
|
||||
dotnet tool install --tool-path $RepoRoot/obj dotnet-coverage --version 17.4.3 --configfile $PSScriptRoot/justnugetorg.nuget.config
|
||||
}
|
||||
if ($reports) {
|
||||
$reports |% { $_.FullName } |% {
|
||||
# In addition to replacing {reporoot}, we also normalize on one kind of slash so that the report aggregates data for a file whether data was collected on Windows or not.
|
||||
$xml = [xml](Get-Content -Path $_)
|
||||
$xml.coverage.packages.package.classes.class |? { $_.filename} |% {
|
||||
$_.filename = $_.filename.Replace('{reporoot}', $RepoRoot).Replace([IO.Path]::AltDirectorySeparatorChar, [IO.Path]::DirectorySeparatorChar)
|
||||
}
|
||||
|
||||
Write-Verbose "Searching $Path for *.cobertura.xml files"
|
||||
$reports = Get-ChildItem -Recurse $Path -Filter *.cobertura.xml
|
||||
|
||||
if ($reports) {
|
||||
$reports |% { $_.FullName } |% {
|
||||
# In addition to replacing {reporoot}, we also normalize on one kind of slash so that the report aggregates data for a file whether data was collected on Windows or not.
|
||||
$xml = [xml](Get-Content -Path $_)
|
||||
$xml.coverage.packages.package.classes.class |? { $_.filename} |% {
|
||||
$_.filename = $_.filename.Replace('{reporoot}', $RepoRoot).Replace([IO.Path]::AltDirectorySeparatorChar, [IO.Path]::DirectorySeparatorChar)
|
||||
$xml.Save($_)
|
||||
}
|
||||
|
||||
$xml.Save($_)
|
||||
$Inputs = $reports |% { Resolve-Path -relative $_.FullName }
|
||||
|
||||
if ((Split-Path $OutputFile) -and -not (Test-Path (Split-Path $OutputFile))) {
|
||||
New-Item -Type Directory -Path (Split-Path $OutputFile) | Out-Null
|
||||
}
|
||||
|
||||
& dotnet tool run dotnet-coverage merge $Inputs -o $OutputFile -f cobertura
|
||||
} else {
|
||||
Write-Error "No reports found to merge."
|
||||
}
|
||||
|
||||
$Inputs = $reports |% { Resolve-Path -relative $_.FullName }
|
||||
|
||||
if ((Split-Path $OutputFile) -and -not (Test-Path (Split-Path $OutputFile))) {
|
||||
New-Item -Type Directory -Path (Split-Path $OutputFile) | Out-Null
|
||||
}
|
||||
|
||||
& "$RepoRoot/obj/dotnet-coverage" merge $Inputs -o $OutputFile -f cobertura
|
||||
} else {
|
||||
Write-Error "No reports found to merge."
|
||||
} finally {
|
||||
Pop-Location
|
||||
}
|
||||
|
|
|
@ -34,6 +34,12 @@ steps:
|
|||
fetchDepth: 0
|
||||
- powershell: tools/Install-DotNetSdk.ps1
|
||||
displayName: ⚙ Install .NET SDK
|
||||
- task: NuGetAuthenticate@1
|
||||
displayName: 🔏 Authenticate NuGet feeds
|
||||
inputs:
|
||||
forceReinstallCredentialProvider: true
|
||||
- script: dotnet tool restore
|
||||
displayName: ⚙️ Restore CLI tools
|
||||
- powershell: azure-pipelines/variables/_pipelines.ps1
|
||||
failOnStderr: true
|
||||
displayName: ⚙ Set pipeline variables based on source
|
||||
|
|
|
@ -32,7 +32,7 @@ jobs:
|
|||
|
||||
- template: install-dependencies.yml
|
||||
|
||||
- powershell: '& (./azure-pipelines/Get-nbgv.ps1) cloud -ca'
|
||||
- script: dotnet tool run nbgv cloud -ca
|
||||
displayName: ⚙ Set build number
|
||||
|
||||
- ${{ if eq(variables['system.collectionId'], '011b8bdf-6d56-4f87-be0d-0092136884d9') }}:
|
||||
|
|
|
@ -3,7 +3,7 @@ parameters:
|
|||
|
||||
steps:
|
||||
|
||||
- script: dotnet build -t:build,pack --no-restore -c $(BuildConfiguration) /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog"
|
||||
- script: dotnet build -t:build,pack --no-restore -c $(BuildConfiguration) -warnaserror /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog"
|
||||
displayName: 🛠 dotnet build
|
||||
|
||||
- powershell: azure-pipelines/dotnet-test-cloud.ps1 -Configuration $(BuildConfiguration) -Agent $(Agent.JobName) -PublishResults
|
||||
|
|
|
@ -9,7 +9,7 @@ steps:
|
|||
outputformat: text
|
||||
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
|
||||
|
||||
- task: MicroBuildSigningPlugin@3
|
||||
- task: MicroBuildSigningPlugin@4
|
||||
inputs:
|
||||
signType: $(SignType)
|
||||
zipSources: false
|
||||
|
|
|
@ -50,7 +50,6 @@ stages:
|
|||
|
||||
- stage: Build
|
||||
variables:
|
||||
MSBuildTreatWarningsAsErrors: true
|
||||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
|
||||
BuildConfiguration: Release
|
||||
NUGET_PACKAGES: $(Agent.TempDirectory)/.nuget/packages
|
||||
|
|
|
@ -1,36 +1,41 @@
|
|||
stages:
|
||||
- stage: symbol_archive
|
||||
displayName: Symbol archival
|
||||
condition: and(succeeded(), eq(dependencies.Build.outputs['Windows.SetPipelineVariables.SignType'], 'Real'))
|
||||
jobs:
|
||||
- job: archive
|
||||
pool: VSEng-ReleasePool-1ES
|
||||
steps:
|
||||
- checkout: none
|
||||
- download: current
|
||||
artifact: Variables-Windows
|
||||
displayName: 🔻 Download Variables-Windows artifact
|
||||
- powershell: $(Pipeline.Workspace)/Variables-Windows/_pipelines.ps1
|
||||
displayName: ⚙️ Set pipeline variables based on artifacts
|
||||
- download: current
|
||||
artifact: symbols-legacy
|
||||
displayName: 🔻 Download symbols-legacy artifact
|
||||
- task: MicroBuildArchiveSymbols@1
|
||||
displayName: 🔣 Archive symbols to Symweb
|
||||
inputs:
|
||||
SymbolsFeatureName: $(SymbolsFeatureName)
|
||||
SymbolsSymwebProject: VS
|
||||
SymbolsUncPath: \\cpvsbuild\drops\$(TeamName)\$(Build.DefinitionName)\$(Build.SourceBranchName)\$(Build.BuildId)\Symbols.Archival
|
||||
SymbolsEmailContacts: vsidemicrobuild
|
||||
SymbolsAgentPath: $(Pipeline.Workspace)/symbols-legacy
|
||||
- task: MicroBuildCleanup@1
|
||||
displayName: ☎️ Send Telemetry
|
||||
parameters:
|
||||
- name: ArchiveSymbols
|
||||
type: boolean
|
||||
default: true
|
||||
|
||||
- stage: azure_public_vssdk_feed
|
||||
displayName: azure-public/vssdk feed
|
||||
stages:
|
||||
- stage: release
|
||||
displayName: Publish
|
||||
condition: and(succeeded(), eq(dependencies.Build.outputs['Windows.SetPipelineVariables.SignType'], 'Real'))
|
||||
jobs:
|
||||
- ${{ if parameters.ArchiveSymbols }}:
|
||||
- job: symbol_archive
|
||||
displayName: Archive symbols
|
||||
pool: VSEngSS-MicroBuild2022-1ES
|
||||
steps:
|
||||
- checkout: none
|
||||
- download: current
|
||||
artifact: Variables-Windows
|
||||
displayName: 🔻 Download Variables-Windows artifact
|
||||
- powershell: $(Pipeline.Workspace)/Variables-Windows/_pipelines.ps1
|
||||
displayName: ⚙️ Set pipeline variables based on artifacts
|
||||
- download: current
|
||||
artifact: symbols-legacy
|
||||
displayName: 🔻 Download symbols-legacy artifact
|
||||
- task: MicroBuildArchiveSymbols@4
|
||||
displayName: 🔣 Archive symbols to Symweb
|
||||
inputs:
|
||||
SymbolsFeatureName: $(SymbolsFeatureName)
|
||||
SymbolsProject: VS
|
||||
SymbolsAgentPath: $(Pipeline.Workspace)/symbols-legacy
|
||||
azureSubscription: Symbols Upload (DevDiv)
|
||||
- task: MicroBuildCleanup@1
|
||||
displayName: ☎️ Send Telemetry
|
||||
|
||||
- job: push
|
||||
displayName: azure-public/vssdk feed
|
||||
${{ if parameters.ArchiveSymbols }}:
|
||||
dependsOn: symbol_archive
|
||||
pool:
|
||||
name: AzurePipelines-EO
|
||||
vmImage: AzurePipelinesUbuntu20.04compliant
|
||||
|
|
|
@ -16,24 +16,26 @@ steps:
|
|||
targetArgument: $(System.DefaultWorkingDirectory)
|
||||
optionsUEPATH: $(System.DefaultWorkingDirectory)\azure-pipelines\PoliCheckExclusions.xml
|
||||
|
||||
- task: BinSkim@4
|
||||
displayName: 🔍 Run BinSkim
|
||||
inputs:
|
||||
InputType: Basic
|
||||
Function: analyze
|
||||
TargetPattern: guardianGlob
|
||||
AnalyzeTargetGlob: $(BinSkimTargets)
|
||||
|
||||
- task: CopyFiles@2
|
||||
displayName: 🔍 Collect APIScan inputs
|
||||
displayName: 📂 Collect APIScan/BinSkim inputs
|
||||
inputs:
|
||||
SourceFolder: $(Build.ArtifactStagingDirectory)/Symbols-$(Agent.JobName)
|
||||
# Exclude any patterns from the Contents (e.g. `!**/git2*`) that we have symbols for but do not need to run APIScan on.
|
||||
Contents: |
|
||||
**
|
||||
!**/arm64/**
|
||||
!**/win-arm64/**
|
||||
!**/linux-*/**
|
||||
!**/osx*/**
|
||||
TargetFolder: $(Build.ArtifactStagingDirectory)/APIScanInputs
|
||||
condition: and(succeeded(), ${{ parameters.EnableAPIScan }}, ne(variables.ApiScanClientId, ''))
|
||||
|
||||
- task: BinSkim@4
|
||||
displayName: 🔍 Run BinSkim
|
||||
inputs:
|
||||
InputType: Basic
|
||||
Function: analyze
|
||||
TargetPattern: guardianGlob
|
||||
AnalyzeTargetGlob: $(Build.ArtifactStagingDirectory)/APIScanInputs/**/*.dll;$(Build.ArtifactStagingDirectory)/APIScanInputs/**/*.exe
|
||||
|
||||
- task: APIScan@2
|
||||
displayName: 🔍 Run APIScan
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
$Path = "$PSScriptRoot\..\..\bin"
|
||||
if (Test-Path $Path) {
|
||||
[string]::join(';', (& "$PSScriptRoot\..\Get-SymbolFiles.ps1" -Path $Path))
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
$nbgv = & "$PSScriptRoot\..\Get-nbgv.ps1"
|
||||
$MacroName = 'MicrosoftVisualStudioValidationVersion'
|
||||
$SampleProject = "$PSScriptRoot\..\..\src\Microsoft.VisualStudio.Validation"
|
||||
[string]::join(',',(@{
|
||||
('MicrosoftVisualStudioValidationVersion') = & { (& $nbgv get-version --project "$PSScriptRoot\..\..\src\Microsoft.VisualStudio.Validation" --format json | ConvertFrom-Json).AssemblyVersion };
|
||||
($MacroName) = & { (dotnet tool run nbgv -- get-version --project $SampleProject --format json | ConvertFrom-Json).AssemblyVersion };
|
||||
}.GetEnumerator() |% { "$($_.key)=$($_.value)" }))
|
||||
|
|
|
@ -24,6 +24,8 @@ stages:
|
|||
RunTests: false
|
||||
|
||||
- template: prepare-insertion-stages.yml
|
||||
parameters:
|
||||
ArchiveSymbols: false
|
||||
|
||||
- stage: insertion
|
||||
displayName: VS insertion
|
||||
|
@ -60,7 +62,7 @@ stages:
|
|||
inputs:
|
||||
TeamName: $(TeamName)
|
||||
TeamEmail: $(TeamEmail)
|
||||
InsertionPayloadName: $(Build.Repository.Name) VALIDATION BUILD $(Build.BuildNumber) ($(Build.SourceBranch))
|
||||
InsertionPayloadName: $(Build.Repository.Name) VALIDATION BUILD $(Build.BuildNumber) ($(Build.SourceBranch)) [Skip-SymbolCheck]
|
||||
InsertionDescription: |
|
||||
This PR is for **validation purposes only** for !$(System.PullRequest.PullRequestId). **Do not complete**.
|
||||
CustomScriptExecutionCommand: src/VSSDK/NuGet/AllowUnstablePackages.ps1
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"sdk": {
|
||||
"version": "7.0.101",
|
||||
"version": "7.0.302",
|
||||
"rollForward": "patch",
|
||||
"allowPrerelease": false
|
||||
}
|
||||
|
|
23
init.ps1
23
init.ps1
|
@ -28,6 +28,8 @@
|
|||
No effect if -NoPrerequisites is specified.
|
||||
.PARAMETER NoRestore
|
||||
Skips the package restore step.
|
||||
.PARAMETER NoToolRestore
|
||||
Skips the dotnet tool restore step.
|
||||
.PARAMETER Signing
|
||||
Install the MicroBuild signing plugin for building test-signed builds on desktop machines.
|
||||
.PARAMETER Localization
|
||||
|
@ -55,6 +57,8 @@ Param (
|
|||
[Parameter()]
|
||||
[switch]$NoRestore,
|
||||
[Parameter()]
|
||||
[switch]$NoToolRestore,
|
||||
[Parameter()]
|
||||
[switch]$Signing,
|
||||
[Parameter()]
|
||||
[switch]$Localization,
|
||||
|
@ -94,13 +98,13 @@ Push-Location $PSScriptRoot
|
|||
try {
|
||||
$HeaderColor = 'Green'
|
||||
|
||||
if (!$NoRestore -and $PSCmdlet.ShouldProcess("NuGet packages", "Restore")) {
|
||||
$RestoreArguments = @()
|
||||
if ($Interactive)
|
||||
{
|
||||
$RestoreArguments += '--interactive'
|
||||
}
|
||||
$RestoreArguments = @()
|
||||
if ($Interactive)
|
||||
{
|
||||
$RestoreArguments += '--interactive'
|
||||
}
|
||||
|
||||
if (!$NoRestore -and $PSCmdlet.ShouldProcess("NuGet packages", "Restore")) {
|
||||
Write-Host "Restoring NuGet packages" -ForegroundColor $HeaderColor
|
||||
dotnet restore @RestoreArguments
|
||||
if ($lastexitcode -ne 0) {
|
||||
|
@ -108,6 +112,13 @@ try {
|
|||
}
|
||||
}
|
||||
|
||||
if (!$NoToolRestore -and $PSCmdlet.ShouldProcess("dotnet tool", "restore")) {
|
||||
dotnet tool restore @RestoreArguments
|
||||
if ($lastexitcode -ne 0) {
|
||||
throw "Failure while restoring dotnet CLI tools."
|
||||
}
|
||||
}
|
||||
|
||||
$InstallNuGetPkgScriptPath = "$PSScriptRoot\azure-pipelines\Install-NuGetPackage.ps1"
|
||||
$nugetVerbosity = 'quiet'
|
||||
if ($Verbose) { $nugetVerbosity = 'normal' }
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
<TargetFrameworks>net472;net6.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeCoverage" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" />
|
||||
<PackageReference Include="Moq" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" />
|
||||
|
|
|
@ -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.
|
||||
|
@ -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
|
||||
)
|
||||
|
||||
$DotNetInstallScriptRoot = "$PSScriptRoot/../obj/tools"
|
||||
|
@ -41,39 +47,49 @@ $arch = [System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture
|
|||
if (!$arch) { # Windows Powershell leaves this blank
|
||||
$arch = 'x64'
|
||||
if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { $arch = 'ARM64' }
|
||||
if (${env:ProgramFiles(Arm)}) { $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 = @()
|
||||
Get-ChildItem "$PSScriptRoot\..\src\*.*proj","$PSScriptRoot\..\test\*.*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 ';'
|
||||
$aspnetRuntimeVersions = @()
|
||||
if (!$SdkOnly) {
|
||||
Get-ChildItem "$PSScriptRoot\..\src\*.*proj","$PSScriptRoot\..\test\*.*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
|
||||
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
|
||||
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 = @()
|
||||
}
|
||||
|
||||
Function Get-FileFromWeb([Uri]$Uri, $OutDir) {
|
||||
|
@ -92,18 +108,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
|
||||
|
@ -116,6 +138,14 @@ Function Get-InstallerExe(
|
|||
if ($release.$sku.version -eq $Version) {
|
||||
$filesElement = $release.$sku.files
|
||||
}
|
||||
if (!$filesElement -and ($sku -eq 'sdk') -and $release.sdks) {
|
||||
foreach ($sdk in $release.sdks) {
|
||||
if ($sdk.version -eq $Version) {
|
||||
$filesElement = $sdk.files
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($filesElement) {
|
||||
foreach ($file in $filesElement) {
|
||||
|
@ -134,14 +164,14 @@ Function Get-InstallerExe(
|
|||
if ($url) {
|
||||
Get-FileFromWeb -Uri $url -OutDir $DotNetInstallScriptRoot
|
||||
} else {
|
||||
Write-Error "Unable to find release of $sku v$Version"
|
||||
throw "Unable to find release of $sku v$Version"
|
||||
}
|
||||
}
|
||||
|
||||
Function Install-DotNet($Version, $Architecture, [ValidateSet('Sdk','Runtime','WindowsDesktop')][string]$sku = 'Sdk') {
|
||||
Write-Host "Downloading .NET Core $sku $Version..."
|
||||
Function Install-DotNet($Version, $Architecture, [ValidateSet('Sdk','Runtime','WindowsDesktop','AspNetCore')][string]$sku = 'Sdk') {
|
||||
Write-Host "Downloading .NET $sku $Version..."
|
||||
$Installer = Get-InstallerExe -Version $Version -Architecture $Architecture -sku $sku
|
||||
Write-Host "Installing .NET Core $sku $Version..."
|
||||
Write-Host "Installing .NET $sku $Version..."
|
||||
cmd /c start /wait $Installer /install /passive /norestart
|
||||
if ($LASTEXITCODE -eq 3010) {
|
||||
Write-Verbose "Restart required"
|
||||
|
@ -195,6 +225,17 @@ if ($InstallLocality -eq 'machine') {
|
|||
}
|
||||
}
|
||||
|
||||
$aspnetRuntimeVersions | Sort-Object | Get-Unique |% {
|
||||
if ($PSCmdlet.ShouldProcess("ASP.NET Core $_", "Install")) {
|
||||
Install-DotNet -Version $_ -sku AspNetCore -Architecture $arch
|
||||
$restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010)
|
||||
|
||||
if ($IncludeX86) {
|
||||
Install-DotNet -Version $_ -sku AspNetCore -Architecture x86
|
||||
$restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($restartRequired) {
|
||||
Write-Host -ForegroundColor Yellow "System restart required"
|
||||
Exit 3010
|
||||
|
@ -233,10 +274,10 @@ if ($IncludeX86) {
|
|||
}
|
||||
|
||||
if ($IsMacOS -or $IsLinux) {
|
||||
$DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/781752509a890ca7520f1182e8bae71f9a53d754/src/dotnet-install.sh"
|
||||
$DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/0b09de9bc136cacb5f849a6957ebd4062173c148/src/dotnet-install.sh"
|
||||
$DotNetInstallScriptPath = "$DotNetInstallScriptRoot/dotnet-install.sh"
|
||||
} else {
|
||||
$DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/781752509a890ca7520f1182e8bae71f9a53d754/src/dotnet-install.ps1"
|
||||
$DownloadUri = "https://raw.githubusercontent.com/dotnet/install-scripts/0b09de9bc136cacb5f849a6957ebd4062173c148/src/dotnet-install.ps1"
|
||||
$DotNetInstallScriptPath = "$DotNetInstallScriptRoot/dotnet-install.ps1"
|
||||
}
|
||||
|
||||
|
@ -284,7 +325,7 @@ if ($IncludeX86) {
|
|||
$dotnetRuntimeSwitches = $switches + '-Runtime','dotnet'
|
||||
|
||||
$runtimeVersions | Sort-Object -Unique |% {
|
||||
if ($PSCmdlet.ShouldProcess(".NET Core $Arch runtime $_", "Install")) {
|
||||
if ($PSCmdlet.ShouldProcess(".NET $Arch runtime $_", "Install")) {
|
||||
$anythingInstalled = $true
|
||||
Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ -Architecture $arch -InstallDir $DotNetInstallDir $dotnetRuntimeSwitches"
|
||||
|
||||
|
@ -297,7 +338,7 @@ $runtimeVersions | Sort-Object -Unique |% {
|
|||
}
|
||||
|
||||
if ($IncludeX86) {
|
||||
if ($PSCmdlet.ShouldProcess(".NET Core x86 runtime $_", "Install")) {
|
||||
if ($PSCmdlet.ShouldProcess(".NET x86 runtime $_", "Install")) {
|
||||
$anythingInstalled = $true
|
||||
Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ -Architecture x86 -InstallDir $DotNetX86InstallDir $dotnetRuntimeSwitches"
|
||||
|
||||
|
@ -314,7 +355,7 @@ $runtimeVersions | Sort-Object -Unique |% {
|
|||
$windowsDesktopRuntimeSwitches = $switches + '-Runtime','windowsdesktop'
|
||||
|
||||
$windowsDesktopRuntimeVersions | Sort-Object -Unique |% {
|
||||
if ($PSCmdlet.ShouldProcess(".NET Core WindowsDesktop $arch runtime $_", "Install")) {
|
||||
if ($PSCmdlet.ShouldProcess(".NET WindowsDesktop $arch runtime $_", "Install")) {
|
||||
$anythingInstalled = $true
|
||||
Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ -Architecture $arch -InstallDir $DotNetInstallDir $windowsDesktopRuntimeSwitches"
|
||||
|
||||
|
@ -327,7 +368,7 @@ $windowsDesktopRuntimeVersions | Sort-Object -Unique |% {
|
|||
}
|
||||
|
||||
if ($IncludeX86) {
|
||||
if ($PSCmdlet.ShouldProcess(".NET Core WindowsDesktop x86 runtime $_", "Install")) {
|
||||
if ($PSCmdlet.ShouldProcess(".NET WindowsDesktop x86 runtime $_", "Install")) {
|
||||
$anythingInstalled = $true
|
||||
Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ -Architecture x86 -InstallDir $DotNetX86InstallDir $windowsDesktopRuntimeSwitches"
|
||||
|
||||
|
@ -341,10 +382,40 @@ $windowsDesktopRuntimeVersions | Sort-Object -Unique |% {
|
|||
}
|
||||
}
|
||||
|
||||
$aspnetRuntimeSwitches = $switches + '-Runtime','aspnetcore'
|
||||
|
||||
$aspnetRuntimeVersions | Sort-Object -Unique |% {
|
||||
if ($PSCmdlet.ShouldProcess(".NET ASP.NET Core $arch runtime $_", "Install")) {
|
||||
$anythingInstalled = $true
|
||||
Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ -Architecture $arch -InstallDir $DotNetInstallDir $aspnetRuntimeSwitches"
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Error ".NET SDK installation failure: $LASTEXITCODE"
|
||||
exit $LASTEXITCODE
|
||||
}
|
||||
} else {
|
||||
Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ -Architecture $arch -InstallDir $DotNetInstallDir $aspnetRuntimeSwitches -DryRun"
|
||||
}
|
||||
|
||||
if ($IncludeX86) {
|
||||
if ($PSCmdlet.ShouldProcess(".NET ASP.NET Core x86 runtime $_", "Install")) {
|
||||
$anythingInstalled = $true
|
||||
Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ -Architecture x86 -InstallDir $DotNetX86InstallDir $aspnetRuntimeSwitches"
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Error ".NET SDK installation failure: $LASTEXITCODE"
|
||||
exit $LASTEXITCODE
|
||||
}
|
||||
} else {
|
||||
Invoke-Expression -Command "$DotNetInstallScriptPathExpression -Channel $_ -Architecture x86 -InstallDir $DotNetX86InstallDir $aspnetRuntimeSwitches -DryRun"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($PSCmdlet.ShouldProcess("Set DOTNET environment variables to discover these installed runtimes?")) {
|
||||
& "$PSScriptRoot/Set-EnvVars.ps1" -Variables $envVars -PrependPath $DotNetInstallDir | Out-Null
|
||||
}
|
||||
|
||||
if ($anythingInstalled -and ($InstallLocality -ne 'machine') -and !$env:TF_BUILD -and !$env:GITHUB_ACTIONS) {
|
||||
Write-Warning ".NET Core runtimes or SDKs were installed to a non-machine location. Perform your builds or open Visual Studio from this same environment in order for tools to discover the location of these dependencies."
|
||||
Write-Warning ".NET runtimes or SDKs were installed to a non-machine location. Perform your builds or open Visual Studio from this same environment in order for tools to discover the location of these dependencies."
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче