diff --git a/Images/CopyLocal.png b/Images/CopyLocal.png new file mode 100644 index 0000000..60e8d34 Binary files /dev/null and b/Images/CopyLocal.png differ diff --git a/PowerShellStandard.psm1 b/PowerShellStandard.psm1 index f930306..d357b49 100644 --- a/PowerShellStandard.psm1 +++ b/PowerShellStandard.psm1 @@ -1,4 +1,5 @@ function Start-Build { + param ( [switch]$CoreOnly ) $versions = 3,5 $srcBase = Join-Path $PsScriptRoot src foreach ( $version in $versions ) { @@ -6,7 +7,12 @@ function Start-Build { $srcDir = Join-Path $srcBase $version Push-Location $srcDir dotnet restore - dotnet build --configuration Release + if ( $CoreOnly ) { + dotnet build --configuration Release --framework netstandard2.0 + } + else { + dotnet build --configuration Release + } } finally { Pop-Location @@ -49,13 +55,40 @@ function Start-Clean { } function Invoke-Test { + param ( [switch]$CoreOnly ) + # first, run the package tests and validate that the signing.xml file is correct + try { + $testBase = Join-Path $PsScriptRoot test + Push-Location $testBase + Invoke-Pester -Path ./Build.Tests.ps1 + } + finally { + Pop-Location + } $versions = 3,5 foreach ( $version in $versions ) { try { $testBase = Join-Path $PsScriptRoot "test/${version}" Push-Location $testBase - dotnet build --configuration Release - Invoke-Pester + foreach ( $framework in "core","full" ) { + if ( $CoreOnly -and $framework -eq "full" ) { + continue + } + try { + Push-Location $framework + if ( $CoreOnly ) { + dotnet build --configuration Release --framework netstandard2.0 + Invoke-Pester + } + else { + dotnet build --configuration Release + Invoke-Pester + } + } + finally { + pop-location + } + } } finally { Pop-Location diff --git a/README.md b/README.md index be5ad1d..f7e07f4 100644 --- a/README.md +++ b/README.md @@ -65,3 +65,92 @@ To remove all build artifacts (except for the .nuget files in the root of the re ```powershell ./build.ps1 -Clean ``` + +## How to use the PowerShell Standard Library + +### Via Visual Studio + +Using the PowerShell Standard Library within Visual Studio is as simple as installing the package into your solution and building the project + +Create a project, and in the Package Manager Console (Tools -> Nuget Package Manager -> Package Manager Console) type: + +```powershell +install-package -id PowerShellStandard.Library +``` + +This will add `System.Management.Automation` to your project references. +After this, you must set `Copy Local` to False in the Reference Properties pane. + +![Copy Local = False](Images/CopyLocal.png) + +This will keep the PowerShell Standard Library from being copied into your release/publish directories. +This is because the PowerShell Standard Library is a _reference_ assembly and doesn't actually contain any implementations and should never be distributed with your module. +You may now create and build your module in the usual way. + +Once your module is built, you can see the portability of your module very easily, if you have both Windows PowerShell and PowerShell core on your system. +The following demonstrates the portability of using PowerShell Standard. + +The following shows the same assembly being used by both Windows PowerShell, PowerShell Core, and via Docker; PowerShell Core on Linux. + +```powershell +PS> powershell +Windows PowerShell +Copyright (C) Microsoft Corporation. All rights reserved. + +Loading personal and system profiles took 714ms. +PS> gci + + Directory: C:\users\jimtru\documents\visual studio 2017\Projects\ClassLibrary2\ClassLibrary2\bin\Debug + +Mode LastWriteTime Length Name +---- ------------- ------ ---- +-a---- 3/7/2019 10:54 AM 4608 ClassLibrary2.dll +-a---- 3/7/2019 10:54 AM 15872 ClassLibrary2.pdb + +PS> import-module .\ClassLibrary2.dll +PS> "joe","jane" | Invoke-Demo +Hello 'joe' +Hello 'jane' +PS> exit + +PS> pwsh-preview +PowerShell 6.1.0-rc.1 +Copyright (c) Microsoft Corporation. All rights reserved. + +https://aka.ms/pscore6-docs +Type 'help' to get help. + +PS> import-module .\ClassLibrary2.dll +PS> "joe","jane" | Invoke-Demo +Hello 'joe' +Hello 'jane' +PS> exit + +PS> $m = "C:\Users\jimtru\DOCUME~1\VIBB41~1\Projects\CLASSL~2\CLASSL~1\bin\Debug" +PS> docker run --rm -it -v "${m}:/module" mcr.microsoft.com/powershell:preview +PowerShell 6.2.0-rc.1 +Copyright (c) Microsoft Corporation. All rights reserved. + +https://aka.ms/pscore6-docs +Type 'help' to get help. + +PS /> hostname +add7d6ed4818 + +PS /> select-string pretty /etc/os-release +etc/os-release:5:PRETTY_NAME="Ubuntu 18.04.2 LTS" + +PS /> gci /module + Directory: /module +Mode LastWriteTime Length Name +---- ------------- ------ ---- +------ 3/7/19 6:54 PM 4608 ClassLibrary2.dll +------ 3/7/19 6:54 PM 15872 ClassLibrary2.pdbPS /> import-module /module/ClassLibrary2.dll + +PS /> Import-Module /module/ClassLibrary2.dll +PS /> "joe","jane" | Invoke-Demo +Hello 'joe' +Hello 'jane' +``` + +And that's how you can build a single module used by Windows PowerShell, PowerShell Core on Windows and Linux! diff --git a/build.ps1 b/build.ps1 index da00f83..053cdd0 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,8 +1,9 @@ #!/usr/bin/env pwsh param ( - [Parameter()][switch]$Clean, - [Parameter()][switch]$Test, - [Parameter()][switch]$Pack + [Parameter(HelpMessage="Remove earlier built versions")][switch]$Clean, + [Parameter(HelpMessage="Run the tests")][switch]$Test, + [Parameter(HelpMessage="Create a .nupkg")][switch]$Pack, + [Parameter(HelpMessage="Build only for netstandard2.0")][switch]$CoreOnly ) import-module $PSScriptRoot/PowerShellStandard.psm1 -force @@ -12,14 +13,25 @@ if ( $Clean ) { return } +# It would be great if there were targeting frameworks for net452 +# on non-Windows platforms, but for now, if you're linux or macOS +# we'll build only core +if ( $IsLinux -or $IsMacOS ) { + $CoreOnly = $true +} + if ( $Pack ) { + if ( $CoreOnly ) { + Write-Warning "Must build both netstandard2.0 and net452 to build package" + throw "Build on a Windows system with netstandard and net452 target platforms" + } Export-NuGetPackage } else { - Start-Build + Start-Build -CoreOnly:$CoreOnly } if ( $Test ) { - Invoke-Test + Invoke-Test -CoreOnly:$CoreOnly } diff --git a/src/3/System.Management.Automation-lib.csproj b/src/3/System.Management.Automation-lib.csproj index 3df409d..c85d8ff 100644 --- a/src/3/System.Management.Automation-lib.csproj +++ b/src/3/System.Management.Automation-lib.csproj @@ -1,6 +1,6 @@  - netstandard2.0 + netstandard2.0;net451 True ..\signing\visualstudiopublic.snk System.Management.Automation @@ -10,7 +10,7 @@ RUNTIME_SERIALIZATION ./PowershellStandard.Library.nuspec - + diff --git a/src/5/PowerShellStandard.Library.nuspec b/src/5/PowerShellStandard.Library.nuspec index 657e569..843274d 100644 --- a/src/5/PowerShellStandard.Library.nuspec +++ b/src/5/PowerShellStandard.Library.nuspec @@ -2,7 +2,8 @@ PowerShellStandard.Library - 5.1.0-RC1 + 5.1.1 + PowerShellStandard.Library Microsoft Microsoft,PowerShellTeam https://github.com/PowerShell/PowerShellStandard @@ -11,13 +12,16 @@ false Contains the reference assemblies for PowerShell Standard 5 © Microsoft Corporation. All rights reserved. - PowerShell, reference, netstandard2, netstandard2.0 + PowerShell, reference, net452, netstandard2, netstandard2.0 - + + False + + diff --git a/src/5/System.Management.Automation-lib.csproj b/src/5/System.Management.Automation-lib.csproj index ba6c6d4..09923e0 100644 --- a/src/5/System.Management.Automation-lib.csproj +++ b/src/5/System.Management.Automation-lib.csproj @@ -1,16 +1,16 @@  - netstandard2.0 + netstandard2.0;net452 True ..\signing\visualstudiopublic.snk System.Management.Automation 3.0.0 - 5.1.0 + 5.1.1 True RUNTIME_SERIALIZATION ./PowershellStandard.Library.nuspec - + diff --git a/src/dotnetTemplate/Microsoft.PowerShell.Standard.Module.Template/Microsoft.PowerShell.Standard.Module.Template.nuspec b/src/dotnetTemplate/Microsoft.PowerShell.Standard.Module.Template/Microsoft.PowerShell.Standard.Module.Template.nuspec index f5c0437..091bb80 100755 --- a/src/dotnetTemplate/Microsoft.PowerShell.Standard.Module.Template/Microsoft.PowerShell.Standard.Module.Template.nuspec +++ b/src/dotnetTemplate/Microsoft.PowerShell.Standard.Module.Template/Microsoft.PowerShell.Standard.Module.Template.nuspec @@ -2,7 +2,7 @@ Microsoft.PowerShell.Standard.Module.Template - 0.1.3 + 0.1.4 PowerShell Standard module Microsoft Microsoft,PowerShellTeam diff --git a/src/dotnetTemplate/Microsoft.PowerShell.Standard.Module.Template/Microsoft.PowerShell.Standard.Module.Template/Microsoft.PowerShell.Standard.Module.Template.csproj b/src/dotnetTemplate/Microsoft.PowerShell.Standard.Module.Template/Microsoft.PowerShell.Standard.Module.Template/Microsoft.PowerShell.Standard.Module.Template.csproj index 75b7bc0..c0568b5 100755 --- a/src/dotnetTemplate/Microsoft.PowerShell.Standard.Module.Template/Microsoft.PowerShell.Standard.Module.Template/Microsoft.PowerShell.Standard.Module.Template.csproj +++ b/src/dotnetTemplate/Microsoft.PowerShell.Standard.Module.Template/Microsoft.PowerShell.Standard.Module.Template/Microsoft.PowerShell.Standard.Module.Template.csproj @@ -6,7 +6,7 @@ - + All diff --git a/src/dotnetTemplate/README.md b/src/dotnetTemplate/README.md index e156eed..917903f 100755 --- a/src/dotnetTemplate/README.md +++ b/src/dotnetTemplate/README.md @@ -95,9 +95,9 @@ PowerShell Standard Module (C#) Author: Microsoft Corporation Options: -v|--powershell-standard-version - 5.1.0-preview-03 - PowerShell Standard 5.1 + 5.1.1 - PowerShell Standard 5.1.1 3.0.0-preview-02 - PowerShell Standard 3.0 - Default: 5.1.0-preview-03 + Default: 5.1.1 --no-restore If specified, skips the automatic restore of the project on create. bool - Optional @@ -132,4 +132,4 @@ This template will create: * `*.csproj` - a project file that uses the same name as the folder it was created in * `TestSampleCmdletCommand.cs` - an example PowerShell cmdlet class -* `obj` - a folder generated by the restore \ No newline at end of file +* `obj` - a folder generated by the restore diff --git a/test/3/Class1.cs b/test/3/core/Class1.cs similarity index 100% rename from test/3/Class1.cs rename to test/3/core/Class1.cs diff --git a/test/3/PSS3.Tests.ps1 b/test/3/core/PSS3.Tests.ps1 similarity index 100% rename from test/3/PSS3.Tests.ps1 rename to test/3/core/PSS3.Tests.ps1 diff --git a/test/3/PSStandard.csproj b/test/3/core/PSStandard.csproj similarity index 67% rename from test/3/PSStandard.csproj rename to test/3/core/PSStandard.csproj index 9539d6e..1788186 100644 --- a/test/3/PSStandard.csproj +++ b/test/3/core/PSStandard.csproj @@ -6,7 +6,7 @@ - + diff --git a/test/3/full/Class1.cs b/test/3/full/Class1.cs new file mode 100644 index 0000000..bb19baf --- /dev/null +++ b/test/3/full/Class1.cs @@ -0,0 +1,17 @@ +using System; +using System.Management.Automation; + +namespace PSStandard +{ + [Cmdlet("get","thing")] + public class Class1 : PSCmdlet + { + [Parameter()] + [Credential()] + public PSCredential Credential { get; set; } + + protected override void EndProcessing() { + WriteObject("Success!"); + } + } +} diff --git a/test/3/full/PSS3.Tests.ps1 b/test/3/full/PSS3.Tests.ps1 new file mode 100644 index 0000000..fa5f429 --- /dev/null +++ b/test/3/full/PSS3.Tests.ps1 @@ -0,0 +1,16 @@ +Describe "PowerShell Standard 3" { + BeforeAll { + $cmdletAssembly = "bin/Release/net452/Demo.Cmdlet.dll" + $assemblyPath = Join-Path "$PSScriptRoot" $cmdletAssembly + $PSBin = (Get-Process -id $PID).MainModule.FileName + } + It "Can build a reference assembly" { + dotnet restore + dotnet build --configuration Release + $assemblyPath | Should Exist + } + It "Can execute the compiled cmdlet" { + $result = & $PSBin -c "import-module $assemblyPath; Get-Thing" + $result | Should Be "success!" + } +} diff --git a/test/3/full/PSStandard.csproj b/test/3/full/PSStandard.csproj new file mode 100644 index 0000000..c2e6477 --- /dev/null +++ b/test/3/full/PSStandard.csproj @@ -0,0 +1,12 @@ + + + + net452 + Demo.Cmdlet + + + + + + + diff --git a/test/5/Class1.cs b/test/5/core/Class1.cs similarity index 100% rename from test/5/Class1.cs rename to test/5/core/Class1.cs diff --git a/test/5/PSS5.Tests.ps1 b/test/5/core/PSS5.Tests.ps1 similarity index 100% rename from test/5/PSS5.Tests.ps1 rename to test/5/core/PSS5.Tests.ps1 diff --git a/test/5/PSStandard.csproj b/test/5/core/PSStandard.csproj similarity index 67% rename from test/5/PSStandard.csproj rename to test/5/core/PSStandard.csproj index b452d75..56ea41f 100644 --- a/test/5/PSStandard.csproj +++ b/test/5/core/PSStandard.csproj @@ -6,7 +6,7 @@ - + diff --git a/test/5/full/Class1.cs b/test/5/full/Class1.cs new file mode 100644 index 0000000..6c8e388 --- /dev/null +++ b/test/5/full/Class1.cs @@ -0,0 +1,27 @@ +using System; +using System.Management.Automation; +using System.Management.Automation.Runspaces; + +namespace PSStandard +{ + [Cmdlet("get","thing")] + public class Class1 : PSCmdlet + { + [Parameter()] + [Credential()] + public PSCredential Credential { get; set; } + + [Parameter()] + [ValidateSet("a","b","c")] + public string p1 { get; set; } + + protected override void BeginProcessing() { + WriteVerbose(Runspace.DefaultRunspace.Name); + PSObject p = new PSObject(DateTime.Now); + WriteVerbose(p.Properties["DateTime"].ToString()); + } + protected override void EndProcessing() { + WriteObject("Success!"); + } + } +} diff --git a/test/5/full/PSS5.Tests.ps1 b/test/5/full/PSS5.Tests.ps1 new file mode 100644 index 0000000..818ec7a --- /dev/null +++ b/test/5/full/PSS5.Tests.ps1 @@ -0,0 +1,242 @@ +Describe 'PowerShell Standard 5 - Full CLR' { + + BeforeAll { + $repoRoot = git rev-parse --show-toplevel + $libraryPath = "${repoRoot}/src/5/bin/Release/net452/System.Management.Automation.dll" + $assemblyExists = test-path $libraryPath + if ( $assemblyExists ) { + $standardAssembly = [System.Reflection.Assembly]::LoadFile($libraryPath) + } + } + + Context 'Creating a cmdlet' { + BeforeAll { + $cmdletAssembly = 'bin/Release/net452/Demo.Cmdlet.dll' + $assemblyPath = Join-Path "$PSScriptRoot" $cmdletAssembly + $PSBin = (Get-Process -id $PID).MainModule.FileName + } + It 'Can build a reference assembly' { + try { + Push-Location $PSScriptRoot + dotnet restore + dotnet build --configuration Release + $assemblyPath | Should -Exist + } + finally { + Pop-Location + } + } + It 'Can execute the compiled cmdlet' { + $result = & $PSBin -c "import-module $assemblyPath; Get-Thing" + $result | Should -Be 'success!' + } + } + + Context 'Reflection tests' { + + $testCases = @{ + Name = "Issue 52: ValidateArgumentsAttribute.Validate method is not abstract" + ScriptBlock = { + $t = $standardAssembly.GetType('System.Management.Automation.ValidateArgumentsAttribute') + $m = $t.GetMember('Validate','Public,NonPublic,Instance,Static,DeclaredOnly') + $m.IsAbstract |Should -Be $true + } + }, + @{ + Name = "Issue 50: PSEventUnsubscribedEventHander argument type should be PSEventUnsubscribedEventArgs" + ScriptBlock = { + $t = $standardAssembly.GetType('System.Management.Automation.PSEventUnsubscribedEventHandler') + $m = $t.GetMethod('Invoke') + $parameters = $m.GetParameters() + $parameters[1].ParameterType.FullName | Should -Be 'System.Management.Automation.PSEventUnsubscribedEventArgs' + } + }, + @{ + Name = "Issue 44: FunctionMemberAst.Parameters should be accessible" + ScriptBlock = { + $t = $standardAssembly.GetType('System.Management.Automation.Language.FunctionMemberAst') + $p = $t.GetProperty('Parameters') + $p.GetMethod.IsPublic | Should -Be $true + } + }, + @{ + Name = "Issue 42: Runspace.Default should not contain public CreateNestedPipeline" + ScriptBlock = { + $t = $standardAssembly.GetType('System.Management.Automation.Runspaces.Runspace') + $t.GetMembers('Public,NonPublic,Instance,Static')|?{$_.Name -match 'CreatedNestedPipeline'}|Should -BeNullOrEmpty + } + }, + @{ + Name = "Issue 36: PSMemberInfo.Copy is marked 'virtual' but should be 'abstract'" + ScriptBlock = { + $t = $standardAssembly.GetType('System.Management.Automation.PSMemberInfo') + $m = $t.GetMethod('Copy') + $m.IsAbstract | Should -Be $true + } + }, + @{ + Name = "Issue 26: Several properties missing from CmdletProvider (also issue 14)" + ScriptBlock = { + $t = $standardAssembly.GetType('System.Management.Automation.Provider.CmdletProvider') + $t.GetProperty('CurrentPSTransaction') | Should -Not -BeNullOrEmpty + $t.GetProperty('DynamicParameters',[Reflection.BindingFlags]'NonPublic,Instance') | Should -Not -BeNullOrEmpty + $t.GetProperty('PSDriveInfo',[Reflection.BindingFlags]'NonPublic,Instance') | Should -Not -BeNullOrEmpty + $t.GetProperty('ProviderInfo',[Reflection.BindingFlags]'NonPublic,Instance') | Should -Not -BeNullOrEmpty + } + }, + @{ + Name = "Issue 19: SetJobState missing from Job class" + ScriptBlock = { + $t = $standardAssembly.GetType('System.Management.Automation.Job') + $t.GetMethod('SetJobState',[System.Reflection.BindingFlags]'NonPublic,Instance') | Should -Not -BeNullOrEmpty + } + }, + @{ + Name = "Issue 18: Debugger does not contain protected parameterless constructor" + ScriptBlock = { + $t = $standardAssembly.GetType('System.Management.Automation.Debugger') + # no public constructors + $t.GetConstructors().Count | Should -Be 0 + # one protected, parameterless constructor + $constructor = $t.GetConstructors('NonPublic,Instance') + @($constructor).Count | Should -Be 1 + $constructor.IsFamily | Should -Be $true + $constructor.GetParameters().Count | Should -Be 0 + } + }, + @{ + Name = "Issue 17: ScriptExtent does not inherit IScriptExtent" + ScriptBlock = { + $t = $standardAssembly.GetType('System.Management.Automation.Language.ScriptExtent') + $t.GetInterface('System.Management.Automation.Language.IScriptExtent')|Should -Not -BeNullOrEmpty + } + }, + @{ + Name = "Issue 16: ICustomAstVistor2 does not inherit ICustomAstVistor" + ScriptBlock = { + $t = $standardAssembly.GetType('System.Management.Automation.Language.ICustomAstVisitor2') + $t.GetInterface('System.Management.Automation.Language.ICustomAstVisitor')|Should -Not -BeNullOrEmpty + } + }, + @{ + Name = "Issue 11: Missing cmdletization types" + ScriptBlock = { + $typeList = 'Microsoft.PowerShell.Cmdletization.BehaviorOnNoMatch', + 'Microsoft.PowerShell.Cmdletization.CmdletAdapter`1', + 'Microsoft.PowerShell.Cmdletization.MethodInvocationInfo', 'Microsoft.PowerShell.Cmdletization.MethodParameter', + 'Microsoft.PowerShell.Cmdletization.MethodParameterBindings', + 'Microsoft.PowerShell.Cmdletization.QueryBuilder', + 'Microsoft.PowerShell.Cmdletization.Xml.ConfirmImpact', 'Microsoft.PowerShell.Cmdletization.Xml.ItemsChoiceType' + foreach ( $t in $typeList ) { + $standardAssembly.GetType($t) | Should -Not -BeNullOrEmpty + } + } + }, + @{ + Name = "Issue 8: DefaultRunspace should be a static property" + ScriptBlock = { + $t = $standardAssembly.GetType('System.Management.Automation.Runspaces.Runspace') + $p = $t.GetProperty('DefaultRunspace',[System.Reflection.BindingFlags]'Public,Static') + $p | Should -Not -BeNullOrEmpty + } + }, + @{ + Name = "Issue 7: params keyword is left out for array type parameters" + ScriptBlock = { + $t = $standardAssembly.GetType('System.Management.Automation.OutputTypeAttribute') + foreach ($c in $t.GetConstructors()) { + $c.GetParameters()[-1].CustomAttributes.AttributeType.FullName | Should -Be System.ParamArrayAttribute + } + } + }, + @{ + Name = "Issue 6: PSObject.Properties is using int instead of string" + ScriptBlock = { + $t = $standardAssembly.GetType('System.Management.Automation.PSObject') + $p = $t.GetProperty('Properties') + $p.PropertyType.GetMember('Item').GetIndexParameters().ParameterType.FullName | Should -Be 'System.String' + } + }, + @{ + Name = "Issue 4: CreatePipeline should not be available" + ScriptBlock = { + $t = $standardAssembly.GetType('System.Management.Automation.Runspaces.Runspace') + $t.GetMembers('Public,NonPublic,Instance,Static')|?{$_.Name -match 'CreatePipeline'} | Should -BeNullOrEmpty + } + } + + It '' -testcases $testCases -skip:(! $assemblyExists) { + param ( [string]$name, [scriptblock]$ScriptBlock ) + & ${ScriptBlock} + } + } + + Context 'The type list is expected' { + BeforeAll { + $smaT = [psobject].assembly.GetTypes()|?{$_.IsPublic}|Sort-Object FullName + $asmT = $standardAssembly.GetTypes()|?{$_.IsPublic}|Sort-Object FullName + # These are the types which we expect to not be in the standard library + $expectedMissingTypes = @{ Name = 'Microsoft.PowerShell.ProcessCodeMethods' }, + @{ Name = 'Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute' }, + @{ Name = 'Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscRemoteOperationsClass' }, + @{ Name = 'Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache' }, + @{ Name = 'Microsoft.PowerShell.Commands.GetExperimentalFeatureCommand' }, + @{ Name = 'Microsoft.PowerShell.Commands.PSPropertyExpressionResult' }, + @{ Name = 'Microsoft.PowerShell.Commands.PSPropertyExpression' }, + @{ Name = 'Microsoft.PowerShell.Commands.UpdateHelpScope' }, + @{ Name = 'Microsoft.PowerShell.CoreClr.Stubs.AuthenticationLevel' }, + @{ Name = 'Microsoft.PowerShell.CoreClr.Stubs.ImpersonationLevel' }, + @{ Name = 'System.Management.Automation.PowerShellAssemblyLoadContextInitializer' }, + @{ Name = 'System.Management.Automation.Platform' }, + @{ Name = 'System.Management.Automation.ValidateRangeKind' }, + @{ Name = 'System.Management.Automation.CachedValidValuesGeneratorBase' }, + @{ Name = 'System.Management.Automation.IValidateSetValuesGenerator' }, + @{ Name = 'System.Management.Automation.ArgumentCompletionsAttribute' }, + @{ Name = 'System.Management.Automation.GetSymmetricEncryptionKey' }, + @{ Name = 'System.Management.Automation.StartRunspaceDebugProcessingEventArgs' }, + @{ Name = 'System.Management.Automation.ProcessRunspaceDebugEndEventArgs' }, + @{ Name = 'System.Management.Automation.ExperimentalFeature' }, + @{ Name = 'System.Management.Automation.ExperimentAction' }, + @{ Name = 'System.Management.Automation.ExperimentalAttribute' }, + @{ Name = 'System.Management.Automation.PSSnapInSpecification' }, + @{ Name = 'System.Management.Automation.PSParseError' }, + @{ Name = 'System.Management.Automation.PSParser' }, + @{ Name = 'System.Management.Automation.PSToken' }, + @{ Name = 'System.Management.Automation.PSTokenType' }, + @{ Name = 'System.Management.Automation.TypeInferenceRuntimePermissions' }, + @{ Name = 'System.Management.Automation.PSVersionHashTable' }, + @{ Name = 'System.Management.Automation.SemanticVersion' }, + @{ Name = 'System.Management.Automation.LocationChangedEventArgs' }, + @{ Name = 'System.Management.Automation.WorkflowInfo' }, + @{ Name = 'System.Management.Automation.PSSnapInInfo' }, + @{ Name = 'System.Management.Automation.VerbInfo' }, + @{ Name = 'System.Management.Automation.Remoting.WSMan.WSManServerChannelEvents' }, + @{ Name = 'System.Management.Automation.Remoting.WSMan.ActiveSessionsChangedEventArgs' }, + @{ Name = 'System.Management.Automation.Runspaces.PipelineStateInfo' }, + @{ Name = 'System.Management.Automation.Runspaces.PipelineStateEventArgs' }, + @{ Name = 'System.Management.Automation.Runspaces.Pipeline' }, + @{ Name = 'System.Management.Automation.Runspaces.PowerShellProcessInstance' }, + @{ Name = 'System.Management.Automation.Runspaces.SSHConnectionInfo' }, + @{ Name = 'System.Management.Automation.Runspaces.VMConnectionInfo' }, + @{ Name = 'System.Management.Automation.Runspaces.PSSnapInException' }, + @{ Name = 'System.Management.Automation.Runspaces.PipelineReader`1' }, + @{ Name = 'System.Management.Automation.Runspaces.PipelineWriter' }, + @{ Name = 'System.Management.Automation.Tracing.EtwActivity' }, + @{ Name = 'System.Management.Automation.Tracing.PowerShellTraceTask' }, + @{ Name = 'System.Management.Automation.Tracing.PowerShellTraceKeywords' }, + @{ Name = 'System.Management.Automation.Tracing.Tracer' }, + @{ Name = 'System.Management.Automation.Tracing.PowerShellTraceSource' }, + @{ Name = 'System.Management.Automation.Tracing.PowerShellTraceSourceFactory' }, + @{ Name = 'System.Management.Automation.Internal.TransactionParameters' } + } + + It "There should be no types in standard which are not in the product" -skip:(! $assemblyExists) { + Compare-Object -reference $smaT -difference $asmT | ?{$_.SideIndicator -eq '=>' } | Should -BeNullOrEmpty + } + + It " should not be in the standard library" -skip:(! $assemblyExists) -testcase $expectedMissingTypes { + param ( $Name ) + $Name | Should -BeIn @($expectedMissingTypes.Values) + } + } +} diff --git a/test/5/full/PSStandard.csproj b/test/5/full/PSStandard.csproj new file mode 100644 index 0000000..a6f3584 --- /dev/null +++ b/test/5/full/PSStandard.csproj @@ -0,0 +1,12 @@ + + + + net452 + Demo.Cmdlet + + + + + + + diff --git a/test/Build.Tests.ps1 b/test/Build.Tests.ps1 new file mode 100644 index 0000000..b500ba7 --- /dev/null +++ b/test/Build.Tests.ps1 @@ -0,0 +1,13 @@ +Describe "Ensure that the created file versions match what is in the Signing.xml file" { + BeforeAll { + $baseDir = Resolve-Path (Join-Path $PsScriptRoot "..") + $signingFilePath = Join-Path $baseDir "tools/releaseBuild/signing.xml" + $signingXml = [xml](Get-Content $signingFilePath) + $testCases = $signingXml.SelectNodes(".//file").src | + Foreach-Object { @{ FileName = $_.split(([char[]]"/\"))[-1] } } + } + It "the file '' should exist" -testcases $testCases { + param ( $FileName ) + "$baseDir/$fileName" | Should -Exist + } +} diff --git a/tools/releaseBuild/Image/DockerFile b/tools/releaseBuild/Image/DockerFile index 096c625..628a262 100644 --- a/tools/releaseBuild/Image/DockerFile +++ b/tools/releaseBuild/Image/DockerFile @@ -1,6 +1,6 @@ # escape=` #0.3.6 (no powershell 6) -FROM microsoft/dotnet-framework:4.7.1 +FROM microsoft/dotnet-framework:4.7.2-sdk LABEL maintainer='PowerShell Team ' LABEL description="This Dockerfile for Windows Server Core with git installed via chocolatey." @@ -23,8 +23,10 @@ RUN Import-Module PackageManagement; ` # git clone https://Github.com/PowerShell/PSScriptAnalyzer; ` # Install-ChocolateyPackage -PackageName dotnet4.5; -# RUN Import-Module ./containerFiles/dockerInstall.psm1; ` # Install-ChocolateyPackage -PackageName netfx-4.5.1-devpack; +#RUN Import-Module ./containerFiles/dockerInstall.psm1; ` +# Install-ChocolateyPackage -PackageName netfx-4.7.2-devpack; ` +# Install-ChocolateyPackage -PackageName dotnetfx; COPY buildStandard.ps1 containerFiles/buildStandard.ps1 diff --git a/tools/releaseBuild/signing.xml b/tools/releaseBuild/signing.xml index adcd83b..ca58860 100644 --- a/tools/releaseBuild/signing.xml +++ b/tools/releaseBuild/signing.xml @@ -2,11 +2,11 @@ - - + - +