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