Skip to content
21 changes: 14 additions & 7 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ function Start-PSBuild {

# These runtimes must match those in project.json
# We do not use ValidateScript since we want tab completion
# If this parameter is not provided it will get determined automatically.
[ValidateSet("win7-x64",
"win7-x86",
"osx.10.12-x64",
Expand Down Expand Up @@ -488,10 +489,12 @@ Fix steps:
Start-ResGen
}

# handle TypeGen
if ($TypeGen -or -not (Test-Path "$PSScriptRoot/src/System.Management.Automation/CoreCLR/CorePsTypeCatalog.cs")) {
# Handle TypeGen
# .inc file name must be different for Windows and Linux to allow build on Windows and WSL.
$incFileName = "powershell_$($Options.Runtime).inc"
if ($TypeGen -or -not (Test-Path "$PSScriptRoot/TypeCatalogGen/$incFileName")) {
log "Run TypeGen (generating CorePsTypeCatalog.cs)"
Start-TypeGen
Start-TypeGen -IncFileName $incFileName
}

# Get the folder path where pwsh.exe is located.
Expand All @@ -515,7 +518,7 @@ Fix steps:
# publish netcoreapp2.0 reference assemblies
try {
Push-Location "$PSScriptRoot/src/TypeCatalogGen"
$refAssemblies = Get-Content -Path "powershell.inc" | Where-Object { $_ -like "*microsoft.netcore.app*" } | ForEach-Object { $_.TrimEnd(';') }
$refAssemblies = Get-Content -Path $incFileName | Where-Object { $_ -like "*microsoft.netcore.app*" } | ForEach-Object { $_.TrimEnd(';') }
$refDestFolder = Join-Path -Path $publishPath -ChildPath "ref"

if (Test-Path $refDestFolder -PathType Container) {
Expand Down Expand Up @@ -1631,7 +1634,11 @@ function Start-DevPowerShell {
function Start-TypeGen
{
[CmdletBinding()]
param()
param
(
[ValidateNotNullOrEmpty()]
$IncFileName = 'powershell.inc'
)

# Add .NET CLI tools to PATH
Find-Dotnet
Expand All @@ -1652,15 +1659,15 @@ function Start-TypeGen

Push-Location "$PSScriptRoot/src/Microsoft.PowerShell.SDK"
try {
$ps_inc_file = "$PSScriptRoot/src/TypeCatalogGen/powershell.inc"
$ps_inc_file = "$PSScriptRoot/src/TypeCatalogGen/$IncFileName"
dotnet msbuild .\Microsoft.PowerShell.SDK.csproj /t:_GetDependencies "/property:DesignTimeBuild=true;_DependencyFile=$ps_inc_file" /nologo
} finally {
Pop-Location
}

Push-Location "$PSScriptRoot/src/TypeCatalogGen"
try {
dotnet run ../System.Management.Automation/CoreCLR/CorePsTypeCatalog.cs powershell.inc
dotnet run ../System.Management.Automation/CoreCLR/CorePsTypeCatalog.cs $IncFileName
} finally {
Pop-Location
}
Expand Down
2 changes: 1 addition & 1 deletion src/TypeCatalogGen/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
powershell.inc
powershell**.inc