|
2 | 2 | {
|
3 | 3 | <#
|
4 | 4 | .SYNOPSIS
|
5 |
| - Creates a nuget package from a PowerShell module. |
| 5 | + Creates a nuget package from a PowerShell module. |
6 | 6 |
|
7 | 7 | .DESCRIPTION
|
8 | 8 | This function will take a module and wrap it into a nuget package.
|
9 | 9 | This is accomplished by creating a temporary local filesystem repository and using the PowerShellGet module to do the actual writing.
|
10 |
| - |
| 10 | + |
11 | 11 | Note:
|
12 | 12 | - Requires PowerShellGet module
|
13 | 13 | - Dependencies must be built first to the same folder
|
14 |
| -
|
| 14 | + |
15 | 15 | .PARAMETER ModulePath
|
16 |
| - Path to the PowerShell module you are creating a Nuget package from |
| 16 | + Path to the PowerShell module you are creating a Nuget package from |
17 | 17 |
|
18 | 18 | .PARAMETER PackagePath
|
19 |
| - Path where the package file will be copied. |
| 19 | + Path where the package file will be copied. |
20 | 20 |
|
21 | 21 | .PARAMETER EnableException
|
22 |
| - Replaces user friendly yellow warnings with bloody red exceptions of doom! |
23 |
| - Use this if you want the function to throw terminating errors you want to catch. |
24 |
| -
|
25 |
| - .EXAMPLE |
26 |
| - New-PSMDModuleNugetPackage -PackagePath 'c:\temp\package' -ModulePath .\DBOps |
| 22 | + Replaces user friendly yellow warnings with bloody red exceptions of doom! |
| 23 | + Use this if you want the function to throw terminating errors you want to catch. |
27 | 24 |
|
| 25 | + .EXAMPLE |
| 26 | + New-PSMDModuleNugetPackage -PackagePath 'c:\temp\package' -ModulePath .\DBOps |
| 27 | + |
28 | 28 | Packages the module stored in .\DBOps and stores the nuget file in 'c:\temp\package'
|
29 | 29 |
|
30 | 30 | .NOTES
|
|
60 | 60 | catch
|
61 | 61 | {
|
62 | 62 | $paramStopPSFFunction = @{
|
63 |
| - Message = "Failed to detect the PowerShellGet module! The module is required in order to execute this function." |
64 |
| - EnableException = $EnableException |
65 |
| - Category = 'NotInstalled' |
66 |
| - ErrorRecord = $_ |
67 |
| - OverrideExceptionMessage = $true |
68 |
| - Tag = 'fail', 'validation', 'prerequisites', 'module' |
| 63 | + Message = "Failed to detect the PowerShellGet module! The module is required in order to execute this function." |
| 64 | + EnableException = $EnableException |
| 65 | + Category = 'NotInstalled' |
| 66 | + ErrorRecord = $_ |
| 67 | + OverrideExceptionMessage = $true |
| 68 | + Tag = 'fail', 'validation', 'prerequisites', 'module' |
69 | 69 | }
|
70 | 70 | Stop-PSFFunction @paramStopPSFFunction
|
71 | 71 | return
|
|
87 | 87 | try
|
88 | 88 | {
|
89 | 89 | $paramRegisterPSRepository = @{
|
90 |
| - Name = 'PSModuleDevelopment_TempLocalRepository' |
91 |
| - PublishLocation = $PackagePath |
92 |
| - SourceLocation = $PackagePath |
93 |
| - InstallationPolicy = 'Trusted' |
94 |
| - ErrorAction = 'Stop' |
| 90 | + Name = 'PSModuleDevelopment_TempLocalRepository' |
| 91 | + PublishLocation = $PackagePath |
| 92 | + SourceLocation = $PackagePath |
| 93 | + InstallationPolicy = 'Trusted' |
| 94 | + ErrorAction = 'Stop' |
95 | 95 | }
|
96 | 96 |
|
97 | 97 | Register-PSRepository @paramRegisterPSRepository
|
|
109 | 109 | #region Process Paths
|
110 | 110 | foreach ($Path in $ModulePath)
|
111 | 111 | {
|
112 |
| - Write-PSFMessage -Level VeryVerbose -Message "Starting to package: $Path" -Tag 'progress','developer' -Target $Path |
| 112 | + Write-PSFMessage -Level VeryVerbose -Message "Starting to package: $Path" -Tag 'progress', 'developer' -Target $Path |
113 | 113 |
|
114 | 114 | if (-not (Test-Path $Path))
|
115 | 115 | {
|
116 |
| - Stop-PSFFunction -Message "Path not found: $Path" -EnableException $EnableException -Category InvalidArgument -Tag 'progress','developer','fail' -Target $Path -Continue |
| 116 | + Stop-PSFFunction -Message "Path not found: $Path" -EnableException $EnableException -Category InvalidArgument -Tag 'progress', 'developer', 'fail' -Target $Path -Continue |
117 | 117 | }
|
118 | 118 |
|
119 | 119 | try { Publish-Module -Path $Path -Repository 'PSModuleDevelopment_TempLocalRepository' -ErrorAction Stop -Force }
|
|
122 | 122 | Stop-PSFFunction -Message "Failed to publish module: $Path" -EnableException $EnableException -ErrorRecord $_ -Tag 'progress', 'developer', 'fail' -Target $Path -Continue
|
123 | 123 | }
|
124 | 124 |
|
125 |
| - Write-PSFMessage -Level Verbose -Message "Finished processing: $Path" -Tag 'progress','developer' -Target $Path |
| 125 | + Write-PSFMessage -Level Verbose -Message "Finished processing: $Path" -Tag 'progress', 'developer' -Target $Path |
126 | 126 | }
|
127 | 127 | #endregion Process Paths
|
128 | 128 | }
|
|
0 commit comments