This repository was archived by the owner on Jun 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 133
Expand file tree
/
Copy pathPublish-PSResource.ps1
More file actions
149 lines (128 loc) · 5.02 KB
/
Publish-PSResource.ps1
File metadata and controls
149 lines (128 loc) · 5.02 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
function Publish-PSResource {
[OutputType([void])]
[Cmdletbinding(SupportsShouldProcess = $true)]
Param
(
# Specifies the name of the resource to be published.
[Parameter(Mandatory = $true,
ParameterSetName = "ModuleNameParameterSet",
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true)]
[ValidateNotNullOrEmpty()]
[string]
$Name,
# Specifies the path to the resource that you want to publish. This parameter accepts the path to the folder that contains the resource.
# Specifies a path to one or more locations. Wildcards are permitted. The default location is the current directory (.).
[Parameter(Mandatory = $true,
ParameterSetName = "ModulePathParameterSet",
ValueFromPipelineByPropertyName = $true)]
[Parameter(Mandatory = $true,
ParameterSetName = 'ScriptPathParameterSet',
ValueFromPipelineByPropertyName = $true)]
[ValidateNotNullOrEmpty()]
[string]
$Path,
# Specifies a path to one or more locations. Unlike the Path parameter, the value of the LiteralPath parameter is used exactly as entered.
# No characters are interpreted as wildcards. If the path includes escape characters, enclose them in single quotation marks.
# Single quotation marks tell PowerShell not to interpret any characters as escape sequences.
[Parameter(Mandatory = $true,
ParameterSetName = 'ModuleLiteralPathParameterSet',
ValueFromPipelineByPropertyName = $true)]
[Parameter(Mandatory = $true,
ParameterSetName = 'ScriptLiteralPathParameterSet',
ValueFromPipelineByPropertyName = $true)]
[Alias('PSPath')]
[ValidateNotNullOrEmpty()]
[string]
$LiteralPath,
# Can be used to publish the a nupkg locally.
[Parameter(Mandatory = $true,
ParameterSetName = 'DestinationPathParameterSet',
ValueFromPipelineByPropertyName = $true)]
[ValidateNotNullOrEmpty()]
[string]
$DestinationPath,
# Specifies the exact version of a single resource to publish.
[Parameter()]
[ValidateNotNullOrEmpty()]
[string]
$RequiredVersion,
# Specifies the API key that you want to use to publish a module to the online gallery.
[Parameter()]
[ValidateNotNullOrEmpty()]
[string]
$NuGetApiKey,
# Specifies the repository to publish to.
[Parameter()]
[ValidateNotNullOrEmpty()]
[string]
$Repository,
# Specifies a user account that has rights to a specific repository.
[Parameter(ValueFromPipelineByPropertyName = $true)]
[PSCredential]
$Credential,
# Specifies a string containing release notes or comments that you want to be available to users of this version of the resource.
[Parameter()]
[string[]]
$ReleaseNotes,
# Adds one or more tags to the resource that you are publishing.
[Parameter()]
[ValidateNotNullOrEmpty()]
[string[]]
$Tags,
# Specifies the URL of licensing terms for the resource you want to publish.
[Parameter()]
[ValidateNotNullOrEmpty()]
[Uri]
$LicenseUri,
# Specifies the URL of an icon for the resource.
[Parameter()]
[ValidateNotNullOrEmpty()]
[Uri]
$IconUri,
# Specifies the URL of a webpage about this project.
[Parameter()]
[ValidateNotNullOrEmpty()]
[Uri]
$ProjectUri,
# Excludes files from a nuspec
[Parameter(ParameterSetName = "ModuleNameParameterSet")]
[ValidateNotNullOrEmpty()]
[string[]]
$Exclude,
# Forces the command to run without asking for user confirmation.
[Parameter()]
[switch]
$Force,
# Allows resources marked as prerelease to be published.
[Parameter()]
[switch]
$Prerelease,
# Bypasses the default check that all dependencies are present.
[Parameter()]
[switch]
$SkipDependenciesCheck,
# Specifies a nuspec file rather than relying on this module to produce one.
[Parameter()]
[switch]
$Nuspec
)
begin { }
process {
if ($pscmdlet.ShouldProcess($Name)) {
if ($Name) {
# Publish module
Write-Verbose -message "Successfully published $Name"
}
elseif ($Path) {
# Publish resource
Write-Verbose -message "Successfully published $Path"
}
elseif ($LiteralPath) {
# Publish resource
Write-Verbose -message "Successfully published $LiteralPath"
}
}
}
end { }
}