Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ os:
- osx
sudo: required
dist: trusty
osx_image: xcode7.3
osx_image: xcode8.1

matrix:
fast_finish: true
Expand All @@ -25,7 +25,7 @@ install:
- popd
# Default 2.0.0 Ruby is buggy
# Default bundler version is buggy
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then rvm use 2.3.1; gem uninstall bundler -v1.13.1; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then rvm install ruby-2.3.1; rvm use 2.3.1; fi
# spellcheck
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
nvm install 6.4.0 &&
Expand Down
5 changes: 3 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ version: 6.0.0-alpha.18-{build}

image: Visual Studio 2015

# cache version - netcoreapp.2.0.0-preview1-001913-00
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should it be '005724' ?

Copy link
Member Author

Choose a reason for hiding this comment

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

005724 is the build of dotnet-cli we are currently using, but the netcoreapp version is actually 2.0.0-preview1-001913-00.

cache:
- '%LocalAppData%\Microsoft\dotnet'
- '%HOMEDRIVE%%HOMEPATH%\.nuget\packages'
- '%LocalAppData%\Microsoft\dotnet -> appveyor.yml'
- '%HOMEDRIVE%%HOMEPATH%\.nuget\packages -> appveyor.yml'

nuget:
project_feed: true
Expand Down
101 changes: 49 additions & 52 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The 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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -561,7 +572,7 @@ function New-PSOptions {
$Framework = if ($FullCLR) {
"net451"
} else {
"netcoreapp1.1"
"netcoreapp2.0"
}
Write-Verbose "Using framework '$Framework'"
}
Expand Down Expand Up @@ -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
Expand All @@ -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
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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>
'@
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<VersionPrefix>6.0.0</VersionPrefix>
<TargetFramework>netstandard1.6</TargetFramework>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DelaySign>true</DelaySign>
<AssemblyName>Microsoft.Management.Infrastructure.CimCmdlets</AssemblyName>
Expand All @@ -16,7 +16,7 @@
<ProjectReference Include="..\System.Management.Automation\System.Management.Automation.csproj" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
<PropertyGroup>
<DefineConstants>$(DefineConstants);CORECLR</DefineConstants>
<DebugType>portable</DebugType>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

#if CORECLR
using System.ComponentModel;
using Microsoft.PowerShell.CoreClr.Stubs;

namespace System.Diagnostics
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<VersionPrefix>6.0.0</VersionPrefix>
<TargetFramework>netstandard1.6</TargetFramework>
<TargetFramework>netcoreapp2.0</TargetFramework>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DelaySign>true</DelaySign>
Expand All @@ -19,11 +19,11 @@
<ProjectReference Include="..\System.Management.Automation\System.Management.Automation.csproj" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
<PropertyGroup>
<DefineConstants>$(DefineConstants);CORECLR</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
<ItemGroup>
<Compile Remove="GetEventSnapin.cs" />
<Compile Remove="gen\GetEventResources.cs" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<VersionPrefix>6.0.0</VersionPrefix>
<TargetFramework>netstandard1.6</TargetFramework>
<TargetFramework>netcoreapp2.0</TargetFramework>
<NoWarn>$(NoWarn);CS1570</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand All @@ -20,11 +20,11 @@
<ProjectReference Include="..\Microsoft.PowerShell.Security\Microsoft.PowerShell.Security.csproj" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
<PropertyGroup>
<DefineConstants>$(DefineConstants);CORECLR</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
<ItemGroup>
<Compile Remove="commands\management\ClearRecycleBinCommand.cs" />
<Compile Remove="commands\management\ControlPanelItemCommand.cs" />
<Compile Remove="commands\management\CommitTransactionCommand.cs" />
Expand Down Expand Up @@ -77,10 +77,8 @@
<DebugType>full</DebugType>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
<PackageReference Include="System.ServiceProcess.ServiceController" Version="4.3.0" />
<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />
<PackageReference Include="System.Net.Ping" Version="4.3.0" />
<ItemGroup>
<PackageReference Include="System.ServiceProcess.ServiceController" Version="4.4.0-preview1-25204-02" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
using Microsoft.Management.Infrastructure;
using Dbg = System.Management.Automation.Diagnostics;

#if CORECLR
// Use stubs for SerializableAttribute, SystemException and ISerializable related types.
using Microsoft.PowerShell.CoreClr.Stubs;
#endif

namespace Microsoft.PowerShell.Cmdletization.Cim
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@
using Microsoft.PowerShell.Cim;
using Dbg = System.Management.Automation.Diagnostics;

#if CORECLR
// Some APIs are missing from System.Environment. We use System.Management.Automation.Environment as a proxy type:
// - for missing APIs, System.Management.Automation.Environment has extension implementation.
// - for existing APIs, System.Management.Automation.Environment redirect the call to System.Environment.
using Environment = System.Management.Automation.Environment;
#endif

namespace Microsoft.PowerShell.Cmdletization.Cim
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Globalization;
using System.Management.Automation;
using System.Net;
using System.Net.Mail;
using System.Net.NetworkInformation;
using System.Reflection;
using System.Security;
Expand All @@ -18,13 +19,6 @@
using Dbg = System.Management.Automation.Diagnostics;
using System.Runtime.InteropServices;

#if CORECLR
// Use stub for MailAddress.
using Microsoft.PowerShell.CoreClr.Stubs;
#else
using System.Net.Mail;
#endif

// TODO/FIXME: Move this class to src/cimSupport/other directory (to map to the namespace it lives in and functionality it implements [cmdletization independent])

namespace Microsoft.PowerShell.Cim
Expand Down
Loading