diff --git a/appveyor.yml b/appveyor.yml index decbcd9b0..5f469df7d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 0.4.0.{build} +version: 0.5.0.{build} nuget: project_feed: true diff --git a/build.psm1 b/build.psm1 index 15ed23184..b61915a2f 100644 --- a/build.psm1 +++ b/build.psm1 @@ -32,6 +32,7 @@ function Start-PSBuild { [string]$Output, [switch]$ResGen, [switch]$TypeGen, + [switch]$Clean, [Parameter(ParameterSetName='CoreCLR')] [switch]$Publish, @@ -48,11 +49,11 @@ function Start-PSBuild { [Parameter(ParameterSetName='CoreCLR')] [string]$Runtime, - [Parameter(ParameterSetName='FullCLR')] + [Parameter(ParameterSetName='FullCLR', Mandatory=$true)] [switch]$FullCLR, [Parameter(ParameterSetName='FullCLR')] - [switch]$ResolveXaml, + [switch]$XamlGen, [Parameter(ParameterSetName='FullCLR')] [string]$cmakeGenerator = "Visual Studio 14 2015 Win64", @@ -63,6 +64,12 @@ function Start-PSBuild { [string]$msbuildConfiguration = "Release" ) + if ($Clean) + { + log "Cleaning your working directory. You can also do it with 'git clean -fdX'" + git clean -fdX + } + # save Git description to file for PowerShell to include in PSVersionTable git --git-dir="$PSScriptRoot/.git" describe --dirty --abbrev=60 > "$psscriptroot/powershell.version" @@ -87,14 +94,7 @@ function Start-PSBuild { # cmake is needed to build powershell.exe $precheck = $precheck -and (precheck 'cmake' 'cmake not found. You can install it from https://chocolatey.org/packages/cmake.portable') - # msbuild is needed to build powershell.exe - # msbuild is part of .NET Framework, we can try to get it from well-known location. - if (-not $NoPath) { - Use-MSBuild - } - - $precheck = $precheck -and (precheck 'msbuild' 'msbuild not found. Install Visual Studio 2015.') - + Use-MSBuild #mc.exe is Message Compiler for native resources $mcexe = Get-ChildItem "${env:ProgramFiles(x86)}\Microsoft SDKs\Windows\" -Recurse -Filter 'mc.exe' | ? {$_.FullName -match 'x64'} | select -First 1 | % {$_.FullName} if (-not $mcexe) { @@ -156,9 +156,10 @@ function Start-PSBuild { # handle xaml files # Heuristic to resolve xaml on the fresh machine - if ($FullCLR -and ($ResolveXaml -or -not (Test-Path "$PSScriptRoot/src/Microsoft.PowerShell.Activities/gen/*.g.resources"))) + if ($FullCLR -and ($XamlGen -or -not (Test-Path "$PSScriptRoot/src/Microsoft.PowerShell.Activities/gen/*.g.resources"))) { - Resolve-Xaml -MSBuildConfiguration $msbuildConfiguration + log "Run XamlGen (generating .g.cs and .resources for .xaml files)" + Start-XamlGen -MSBuildConfiguration $msbuildConfiguration } # Build native components @@ -195,17 +196,17 @@ function Start-PSBuild { @("nativemsh/pwrshplugin") | % { $nativeResourcesFolder = $_ Get-ChildItem $nativeResourcesFolder -Filter "*.mc" | % { - & $mcexe -c -U $_.FullName -h $nativeResourcesFolder -r $nativeResourcesFolder + # & $mcexe -c -U $_.FullName -h $nativeResourcesFolder -r $nativeResourcesFolder } } if ($cmakeGenerator) { - cmake -G $cmakeGenerator . + Start-NativeExecution { cmake -G $cmakeGenerator . } } else { - cmake . + Start-NativeExecution { cmake . } } - Start-NativeExecution { msbuild ALL_BUILD.vcxproj /p:Configuration=$msbuildConfiguration } + Start-NativeExecution { msbuild powershell.vcxproj /p:Configuration=$msbuildConfiguration } } finally { Pop-Location @@ -413,7 +414,7 @@ function Start-PSBootstrap { [string]$Version = "latest" ) - Write-Host "Installing Open PowerShell build dependencies" + log "Installing Open PowerShell build dependencies" Push-Location $PSScriptRoot/tools @@ -745,7 +746,7 @@ function Copy-MappedFiles { $cl = git --git-dir="$PSScriptRoot/.git" tag | % {if ($_ -match 'SD.(\d+)$') {[int]$Matches[1]} } | Sort-Object -Descending | Select-Object -First 1 if ($cl) { - Write-Host -ForegroundColor Green "Current base-line CL is SD:$cl (based on tags)" + log "Current base-line CL is SD:$cl (based on tags)" } else { @@ -762,13 +763,12 @@ function Copy-MappedFiles { if (git log --grep="SD:$cl" HEAD^..HEAD) { - Write-Host -ForegroundColor Green "$pslMonadRoot HEAD matches [SD:$cl]" + log Green "$pslMonadRoot HEAD matches [SD:$cl]" } else { - Write-Host -ForegroundColor Yellow "Try to checkout this commit in $pslMonadRoot :" - git log --grep="SD:$cl" - + Write-Warning "Try to checkout this commit in $pslMonadRoot :" + git log --grep="SD:$cl" | Write-Warning MaybeTerminatingWarning "$pslMonadRoot HEAD doesn't match [SD:$cl]" } } @@ -879,7 +879,7 @@ function Send-GitDiffToSd { $m = Get-Mappings -KeepRelativePaths -Root $AdminRoot $affectedFiles = git diff --name-only $diffArg1 $diffArg2 $affectedFiles | % { - Write-Host -Foreground Green "Changes in file $_" + log "Changes in file $_" } $rev = Get-InvertedOrderedMap $m @@ -894,19 +894,19 @@ function Send-GitDiffToSd { $diff = git diff $diffArg1 $diffArg2 -- $file if ($diff) { - Write-Host -Foreground Green "Apply patch to $sdFilePath" + log "Apply patch to $sdFilePath" Set-Content -Value $diff -Path $env:TEMP\diff -Encoding Ascii if ($WhatIf) { - Write-Host -Foreground Green "Patch content" + log "Patch content" Get-Content $env:TEMP\diff } else { & $patchPath --binary -p1 $sdFilePath $env:TEMP\diff } } else { - Write-Host -Foreground Green "No changes in $file" + log "No changes in $file" } } else { - Write-Host -Foreground Green "Ignore changes in $file, because there is no mapping for it" + log "Ignore changes in $file, because there is no mapping for it" } } } @@ -989,7 +989,7 @@ function Find-Dotnet() { } } -function Resolve-Xaml +function Start-XamlGen { [CmdletBinding()] param( @@ -1000,11 +1000,6 @@ function Resolve-Xaml ) Use-MSBuild - $precheck = precheck 'msbuild' 'msbuild not found. Install Visual Studio 2015.' - if (-not $precheck) { - return - } - Get-ChildItem -Path "$PSScriptRoot/src" -Directory | % { $XamlDir = Join-Path -Path $_.FullName -ChildPath Xamls @@ -1015,19 +1010,22 @@ function Resolve-Xaml Remove-Item -Path $OutputDir -Recurse -Force -ErrorAction SilentlyContinue mkdir -Path $OutputDir -Force > $null - # For GraphicalHost we will get failures, but it's ok: we only need to copy *.g.cs files in the dotnet cli project. - # For over projects we leave the check just in case. - # We can revisit it on case-by-case basis. - $IgnoreFailure = [bool]($XamlDir -match 'GraphicalHost') - - $SourceDir = ConvertFrom-Xaml -Configuration $MSBuildConfiguration -OutputDir $OutputDir -XamlDir $XamlDir -IgnoreMsbuildFailure:$IgnoreFailure + # we will get failures, but it's ok: we only need to copy *.g.cs files in the dotnet cli project. + $SourceDir = ConvertFrom-Xaml -Configuration $MSBuildConfiguration -OutputDir $OutputDir -XamlDir $XamlDir -IgnoreMsbuildFailure:$true $DestinationDir = Join-Path -Path $_.FullName -ChildPath gen - if (-not (Test-Path $DestinationDir -PathType Container)) + New-Item -ItemType Directory $DestinationDir -ErrorAction SilentlyContinue > $null + $filesToCopy = Get-Item "$SourceDir\*.cs", "$SourceDir\*.g.resources" + if (-not $filesToCopy) { - mkdir -Path $DestinationDir -Force > $null + throw "No .cs or .g.resources files are generated for $XamlDir, something went wrong. Run 'Start-XamlGen -Verbose' for details." + } + + $filesToCopy | % { + $sourcePath = $_.FullName + Write-Verbose "Copy generated xaml artifact: $sourcePath -> $DestinationDir" + Copy-Item -Path $sourcePath -Destination $DestinationDir } - Copy-Item -Path $SourceDir\*.cs, $SourceDir\*.g.resources -Destination $DestinationDir -Force } } } @@ -1049,13 +1047,13 @@ $Script:XamlProj = @" {2} - + False - + False - + False @@ -1082,7 +1080,7 @@ function script:ConvertFrom-Xaml { [switch] $IgnoreMsbuildFailure ) - Write-Verbose "ConvertFrom-Xaml for $XamlDir" + log "ConvertFrom-Xaml for $XamlDir" $Pages = "" Get-ChildItem -Path "$XamlDir\*.xaml" | % { @@ -1094,14 +1092,14 @@ function script:ConvertFrom-Xaml { $XamlProjPath = Join-Path -Path $OutputDir -ChildPath xaml.proj Set-Content -Path $XamlProjPath -Value $XamlProjContent -Encoding Ascii -NoNewline -Force - msbuild $XamlProjPath > $null + msbuild $XamlProjPath | Write-Verbose if ($LASTEXITCODE -ne 0) { $message = "When processing $XamlDir 'msbuild $XamlProjPath > `$null' failed with exit code $LASTEXITCODE" if ($IgnoreMsbuildFailure) { - Write-Warning $message + Write-Verbose $message } else { @@ -1114,10 +1112,23 @@ function script:ConvertFrom-Xaml { function script:Use-MSBuild { - if (-not (Get-Command -Name msbuild -ErrorAction Ignore)) { - Write-Verbose "Appending probable Visual C++ tools path" - $env:path += ";${env:SystemRoot}\Microsoft.Net\Framework\v4.0.30319" + # TODO: we probably should require a particular version of msbuild, if we are taking this dependency + # msbuild v14 and msbuild v4 behaviors are different for XAML generation + $frameworkMsBuildLocation = "${env:SystemRoot}\Microsoft.Net\Framework\v4.0.30319\msbuild" + + $msbuild = get-command msbuild -ErrorAction SilentlyContinue + if ($msbuild) + { + # all good, nothing to do + return } + + if (-not (Test-Path $frameworkMsBuildLocation)) + { + throw "msbuild not found in '$frameworkMsBuildLocation'. Install Visual Studio 2015." + } + + Set-Alias msbuild $frameworkMsBuildLocation -Scope Script } diff --git a/src/Microsoft.PowerShell.Activities/Xamls/InlineScriptDesigner.xaml b/src/Microsoft.PowerShell.Activities/Xamls/InlineScriptDesigner.xaml index 6d5deb2de..a01b00c04 100644 --- a/src/Microsoft.PowerShell.Activities/Xamls/InlineScriptDesigner.xaml +++ b/src/Microsoft.PowerShell.Activities/Xamls/InlineScriptDesigner.xaml @@ -6,7 +6,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:conv="clr-namespace:System.Activities.Presentation.Converters;assembly=System.Activities.Presentation" - xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation" + xmlns:sap="clr-namespace:System.Activities.Presentation" xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" diff --git a/src/Microsoft.PowerShell.Activities/Xamls/PipelineDesigner.xaml b/src/Microsoft.PowerShell.Activities/Xamls/PipelineDesigner.xaml index 983cfeee7..16f9b3543 100644 --- a/src/Microsoft.PowerShell.Activities/Xamls/PipelineDesigner.xaml +++ b/src/Microsoft.PowerShell.Activities/Xamls/PipelineDesigner.xaml @@ -1,7 +1,7 @@  + xmlns:swd="clr-namespace:System.Activities.Presentation"> diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs index 1898ebf34..a7db0f5bf 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs @@ -238,7 +238,7 @@ namespace Microsoft.PowerShell result = ReadLineSafe(true, printToken); } SecureString secureResult = result as SecureString; - Diagnostics.Assert(secureResult != null, "ReadLineSafe did not return a SecureString"); + System.Management.Automation.Diagnostics.Assert(secureResult != null, "ReadLineSafe did not return a SecureString"); return secureResult; } diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfacePrompt.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfacePrompt.cs index 875ea3cf1..d32653318 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfacePrompt.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfacePrompt.cs @@ -400,7 +400,7 @@ namespace Microsoft.PowerShell { object userInput = ReadLineSafe(false, null); string userInputString = userInput as string; - Diagnostics.Assert(userInputString != null, "ReadLineSafe did not return a string"); + System.Management.Automation.Diagnostics.Assert(userInputString != null, "ReadLineSafe did not return a string"); rawInputString = userInputString; } if (rawInputString == null) diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfacePromptForChoice.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfacePromptForChoice.cs index 0a74f226e..df674b80e 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfacePromptForChoice.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfacePromptForChoice.cs @@ -315,7 +315,7 @@ namespace Microsoft.PowerShell Dictionary defaultChoiceKeys, bool shouldEmulateForMultipleChoiceSelection) { - Diagnostics.Assert(defaultChoiceKeys != null, "defaultChoiceKeys cannot be null."); + System.Management.Automation.Diagnostics.Assert(defaultChoiceKeys != null, "defaultChoiceKeys cannot be null."); ConsoleColor fg = RawUI.ForegroundColor; ConsoleColor bg = RawUI.BackgroundColor; diff --git a/src/Microsoft.PowerShell.ConsoleHost/project.json b/src/Microsoft.PowerShell.ConsoleHost/project.json index 124d0f4ab..305c19e3c 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/project.json +++ b/src/Microsoft.PowerShell.ConsoleHost/project.json @@ -25,6 +25,9 @@ "../Modules", "powershell.exe", "../../powershell.version" + ], + "exclude": [ + "../Modules/Pester/.git" ] }, @@ -53,7 +56,14 @@ "dependencies": { "Microsoft.PowerShell.ScheduledJob": "1.0.0-*", "Microsoft.PowerShell.Workflow.ServiceCore": "1.0.0-*", - "Microsoft.PowerShell.GraphicalHost": "1.0.0-*" + "Microsoft.PowerShell.GraphicalHost": "1.0.0-*", + "Microsoft.PowerShell.Activities": "1.0.0-*", + "Microsoft.PowerShell.Core.Activities": "1.0.0-*", + "Microsoft.PowerShell.Diagnostics.Activities": "1.0.0-*", + "Microsoft.PowerShell.Management.Activities": "1.0.0-*", + "Microsoft.PowerShell.Security.Activities": "1.0.0-*", + "Microsoft.PowerShell.Utility.Activities": "1.0.0-*", + "Microsoft.WSMan.Management.Activities": "1.0.0-*" } } } diff --git a/src/powershell-native/CMakeLists.txt b/src/powershell-native/CMakeLists.txt index a4ac5cdfa..0388e2644 100644 --- a/src/powershell-native/CMakeLists.txt +++ b/src/powershell-native/CMakeLists.txt @@ -30,8 +30,8 @@ add_executable(powershell WIN32 add_library(pwrshplugin nativemsh/pwrshplugin/entrypoints.cpp nativemsh/pwrshplugin/pwrshclrhost.cpp - nativemsh/pwrshplugin/pwrshpluginerrorcodes.mc - nativemsh/pwrshplugin/pwrshpluginerrorcodes.rc + #nativemsh/pwrshplugin/pwrshpluginerrorcodes.mc + #nativemsh/pwrshplugin/pwrshpluginerrorcodes.rc nativemsh/pwrshplugin/pwrshplugin.def) diff --git a/src/powershell/project.json b/src/powershell/project.json index b9efbc23b..e9818ada7 100644 --- a/src/powershell/project.json +++ b/src/powershell/project.json @@ -25,6 +25,9 @@ "*.so", "*.dylib", "../../powershell.version" + ], + "exclude": [ + "../Modules/Pester/.git" ] },