-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Move powershell to .NET Core 2.0 #3556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
45967c4
Update .csproj files, build script and TypeCatalogGen to adopt to net…
daxian-dbw bc09e7e
Update source code to have a successful build
daxian-dbw 62f54c8
Fix Start-PSBuild
daxian-dbw ca3003f
Update dotnet SDK to the latest
daxian-dbw d386e7b
Update the url to obtain dotnet install script
daxian-dbw def5db0
appveyor.yml - remove cache
daxian-dbw 4197508
Crossgen - remove unnecessary dlls for Add-Type
daxian-dbw 4a14a36
Fix Add-Type
daxian-dbw 8db99dc
Fix Get-Process, Start-Sleep and some tests
daxian-dbw db1c54f
Fix build on Linux and some tests
daxian-dbw 8a0d113
Revive 'Microsoft.PowerShell.CoreCLR.AssemblyExtensions' because Pack…
daxian-dbw 068c41f
Update 'build.psm1' and '.travis.yml' to fix Travis CI
daxian-dbw 3fa431d
Update '.travis.yml' to install ruby-2.3.1
daxian-dbw 586bc45
Run 'chmod u+x' on 'echoargs' and 'createchildprocess'
daxian-dbw 1a6a0f5
Update 'Start-Sleep' test
daxian-dbw 7170188
Fix crossgen on Linux/OSX
daxian-dbw 8203f6a
Using SecureString APIs
daxian-dbw a748ad8
Add back cache section and make the cache depend on 'appveyor.yml'
daxian-dbw e00a2b5
Address review comments
daxian-dbw 13dc9c3
Address more review comments
daxian-dbw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -265,15 +265,6 @@ function Start-PSBuild { | |
| } | ||
|
|
||
| ($srcProjectDirs + $testProjectDirs) | % { Start-NativeExecution { dotnet restore $_ $RestoreArguments } } | ||
|
|
||
| # .NET Core's crypto library needs brew's OpenSSL libraries added to its rpath | ||
| if ($IsOSX) { | ||
| # This is the restored library used to build | ||
| # This is allowed to fail since the user may have already restored | ||
| Write-Warning ".NET Core links the incorrect OpenSSL, correcting NuGet package libraries..." | ||
| find $env:HOME/.nuget -name System.Security.Cryptography.Native.OpenSsl.dylib | % { sudo install_name_tool -add_rpath /usr/local/opt/openssl/lib $_ } | ||
| find $env:HOME/.nuget -name System.Net.Http.Native.dylib | % { sudo install_name_tool -change /usr/lib/libcurl.4.dylib /usr/local/opt/curl/lib/libcurl.4.dylib $_ } | ||
| } | ||
| } | ||
|
|
||
| # handle ResGen | ||
|
|
@@ -414,14 +405,15 @@ cmd.exe /C cd /d "$location" "&" "$($vcVarsPath)\vcvarsall.bat" "$NativeHostArch | |
| Start-TypeGen | ||
| } | ||
|
|
||
| # Get the folder path where powershell.exe is located. | ||
| $publishPath = Split-Path $Options.Output -Parent | ||
| try { | ||
| # Relative paths do not work well if cwd is not changed to project | ||
| Push-Location $Options.Top | ||
| log "Run dotnet $Arguments from $pwd" | ||
| Start-NativeExecution { dotnet $Arguments } | ||
|
|
||
| if ($CrossGen) { | ||
| $publishPath = Split-Path $Options.Output | ||
| Start-CrossGen -PublishPath $publishPath -Runtime $script:Options.Runtime | ||
| log "PowerShell.exe with ngen binaries is available at: $($Options.Output)" | ||
| } else { | ||
|
|
@@ -431,13 +423,32 @@ cmd.exe /C cd /d "$location" "&" "$($vcVarsPath)\vcvarsall.bat" "$NativeHostArch | |
| Pop-Location | ||
| } | ||
|
|
||
| # add 'x' permission when building the standalone application | ||
| # this is temporary workaround to a bug in dotnet.exe, tracking by dotnet/cli issue #6286 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's a pretty hilarious bug |
||
| if ($Options.Configuration -eq "Linux" -and $Options.Publish) { | ||
| chmod u+x $Options.Output | ||
| } | ||
|
|
||
| # publish netcoreapp2.0 reference assemblies | ||
| try { | ||
| Push-Location "$PSScriptRoot/src/TypeCatalogGen" | ||
| $refAssemblies = Get-Content -Path "powershell.inc" | ? { $_ -like "*microsoft.netcore.app*" } | % { $_.TrimEnd(';') } | ||
| $refDestFolder = Join-Path -Path $publishPath -ChildPath "ref" | ||
|
|
||
| if (Test-Path $refDestFolder -PathType Container) { | ||
| Remove-Item $refDestFolder -Force -Recurse -ErrorAction Stop | ||
| } | ||
| New-Item -Path $refDestFolder -ItemType Directory -Force -ErrorAction Stop > $null | ||
| Copy-Item -Path $refAssemblies -Destination $refDestFolder -Force -ErrorAction Stop | ||
| } finally { | ||
| Pop-Location | ||
| } | ||
|
|
||
| # download modules from powershell gallery. | ||
| # - PowerShellGet, PackageManagement, Microsoft.PowerShell.Archive | ||
| if($PSModuleRestore) | ||
| { | ||
| $ProgressPreference = "SilentlyContinue" | ||
| # Downloading the PowerShellGet and PackageManagement modules. | ||
| # $Options.Output is pointing to something like "...\src\powershell-win-core\bin\Debug\netcoreapp1.1\win10-x64\publish\powershell.exe", | ||
| # so we need to get its parent directory | ||
| $publishPath = Split-Path $Options.Output -Parent | ||
| log "Restore PowerShell modules to $publishPath" | ||
|
|
||
| $modulesDir = Join-Path -Path $publishPath -ChildPath "Modules" | ||
|
|
@@ -474,7 +485,7 @@ function New-PSOptions { | |
| [ValidateSet("Linux", "Debug", "Release", "CodeCoverage", "")] | ||
| [string]$Configuration, | ||
|
|
||
| [ValidateSet("netcoreapp1.1", "net451")] | ||
| [ValidateSet("netcoreapp2.0", "net451")] | ||
| [string]$Framework, | ||
|
|
||
| # These are duplicated from Start-PSBuild | ||
|
|
@@ -561,7 +572,7 @@ function New-PSOptions { | |
| $Framework = if ($FullCLR) { | ||
| "net451" | ||
| } else { | ||
| "netcoreapp1.1" | ||
| "netcoreapp2.0" | ||
| } | ||
| Write-Verbose "Using framework '$Framework'" | ||
| } | ||
|
|
@@ -694,7 +705,7 @@ function Publish-PSTestTools { | |
|
|
||
| Find-Dotnet | ||
|
|
||
| $tools = "$PSScriptRoot/test/tools/EchoArgs","$PSScriptRoot/test/tools/CreateChildProcess" | ||
| $tools = @("$PSScriptRoot/test/tools/EchoArgs", "echoargs"), @("$PSScriptRoot/test/tools/CreateChildProcess", "createchildprocess") | ||
| if ($Options -eq $null) | ||
| { | ||
| $Options = New-PSOptions | ||
|
|
@@ -703,9 +714,16 @@ function Publish-PSTestTools { | |
| # Publish EchoArgs so it can be run by tests | ||
| foreach ($tool in $tools) | ||
| { | ||
| Push-Location $tool | ||
| Push-Location $tool[0] | ||
| try { | ||
| dotnet publish --output bin --configuration $Options.Configuration --framework $Options.Framework --runtime $Options.Runtime | ||
|
|
||
| # add 'x' permission when building the standalone application | ||
| # this is temporary workaround to a bug in dotnet.exe, tracking by dotnet/cli issue #6286 | ||
| if ($Options.Configuration -eq "Linux") { | ||
| $executable = Join-Path -Path $tool[0] -ChildPath "bin/$($tool[1])" | ||
| chmod u+x $executable | ||
| } | ||
| } finally { | ||
| Pop-Location | ||
| } | ||
|
|
@@ -972,16 +990,16 @@ function Start-PSxUnit { | |
| function Install-Dotnet { | ||
| [CmdletBinding()] | ||
| param( | ||
| [string]$Channel, | ||
| [string]$Version, | ||
| [string]$Channel = "preview", | ||
| [string]$Version = "2.0.0-preview1-005724", | ||
| [switch]$NoSudo | ||
| ) | ||
|
|
||
| # This allows sudo install to be optional; needed when running in containers / as root | ||
| # Note that when it is null, Invoke-Expression (but not &) must be used to interpolate properly | ||
| $sudo = if (!$NoSudo) { "sudo" } | ||
|
|
||
| $obtainUrl = "https://raw.githubusercontent.com/dotnet/cli/v1.0.1/scripts/obtain" | ||
| $obtainUrl = "https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain" | ||
|
|
||
| # Install for Linux and OS X | ||
| if ($IsLinux -or $IsOSX) { | ||
|
|
@@ -1007,14 +1025,6 @@ function Install-Dotnet { | |
| curl -sO $obtainUrl/$installScript | ||
| bash ./$installScript -c $Channel -v $Version | ||
| } | ||
|
|
||
| # .NET Core's crypto library needs brew's OpenSSL libraries added to its rpath | ||
| if ($IsOSX) { | ||
| # This is the library shipped with .NET Core | ||
| # This is allowed to fail as the user may have installed other versions of dotnet | ||
| Write-Warning ".NET Core links the incorrect OpenSSL, correcting .NET CLI libraries..." | ||
| find $env:HOME/.dotnet -name System.Security.Cryptography.Native.OpenSsl.dylib | % { sudo install_name_tool -add_rpath /usr/local/opt/openssl/lib $_ } | ||
| } | ||
| } elseif ($IsWindows) { | ||
| Remove-Item -ErrorAction SilentlyContinue -Recurse -Force ~\AppData\Local\Microsoft\dotnet | ||
| $installScript = "dotnet-install.ps1" | ||
|
|
@@ -1040,11 +1050,10 @@ function Start-PSBootstrap { | |
| SupportsShouldProcess=$true, | ||
| ConfirmImpact="High")] | ||
| param( | ||
| [string]$Channel = "rel-1.0.0", | ||
| # we currently pin dotnet-cli version, because tool | ||
| # is currently migrating to msbuild toolchain | ||
| # and requires constant updates to our build process. | ||
| [string]$Version = "1.0.1", | ||
| [string]$Channel = "preview", | ||
| # we currently pin dotnet-cli version, and will | ||
| # update it when more stable version comes out. | ||
| [string]$Version = "2.0.0-preview1-005724", | ||
| [switch]$Package, | ||
| [switch]$NoSudo, | ||
| [switch]$Force | ||
|
|
@@ -1250,7 +1259,7 @@ function Start-PSPackage { | |
| -not $Script:Options.CrossGen -or ## Last build didn't specify -CrossGen | ||
| $Script:Options.Runtime -ne $Runtime -or ## Last build wasn't for the required RID | ||
| $Script:Options.Configuration -ne $Configuration -or ## Last build was with configuration other than 'Release' | ||
| $Script:Options.Framework -ne "netcoreapp1.1") ## Last build wasn't for CoreCLR | ||
| $Script:Options.Framework -ne "netcoreapp2.0") ## Last build wasn't for CoreCLR | ||
| { | ||
| # It's possible that the most recent build doesn't satisfy the package requirement but | ||
| # an earlier build does. e.g., run the following in order on win10-x64: | ||
|
|
@@ -2048,11 +2057,11 @@ function Start-TypeGen | |
| $GetDependenciesTargetValue = @' | ||
| <Project> | ||
| <Target Name="_GetDependencies" | ||
| DependsOnTargets="ResolvePackageDependenciesDesignTime"> | ||
| DependsOnTargets="ResolveAssemblyReferencesDesignTime"> | ||
| <ItemGroup> | ||
| <_DependentAssemblyPath Include="%(_DependenciesDesignTime.Path)%3B" Condition=" '%(_DependenciesDesignTime.Type)' == 'Assembly' And '%(_DependenciesDesignTime.Name)' != 'Microsoft.Management.Infrastructure.Native.dll' And '%(_DependenciesDesignTime.Name)' != 'Microsoft.Management.Infrastructure.dll' " /> | ||
| <_RefAssemblyPath Include="%(_ReferencesFromRAR.ResolvedPath)%3B" Condition=" '%(_ReferencesFromRAR.Type)' == 'assembly' And '%(_ReferencesFromRAR.PackageName)' != 'Microsoft.Management.Infrastructure' " /> | ||
| </ItemGroup> | ||
| <WriteLinesToFile File="$(_DependencyFile)" Lines="@(_DependentAssemblyPath)" Overwrite="true" /> | ||
| <WriteLinesToFile File="$(_DependencyFile)" Lines="@(_RefAssemblyPath)" Overwrite="true" /> | ||
| </Target> | ||
| </Project> | ||
| '@ | ||
|
|
@@ -2771,19 +2780,9 @@ function Start-CrossGen { | |
| "win7-x64" | ||
| } | ||
| } elseif ($IsLinux) { | ||
| if ($IsUbuntu) { | ||
| "ubuntu.14.04-x64" | ||
| } elseif ($IsCentOS) { | ||
| "rhel.7-x64" | ||
| } elseif ($IsFedora) { | ||
| "fedora.24-x64" | ||
| } elseif ($IsOpenSUSE13) { | ||
| "opensuse.13.2-x64" | ||
| } elseif (${IsOpenSUSE42.1}) { | ||
| "opensuse.42.1-x64" | ||
| } | ||
| "linux-x64" | ||
| } elseif ($IsOSX) { | ||
| "osx.10.10-x64" | ||
| "osx.10.12-x64" | ||
| } | ||
|
|
||
| if (-not $crossGenRuntime) { | ||
|
|
@@ -2827,8 +2826,6 @@ function Start-CrossGen { | |
| $commonAssembliesForAddType = @( | ||
| "Microsoft.CodeAnalysis.CSharp.dll" | ||
| "Microsoft.CodeAnalysis.dll" | ||
| "Microsoft.CodeAnalysis.VisualBasic.dll" | ||
| "Microsoft.CSharp.dll" | ||
| ) | ||
|
|
||
| # Common PowerShell libraries to crossgen | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be '005724' ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
005724is the build ofdotnet-cliwe are currently using, but thenetcoreappversion is actually2.0.0-preview1-001913-00.