Update install JDK script an instructions to make it easier to use for local development (#10306)
This commit is contained in:
parent
147880f796
commit
194b0b4523
|
|
@ -121,7 +121,7 @@ jobs:
|
||||||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
|
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
|
||||||
TeamName: AspNetCore
|
TeamName: AspNetCore
|
||||||
${{ if and(eq(parameters.installJdk, 'true'), eq(parameters.agentOs, 'Windows')) }}:
|
${{ if and(eq(parameters.installJdk, 'true'), eq(parameters.agentOs, 'Windows')) }}:
|
||||||
JAVA_HOME: $(Agent.BuildDirectory)\.tools\jdk
|
JAVA_HOME: $(Agent.BuildDirectory)\.tools\jdk\win-x64
|
||||||
${{ if or(ne(parameters.codeSign, true), ne(variables['System.TeamProject'], 'internal')) }}:
|
${{ if or(ne(parameters.codeSign, true), ne(variables['System.TeamProject'], 'internal')) }}:
|
||||||
_SignType: ''
|
_SignType: ''
|
||||||
${{ if and(eq(parameters.codeSign, true), eq(variables['System.TeamProject'], 'internal')) }}:
|
${{ if and(eq(parameters.codeSign, true), eq(variables['System.TeamProject'], 'internal')) }}:
|
||||||
|
|
@ -146,10 +146,7 @@ jobs:
|
||||||
command: custom
|
command: custom
|
||||||
arguments: 'locals all -clear'
|
arguments: 'locals all -clear'
|
||||||
- ${{ if and(eq(parameters.installJdk, 'true'), eq(parameters.agentOs, 'Windows')) }}:
|
- ${{ if and(eq(parameters.installJdk, 'true'), eq(parameters.agentOs, 'Windows')) }}:
|
||||||
- powershell: |
|
- powershell: ./eng/scripts/InstallJdk.ps1
|
||||||
./eng/scripts/InstallJdk.ps1 '11.0.1'
|
|
||||||
Write-Host "##vso[task.prependpath]$env:JAVA_HOME\bin"
|
|
||||||
|
|
||||||
displayName: Install JDK 11
|
displayName: Install JDK 11
|
||||||
- ${{ if eq(parameters.isTestingJob, true) }}:
|
- ${{ if eq(parameters.isTestingJob, true) }}:
|
||||||
- powershell: |
|
- powershell: |
|
||||||
|
|
|
||||||
10
build.ps1
10
build.ps1
|
|
@ -306,7 +306,13 @@ $MSBuildArguments += "/p:TargetOsName=win"
|
||||||
if (($All -or $BuildJava) -and -not $NoBuildJava) {
|
if (($All -or $BuildJava) -and -not $NoBuildJava) {
|
||||||
$foundJdk = $false
|
$foundJdk = $false
|
||||||
$javac = Get-Command javac -ErrorAction Ignore -CommandType Application
|
$javac = Get-Command javac -ErrorAction Ignore -CommandType Application
|
||||||
if ($env:JAVA_HOME) {
|
$localJdkPath = "$PSScriptRoot\.tools\jdk\win-x64\"
|
||||||
|
if (Test-Path "$localJdkPath\bin\javac.exe") {
|
||||||
|
$foundJdk = $true
|
||||||
|
Write-Host -f Magenta "Detected JDK in $localJdkPath (via local repo convention)"
|
||||||
|
$env:JAVA_HOME = $localJdkPath
|
||||||
|
}
|
||||||
|
elseif ($env:JAVA_HOME) {
|
||||||
if (-not (Test-Path "${env:JAVA_HOME}\bin\javac.exe")) {
|
if (-not (Test-Path "${env:JAVA_HOME}\bin\javac.exe")) {
|
||||||
Write-Error "The environment variable JAVA_HOME was set, but ${env:JAVA_HOME}\bin\javac.exe does not exist. Remove JAVA_HOME or update it to the correct location for the JDK. See https://www.bing.com/search?q=java_home for details."
|
Write-Error "The environment variable JAVA_HOME was set, but ${env:JAVA_HOME}\bin\javac.exe does not exist. Remove JAVA_HOME or update it to the correct location for the JDK. See https://www.bing.com/search?q=java_home for details."
|
||||||
}
|
}
|
||||||
|
|
@ -337,7 +343,7 @@ if (($All -or $BuildJava) -and -not $NoBuildJava) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-not $foundJdk) {
|
if (-not $foundJdk) {
|
||||||
Write-Error "Could not find the JDK. See $PSScriptRoot\docs\BuildFromSource.md for details on this requirement."
|
Write-Error "Could not find the JDK. Either run $PSScriptRoot\eng\scripts\InstallJdk.ps1 to install for this repo, or install the JDK globally on your machine (see $PSScriptRoot\docs\BuildFromSource.md for details)."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,10 @@ Building ASP.NET Core on Windows requires:
|
||||||
* Java Development Kit 11 or newer. Either:
|
* Java Development Kit 11 or newer. Either:
|
||||||
* OpenJDK <https://jdk.java.net/>
|
* OpenJDK <https://jdk.java.net/>
|
||||||
* Oracle's JDK <https://www.oracle.com/technetwork/java/javase/downloads/index.html>
|
* Oracle's JDK <https://www.oracle.com/technetwork/java/javase/downloads/index.html>
|
||||||
|
* To install a version of the JDK that will only be used by this repo, run [eng/scripts/InstallJdk.ps1](/eng/scripts/InstallJdk.ps1)
|
||||||
|
```ps1
|
||||||
|
PS> ./eng/scripts/InstalLJdk.ps1
|
||||||
|
```
|
||||||
|
|
||||||
### macOS/Linux
|
### macOS/Linux
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
Installs SQL Server 2016 Express LocalDB on a machine.
|
Installs SQL Server 2016 Express LocalDB on a machine.
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This script installs Microsoft SQL Server 2016 Express LocalDB on a machine.
|
This script installs Microsoft SQL Server 2016 Express LocalDB on a machine.
|
||||||
|
.PARAMETER Force
|
||||||
|
Force the script to run the MSI, even it it appears LocalDB is installed.
|
||||||
.LINK
|
.LINK
|
||||||
https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/sql-server-2016-express-localdb?view=sql-server-2016
|
https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/sql-server-2016-express-localdb?view=sql-server-2016
|
||||||
https://docs.microsoft.com/en-us/sql/database-engine/install-windows/install-sql-server-from-the-command-prompt?view=sql-server-2016
|
https://docs.microsoft.com/en-us/sql/database-engine/install-windows/install-sql-server-from-the-command-prompt?view=sql-server-2016
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,52 @@
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Installs JDK into a folder in this repo.
|
||||||
|
.DESCRIPTION
|
||||||
|
This script downloads an extracts the JDK.
|
||||||
|
.PARAMETER JdkVersion
|
||||||
|
The version of the JDK to install. If not set, the default value is read from global.json
|
||||||
|
.PARAMETER Force
|
||||||
|
Overwrite the existing installation
|
||||||
|
#>
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory = $true)]
|
[string]$JdkVersion,
|
||||||
$JdkVersion
|
[switch]$Force
|
||||||
)
|
)
|
||||||
|
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
$ProgressPreference = 'SilentlyContinue' # Workaround PowerShell/PowerShell#2138
|
$ProgressPreference = 'SilentlyContinue' # Workaround PowerShell/PowerShell#2138
|
||||||
|
|
||||||
Set-StrictMode -Version 1
|
Set-StrictMode -Version 1
|
||||||
|
|
||||||
if (-not $env:JAVA_HOME) {
|
$repoRoot = Resolve-Path "$PSScriptRoot\..\.."
|
||||||
throw 'You must set the JAVA_HOME environment variable to the destination of the JDK.'
|
$installDir = "$repoRoot\.tools\jdk\win-x64\"
|
||||||
|
$tempDir = "$repoRoot\obj"
|
||||||
|
if (-not $JdkVersion) {
|
||||||
|
$globalJson = Get-Content "$repoRoot\global.json" | ConvertFrom-Json
|
||||||
|
$JdkVersion = $globalJson.tools.jdk
|
||||||
}
|
}
|
||||||
|
|
||||||
$repoRoot = Resolve-Path "$PSScriptRoot/../.."
|
if (Test-Path $installDir) {
|
||||||
$tempDir = "$repoRoot/obj"
|
if ($Force) {
|
||||||
|
Remove-Item -Force -Recurse $installDir
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Host "The JDK already installed to $installDir. Exiting without action. Call this script again with -Force to overwrite."
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Remove-Item -Force -Recurse $tempDir -ErrorAction Ignore | out-null
|
||||||
mkdir $tempDir -ea Ignore | out-null
|
mkdir $tempDir -ea Ignore | out-null
|
||||||
|
mkdir $installDir -ea Ignore | out-null
|
||||||
Write-Host "Starting download of JDK ${JdkVersion}"
|
Write-Host "Starting download of JDK ${JdkVersion}"
|
||||||
Invoke-WebRequest -UseBasicParsing -Uri "https://netcorenativeassets.blob.core.windows.net/resource-packages/external/windows/java/jdk-${JdkVersion}_windows-x64_bin.zip" -Out "$tempDir/jdk.zip"
|
Invoke-WebRequest -UseBasicParsing -Uri "https://netcorenativeassets.blob.core.windows.net/resource-packages/external/windows/java/jdk-${JdkVersion}_windows-x64_bin.zip" -Out "$tempDir/jdk.zip"
|
||||||
Write-Host "Done downloading JDK ${JdkVersion}"
|
Write-Host "Done downloading JDK ${JdkVersion}"
|
||||||
Expand-Archive "$tempDir/jdk.zip" -d "$tempDir/jdk/"
|
Expand-Archive "$tempDir/jdk.zip" -d "$tempDir/jdk/"
|
||||||
Write-Host "Expanded JDK to $tempDir"
|
Write-Host "Expanded JDK to $tempDir"
|
||||||
mkdir (split-path -parent $env:JAVA_HOME) -ea ignore | out-null
|
Write-Host "Installing JDK to $installDir"
|
||||||
Write-Host "Installing JDK to $env:JAVA_HOME"
|
Move-Item "$tempDir/jdk/jdk-${JdkVersion}/*" $installDir
|
||||||
Move-Item "$tempDir/jdk/jdk-${jdkVersion}" $env:JAVA_HOME
|
Write-Host "Done installing JDK to $installDir"
|
||||||
Write-Host "Done installing JDK to $env:JAVA_HOME"
|
|
||||||
|
if ($env:TF_BUILD) {
|
||||||
|
Write-Host "##vso[task.prependpath]$installDir\bin"
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,9 @@
|
||||||
"sdk": {
|
"sdk": {
|
||||||
"version": "3.0.100-preview5-011568"
|
"version": "3.0.100-preview5-011568"
|
||||||
},
|
},
|
||||||
|
"tools": {
|
||||||
|
"jdk": "11.0.3"
|
||||||
|
},
|
||||||
"msbuild-sdks": {
|
"msbuild-sdks": {
|
||||||
"Yarn.MSBuild": "1.15.2",
|
"Yarn.MSBuild": "1.15.2",
|
||||||
"Microsoft.DotNet.Helix.Sdk": "2.0.0-beta.19262.1"
|
"Microsoft.DotNet.Helix.Sdk": "2.0.0-beta.19262.1"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue