Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$script:TestModulePathSeparator = [System.IO.Path]::PathSeparator

$dotnetCLIChannel = "release"
$dotnetCLIRequiredVersion = "2.0.2"
$dotnetCLIRequiredVersion = $(Get-Content $PSScriptRoot/global.json | ConvertFrom-Json).Sdk.Version
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we stop if global.json does not contain Sdk version?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be highly unusual for global.json to be missing that field since that's about its only purpose.


# Track if tags have been sync'ed
$tagsUpToDate = $false
Expand Down Expand Up @@ -600,7 +600,7 @@ function New-PSOptions {
[string]$Output,

[switch]$SMAOnly,

[switch]$PSModuleRestore
)

Expand Down Expand Up @@ -1685,13 +1685,23 @@ function Start-ResGen

function Find-Dotnet() {
$originalPath = $env:PATH
$dotnetPath = if ($Environment.IsWindows) {
"$env:LocalAppData\Microsoft\dotnet"
} else {
"$env:HOME/.dotnet"
}
$dotnetPath = if ($Environment.IsWindows) { "$env:LocalAppData\Microsoft\dotnet" } else { "$env:HOME/.dotnet" }

if (-not (precheck 'dotnet' "Could not find 'dotnet', appending $dotnetPath to PATH.")) {
# If there dotnet is already in the PATH, check to see if that version of dotnet can find the required SDK
# This is "typically" the globally installed dotnet
if (precheck dotnet) {
# Must run from within repo to ensure global.json can specify the required SDK version
Push-Location $PSScriptRoot
$dotnetCLIInstalledVersion = (dotnet --version)
Pop-Location
if ($dotnetCLIInstalledVersion -ne $dotnetCLIRequiredVersion) {
Write-Warning "The 'dotnet' in the current path can't find SDK version ${dotnetCLIRequiredVersion}, prepending $dotnetPath to PATH."
# Globally installed dotnet doesn't have the required SDK version, prepend the user local dotnet location
$env:PATH = $dotnetPath + [IO.Path]::PathSeparator + $env:PATH
}
}
else {
Write-Warning "Could not find 'dotnet', appending $dotnetPath to PATH."
$env:PATH += [IO.Path]::PathSeparator + $dotnetPath
}

Expand Down