|
1 | | -function New-PSMDBuildProject |
2 | | -{ |
3 | | - [CmdletBinding()] |
| 1 | +function New-PSMDBuildProject { |
| 2 | +<# |
| 3 | + .SYNOPSIS |
| 4 | + Create a new build project file. |
| 5 | + |
| 6 | + .DESCRIPTION |
| 7 | + Create a new build project file. |
| 8 | + Build projects are used to configure a repeatable, managed set of steps that make up a workflow. |
| 9 | + It is designed with software build processes in mind, but can be used for pretty much anything that works in separate steps. |
| 10 | + |
| 11 | + See the help on Invoke-PSMDBuildProject for more details. |
| 12 | + |
| 13 | + NOTE: This is not the tool or component to create new PowerShell _code_ projects / repositories! |
| 14 | + To create a new PowerShell module project, instead run: |
| 15 | + |
| 16 | + Invoke-PSMDTemplate PSFProject |
| 17 | + |
| 18 | + .PARAMETER Name |
| 19 | + The name of the build project. |
| 20 | + |
| 21 | + .PARAMETER Path |
| 22 | + The path to the folder in which the build project file is created. |
| 23 | + Final path will be: "<Path>\<Name>.build.json" |
| 24 | + |
| 25 | + .PARAMETER Condition |
| 26 | + A condition - a filter expression - that must be met in order for the build to proceed. |
| 27 | + For more details on filter conditions, see the PSFramework documentation on its feature: |
| 28 | + https://psframework.org/documentation/documents/psframework/filters.html |
| 29 | + |
| 30 | + .PARAMETER ConditionSet |
| 31 | + The name of the condition set to use. |
| 32 | + This is part of the PSFramework filter system: |
| 33 | + https://psframework.org/documentation/documents/psframework/filters.html |
| 34 | + |
| 35 | + Specify as "<module> <conditionsetname>" format. |
| 36 | + Default Value: PSFramework Environment |
| 37 | + |
| 38 | + .PARAMETER NoSelect |
| 39 | + Do not select the newly created build project as the default project for the current session. |
| 40 | + By default, the newly created build project will be set as default project, in order to facilitate adding steps to it. |
| 41 | + Use Select-PSMDBuildProject to explicitly set a default project file. |
| 42 | + |
| 43 | + .PARAMETER Register |
| 44 | + Persist the newly created build project as default build project beyond the current session. |
| 45 | + By default, the newly created build project will already be set as default project, in order to facilitate adding steps to it. |
| 46 | + But ONLY for the current session. This parameter makes it remember in new PowerShell sessions as well. |
| 47 | + |
| 48 | + .EXAMPLE |
| 49 | + PS C:\> New-PSMDBuildProject -Name 'VMDeployment' -Path 'C:\Code\VMDeployment' |
| 50 | + |
| 51 | + Create a new build project named 'VMDeployment' in the folder 'C:\Code\VMDeployment' |
| 52 | +#> |
| 53 | + [CmdletBinding(DefaultParameterSetName = 'default')] |
4 | 54 | param ( |
5 | 55 | [Parameter(Mandatory = $true)] |
6 | 56 | [string] |
|
17 | 67 | [string] |
18 | 68 | $ConditionSet = 'PSFramework Environment', |
19 | 69 |
|
| 70 | + [Parameter(ParameterSetName = 'NoSelect')] |
20 | 71 | [switch] |
21 | 72 | $NoSelect, |
22 | 73 |
|
| 74 | + [Parameter(ParameterSetName = 'Register')] |
23 | 75 | [switch] |
24 | 76 | $Register |
25 | 77 | ) |
26 | 78 |
|
27 | | - process |
28 | | - { |
| 79 | + process { |
29 | 80 | $project = [pscustomobject]@{ |
30 | | - Name = $Name |
31 | | - Condition = $Condition |
| 81 | + Name = $Name |
| 82 | + Condition = $Condition |
32 | 83 | ConditionSet = $ConditionSet |
33 | | - Steps = @() |
| 84 | + Steps = @() |
34 | 85 | } |
35 | 86 | $outPath = Join-Path -Path $Path -ChildPath "$Name.build.Json" |
36 | | - $project | ConvertTo-Json -Depth 10 | Set-Content -Path $outPath -Encoding UTF8 -ErrorAction Stop |
| 87 | + $project | Export-PsmdBuildProjectFile -OutPath $outPath -ErrorAction Stop |
37 | 88 | if (-not $NoSelect) { |
38 | 89 | Set-PSFConfig -Module PSModuleDevelopment -Name 'Build.Project.Selected' -Value $outPath |
39 | 90 | if ($Register) { Register-PSFConfig -Module PSModuleDevelopment -Name 'Build.Project.Selected' } |
|
0 commit comments