Skip to content

Solve some portability issues with PS Core 6.x on MacOSX#198

Merged
rkeithhill merged 2 commits intopsake:masterfrom
dbroeglin:master
Jul 10, 2017
Merged

Solve some portability issues with PS Core 6.x on MacOSX#198
rkeithhill merged 2 commits intopsake:masterfrom
dbroeglin:master

Conversation

@dbroeglin
Copy link
Copy Markdown
Contributor

This should solve #197. The solution I came up with in the end was to simply check for the presence and value of $IsWindows:

if (!(Get-Variable -Name IsWindows -ErrorAction SilentlyContinue) -and !$IsWindows)

This variable should be present in PS Core and set to $True on windows. So if that variable is not present or if it is true we detect frameworks. If not this part is simply ignored.

The rest of the changes are only aliases that I had to replace with their full cmdlet names because they do not exist under MacOSX or Linux.

@johannesprinz
Copy link
Copy Markdown

Ohh ace! Was about to make the changes myself. Although you can get away with a little less change. As well as there's a bunch more aliases contained as detailed by PSScriptAnalyzer.

{($_ -eq '4.6') -or ($_ -eq '4.6.1')} {
$versions = @('v4.0.30319')
$buildToolsVersions = @('14.0')
if (!(Get-Variable -Name IsWindows -ErrorAction SilentlyContinue) -or $IsWindows) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if it wouldn't be better to create some new functions: ConfigureWindowsBuildEnvironment(), ConfigureLinuxBuildEnvironment() and ConfigureMacOSBuildEnvironment().

Then have your if test call the Windows one, then add a test for $IsLinux and call the Linux one (ditto for $IsOSX). For now, those functions could just write-warning that "build environment support for this platform has not been implemented yet.".

@rkeithhill
Copy link
Copy Markdown
Contributor

Last call for comments on this PR. If there are none then I'll merge this PR in a few days. With .NET Core 2.0 on the cusp of being finalized, it is time to get serious about supporting psake cross-platform.

Copy link
Copy Markdown
Contributor

@rkeithhill rkeithhill left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants