Skip to content
Merged
Show file tree
Hide file tree
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
88 changes: 67 additions & 21 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ function Start-PSBuild {
# simplify ParameterSetNames
if ($PSCmdlet.ParameterSetName -eq 'FullCLR') {
$FullCLR = $true

## Stop building 'FullCLR', but keep the parameters and related scripts for now.
## Once we confirm that portable modules is supported with .NET Core 2.0, we will clean up all FullCLR related scripts.
throw "Building against FullCLR is not supported"
}

# Add .NET CLI tools to PATH
Expand Down Expand Up @@ -236,19 +240,20 @@ function Start-PSBuild {
$Arguments += "--runtime", $Options.Runtime

# handle Restore
if ($Restore -or -not (Test-Path "$($Options.Top)/project.lock.json")) {
if ($Restore -or -not (Test-Path "$($Options.Top)/obj/project.assets.json")) {
log "Run dotnet restore"

$srcProjectDirs = @($Options.Top, "$PSScriptRoot/src/TypeCatalogGen", "$PSScriptRoot/src/ResGen")
$testProjectDirs = Get-ChildItem "$PSScriptRoot/test/*.csproj" -Recurse | % { [System.IO.Path]::GetDirectoryName($_) }

$RestoreArguments = @("--verbosity")
if ($PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent) {
$RestoreArguments += "Info"
$RestoreArguments += "detailed"
} else {
$RestoreArguments += "Warning"
$RestoreArguments += "quiet"
}

$RestoreArguments += "$PSScriptRoot"

Start-NativeExecution { dotnet restore $RestoreArguments }
($srcProjectDirs + $testProjectDirs) | % { Start-NativeExecution { dotnet restore $_ $RestoreArguments } }

# .NET Core's crypto library needs brew's OpenSSL libraries added to its rpath
if ($IsOSX) {
Expand Down Expand Up @@ -493,6 +498,12 @@ function New-PSOptions {
# Add .NET CLI tools to PATH
Find-Dotnet

if ($FullCLR) {
## Stop building 'FullCLR', but keep the parameters and related scripts for now.
## Once we confirm that portable modules is supported with .NET Core 2.0, we will clean up all FullCLR related scripts.
throw "Building against FullCLR is not supported"
}

$ConfigWarningMsg = "The passed-in Configuration value '{0}' is not supported on '{1}'. Use '{2}' instead."
if (-not $Configuration) {
$Configuration = if ($IsLinux -or $IsOSX) {
Expand Down Expand Up @@ -673,18 +684,21 @@ function Publish-PSTestTools {
Find-Dotnet

$tools = "$PSScriptRoot/test/tools/EchoArgs","$PSScriptRoot/test/tools/CreateChildProcess"
# Publish EchoArgs so it can be run by tests
if ($Options -eq $null)
{
$Options = New-PSOptions
}

# Publish EchoArgs so it can be run by tests
foreach ($tool in $tools)
{
Push-Location $tool
try {
dotnet publish --output bin
dotnet publish --output bin --configuration $Options.Configuration --framework $Options.Framework --runtime $Options.Runtime
} finally {
Pop-Location
}
}

}

function Start-PSPester {
Expand All @@ -705,6 +719,12 @@ function Start-PSPester {
[switch]$PassThru
)

if ($FullCLR) {
## Stop building 'FullCLR', but keep the parameters and related scripts for now.
## Once we confirm that portable modules is supported with .NET Core 2.0, we will clean up all FullCLR related scripts.
throw "Building against FullCLR is not supported"
}

# we need to do few checks and if user didn't provide $ExcludeTag explicitly, we should alternate the default
if ($Unelevate)
{
Expand Down Expand Up @@ -937,7 +957,7 @@ function Start-PSxUnit {
function Install-Dotnet {
[CmdletBinding()]
param(
[string]$Channel = "preview",
[string]$Channel,
[string]$Version,
[switch]$NoSudo
)
Expand All @@ -946,7 +966,7 @@ function Install-Dotnet {
# 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.0-preview2-1-3177/scripts/obtain"
$obtainUrl = "https://raw.githubusercontent.com/dotnet/cli/v1.0.1/scripts/obtain"

# Install for Linux and OS X
if ($IsLinux -or $IsOSX) {
Expand Down Expand Up @@ -1005,11 +1025,11 @@ function Start-PSBootstrap {
SupportsShouldProcess=$true,
ConfirmImpact="High")]
param(
[string]$Channel = "preview",
[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.0-preview2-1-003177",
[string]$Version = "1.0.1",
[switch]$Package,
[switch]$NoSudo,
[switch]$Force
Expand Down Expand Up @@ -1751,7 +1771,9 @@ function Publish-NuGetFeed
# Add .NET CLI tools to PATH
Find-Dotnet

@(
try {
Push-Location $PSScriptRoot
@(
'Microsoft.PowerShell.Commands.Management',
'Microsoft.PowerShell.Commands.Utility',
'Microsoft.PowerShell.Commands.Diagnostics',
Expand All @@ -1763,12 +1785,15 @@ function Publish-NuGetFeed
'Microsoft.WSMan.Management',
'Microsoft.WSMan.Runtime',
'Microsoft.PowerShell.SDK'
) | % {
if ($VersionSuffix) {
dotnet pack "src/$_" --output $OutputPath --version-suffix $VersionSuffix
} else {
dotnet pack "src/$_" --output $OutputPath
) | % {
if ($VersionSuffix) {
dotnet pack "src/$_" --output $OutputPath --version-suffix $VersionSuffix /p:IncludeSymbols=true
} else {
dotnet pack "src/$_" --output $OutputPath
}
}
} finally {
Pop-Location
}
}

Expand All @@ -1784,6 +1809,12 @@ function Start-DevPowerShell {
[switch]$KeepPSModulePath
)

if ($FullCLR) {
## Stop building 'FullCLR', but keep the parameters and related scripts for now.
## Once we confirm that portable modules is supported with .NET Core 2.0, we will clean up all FullCLR related scripts.
throw "Building against FullCLR is not supported"
}

try {
if ((-not $NoNewWindow) -and ($IsCoreCLR)) {
Write-Warning "Start-DevPowerShell -NoNewWindow is currently implied in PowerShellCore edition https://github.com/PowerShell/PowerShell/issues/1543"
Expand Down Expand Up @@ -2046,9 +2077,24 @@ function Start-TypeGen
# Add .NET CLI tools to PATH
Find-Dotnet

Push-Location "$PSScriptRoot/src/TypeCatalogParser"
$GetDependenciesTargetPath = "$PSScriptRoot/src/Microsoft.PowerShell.SDK/obj/Microsoft.PowerShell.SDK.csproj.TypeCatalog.targets"
$GetDependenciesTargetValue = @'
<Project>
<Target Name="_GetDependencies"
DependsOnTargets="ResolvePackageDependenciesDesignTime">
<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' " />
</ItemGroup>
<WriteLinesToFile File="$(_DependencyFile)" Lines="@(_DependentAssemblyPath)" Overwrite="true" />
</Target>
</Project>
'@
Set-Content -Path $GetDependenciesTargetPath -Value $GetDependenciesTargetValue -Force -Encoding Ascii

Push-Location "$PSScriptRoot/src/Microsoft.PowerShell.SDK"
try {
dotnet run
$ps_inc_file = "$PSScriptRoot/src/TypeCatalogGen/powershell.inc"
dotnet msbuild .\Microsoft.PowerShell.SDK.csproj /t:_GetDependencies "/property:DesignTimeBuild=true;_DependencyFile=$ps_inc_file" /nologo
} finally {
Pop-Location
}
Expand Down
37 changes: 31 additions & 6 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,51 @@ if hash powershell 2>/dev/null; then
powershell -noprofile -c "Import-Module ./build.psm1; Start-PSBuild"
else
echo 'Continuing with full manual build'
dotnet restore
pushd src/ResGen
dotnet run
popd

pushd src/TypeCatalogParser
## Restore
dotnet restore src/powershell-unix
dotnet restore src/ResGen
dotnet restore src/TypeCatalogGen

## Setup the build target to gather dependency information
targetFile="$(pwd)/src/Microsoft.PowerShell.SDK/obj/Microsoft.PowerShell.SDK.csproj.TypeCatalog.targets"
cat > $targetFile <<-"EOF"
<Project>
<Target Name="_GetDependencies"
DependsOnTargets="ResolvePackageDependenciesDesignTime">
<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' " />
</ItemGroup>
<WriteLinesToFile File="$(_DependencyFile)" Lines="@(_DependentAssemblyPath)" Overwrite="true" />
</Target>
</Project>
EOF
dotnet msbuild src/Microsoft.PowerShell.SDK/Microsoft.PowerShell.SDK.csproj /t:_GetDependencies "/property:DesignTimeBuild=true;_DependencyFile=$(pwd)/src/TypeCatalogGen/powershell.inc" /nologo

## Generate 'powershell.version'
git --git-dir="$(pwd)/.git" describe --dirty --abbrev=60 > "$(pwd)/powershell.version"

## Generate resource binding C# files
pushd src/ResGen
dotnet run
popd

## Generate 'CorePsTypeCatalog.cs'
pushd src/TypeCatalogGen
dotnet run ../Microsoft.PowerShell.CoreCLR.AssemblyLoadContext/CorePsTypeCatalog.cs powershell.inc
popd

## Build native component
pushd src/libpsl-native
cmake -DCMAKE_BUILD_TYPE=Debug .
make -j
make test
popd

dotnet publish --configuration Linux ./src/powershell-unix/ --output bin
## Build powershell core
rawRid="$(dotnet --info | grep RID)"
rid=${rawRid##* } # retain the part after the last space
dotnet publish --configuration Linux src/powershell-unix/ --output bin --runtime $rid

echo 'You can run powershell from bin/, but some modules that are normally added by the Restore-PSModule step will not be available.'
fi
7 changes: 0 additions & 7 deletions docs/cmdlet-example/NuGet.config

This file was deleted.

13 changes: 0 additions & 13 deletions docs/cmdlet-example/SendGreeting.Tests.ps1

This file was deleted.

30 changes: 0 additions & 30 deletions docs/cmdlet-example/SendGreeting.cs

This file was deleted.

19 changes: 0 additions & 19 deletions docs/cmdlet-example/project.json

This file was deleted.

52 changes: 0 additions & 52 deletions powershell.sln

This file was deleted.

Loading