Skip to content

Commit 8a52a54

Browse files
Merge pull request #11 from PowershellFrameworkCollective/development
2.1.1.3
2 parents 01eff11 + e65eac6 commit 8a52a54

File tree

6 files changed

+147
-4
lines changed

6 files changed

+147
-4
lines changed

PSModuleDevelopment/PSModuleDevelopment.psd1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
RootModule = 'PSModuleDevelopment.psm1'
55

66
# Version number of this module.
7-
ModuleVersion = '2.1.0.1'
7+
ModuleVersion = '2.1.1.3'
88

99
# ID used to uniquely identify this module
1010
GUID = '37dd5fce-e7b5-4d57-ac37-832055ce49d6'
@@ -41,7 +41,7 @@
4141

4242
# Modules that must be imported into the global environment prior to importing
4343
# this module
44-
RequiredModules = @(@{ ModuleName='PSFramework'; ModuleVersion= '0.9.8.17' })
44+
RequiredModules = @(@{ ModuleName='PSFramework'; ModuleVersion= '0.9.9.19' })
4545

4646
# Assemblies that must be loaded prior to importing this module
4747
RequiredAssemblies = @('bin\PSModuleDevelopment.dll')
@@ -74,6 +74,7 @@
7474
'New-PSMDDotNetProject',
7575
'New-PSMDHeader',
7676
'New-PSMDFormatTableDefinition',
77+
'New-PSMDModuleNugetPackage',
7778
'New-PssModuleProject',
7879
'Remove-PSMDModuleDebug',
7980
'Rename-PSMDParameter',

PSModuleDevelopment/PSModuleDevelopment.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
$script:PSModuleRoot = $PSScriptRoot
2-
$script:PSModuleVersion = "2.1.0.1"
2+
$script:PSModuleVersion = "2.1.1.3"
33

44
$script:doDotSource = $false
55
if (Get-PSFConfigValue -Name PSModuleDevelopment.Import.DoDotSource) { $script:doDotSource = $true }

PSModuleDevelopment/PSModuleDevelopment.psproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<Folder>internal\tabcompletion</Folder>
2828
<Folder>internal\tabcompletion\scriptblocks</Folder>
2929
<Folder>internal\maintenance</Folder>
30+
<Folder>internal\tabcompletion\assignment</Folder>
3031
</Folders>
3132
<Files>
3233
<File Build="2">PSModuleDevelopment.psd1</File>
@@ -80,6 +81,7 @@
8081
<File Build="2" Shared="True" ReferenceFunction="Invoke-dotNetTemplatesUninstall_ps1">internal\tabcompletion\scriptblocks\dotNetTemplatesUninstall.ps1</File>
8182
<File Build="2" Shared="True" ReferenceFunction="Invoke-dotNetTemplateCache_ps1">internal\maintenance\dotNetTemplateCache.ps1</File>
8283
<File Build="2" Shared="True" ReferenceFunction="Invoke-dotNetTemplatesInstall_ps1">internal\tabcompletion\scriptblocks\dotNetTemplatesInstall.ps1</File>
84+
<File Build="2" Shared="True" ReferenceFunction="Invoke-New-PSMDModuleNugetPackage_ps1">functions\utility\New-PSMDModuleNugetPackage.ps1</File>
8385
</Files>
8486
<StartupScript>F:\Synchronized Data\Scripte\Powershell Studio\Projects\PSModuleDevelopment\Test-Module.ps1</StartupScript>
8587
</Project>

PSModuleDevelopment/en-us/about_psmoduledevelopment.help.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ LONG DESCRIPTION
165165
# Changelog #
166166
#-------------------------------------------------------------------------#
167167

168+
2.1.1.3 (February 06th, 2018)
169+
- new: Command New-PSMDModuleNugetPackage
170+
A command that takes a module and writes it to a Nuget package.
171+
- Upd: Increased PSFramework required version to 0.9.9.19
172+
168173
2.1.0.1 (January 24th, 2018)
169174
- new: Included suite of tests, in order to provide a more reliable user
170175
experience.
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
function New-PSMDModuleNugetPackage
2+
{
3+
<#
4+
.SYNOPSIS
5+
Creates a nuget package from a PowerShell module.
6+
7+
.DESCRIPTION
8+
This function will take a module and wrap it into a nuget package.
9+
This is accomplished by creating a temporary local filesystem repository and using the PowerShellGet module to do the actual writing.
10+
11+
Note:
12+
- Requires PowerShellGet module
13+
- Dependencies must be built first to the same folder
14+
15+
.PARAMETER ModulePath
16+
Path to the PowerShell module you are creating a Nuget package from
17+
18+
.PARAMETER PackagePath
19+
Path where the package file will be copied.
20+
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
27+
28+
Packages the module stored in .\DBOps and stores the nuget file in 'c:\temp\package'
29+
30+
.NOTES
31+
Author: Mark Wilkinson
32+
Editor: Friedrich Weinmann
33+
#>
34+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "")]
35+
[CmdletBinding()]
36+
param (
37+
[Parameter(mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
38+
[Alias('ModuleBase')]
39+
[string[]]
40+
$ModulePath,
41+
42+
[string]
43+
$PackagePath = (Get-PSFConfigValue -FullName 'PSModuleDevelopment.Package.Path' -Fallback "$env:TEMP"),
44+
45+
[switch]
46+
$EnableException
47+
)
48+
49+
begin
50+
{
51+
Write-PSFMessage -Level InternalComment -Message "Bound Parameters: $($PSBoundParameters.Keys -join ",")"
52+
53+
#region Input validation and prerequisites check
54+
try
55+
{
56+
$null = Get-Command Publish-Module -ErrorAction Stop
57+
$null = Get-Command Register-PSRepository -ErrorAction Stop
58+
$null = Get-Command Unregister-PSRepository -ErrorAction Stop
59+
}
60+
catch
61+
{
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'
69+
}
70+
Stop-PSFFunction @paramStopPSFFunction
71+
return
72+
}
73+
74+
if (-not (Test-Path $PackagePath))
75+
{
76+
Write-PSFMessage -Level Verbose -Message "Creating path: $PackagePath" -Tag 'begin', 'create', 'path'
77+
try { $null = New-Item -Path $PackagePath -ItemType Directory -Force -ErrorAction Stop }
78+
catch
79+
{
80+
Stop-PSFFunction -Message "Failed to create output path: $PackagePath" -ErrorRecord $_ -EnableException $EnableException -Tag 'fail', 'bgin', 'create', 'path'
81+
return
82+
}
83+
}
84+
#endregion Input validation and prerequisites check
85+
86+
#region Prepare local Repository
87+
try
88+
{
89+
$paramRegisterPSRepository = @{
90+
Name = 'PSModuleDevelopment_TempLocalRepository'
91+
PublishLocation = $PackagePath
92+
SourceLocation = $PackagePath
93+
InstallationPolicy = 'Trusted'
94+
ErrorAction = 'Stop'
95+
}
96+
97+
Register-PSRepository @paramRegisterPSRepository
98+
}
99+
catch
100+
{
101+
Stop-PSFFunction -Message "Failed to create temporary PowerShell Repository" -ErrorRecord $_ -EnableException $EnableException -Tag 'fail', 'bgin', 'create', 'path'
102+
return
103+
}
104+
#endregion Prepare local Repository
105+
}
106+
process
107+
{
108+
if (Test-PSFFunctionInterrupt) { return }
109+
#region Process Paths
110+
foreach ($Path in $ModulePath)
111+
{
112+
Write-PSFMessage -Level VeryVerbose -Message "Starting to package: $Path" -Tag 'progress', 'developer' -Target $Path
113+
114+
if (-not (Test-Path $Path))
115+
{
116+
Stop-PSFFunction -Message "Path not found: $Path" -EnableException $EnableException -Category InvalidArgument -Tag 'progress', 'developer', 'fail' -Target $Path -Continue
117+
}
118+
119+
try { Publish-Module -Path $Path -Repository 'PSModuleDevelopment_TempLocalRepository' -ErrorAction Stop -Force }
120+
catch
121+
{
122+
Stop-PSFFunction -Message "Failed to publish module: $Path" -EnableException $EnableException -ErrorRecord $_ -Tag 'progress', 'developer', 'fail' -Target $Path -Continue
123+
}
124+
125+
Write-PSFMessage -Level Verbose -Message "Finished processing: $Path" -Tag 'progress', 'developer' -Target $Path
126+
}
127+
#endregion Process Paths
128+
}
129+
end
130+
{
131+
Unregister-PSRepository -Name 'PSModuleDevelopment_TempLocalRepository' -ErrorAction Ignore
132+
if (Test-PSFFunctionInterrupt) { return }
133+
}
134+
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
Set-PSFConfig -Module PSModuleDevelopment -Name "Module.Path" -Value "" -Initialize -Validation "string" -Handler { } -Description "The path to the module currently under development. Used as default path by commnds that work within a module directory."
1+
Set-PSFConfig -Module PSModuleDevelopment -Name "Module.Path" -Value "" -Initialize -Validation "string" -Handler { } -Description "The path to the module currently under development. Used as default path by commnds that work within a module directory."
2+
Set-PSFConfig -Module PSModuleDevelopment -Name 'Package.Path' -Value "$env:TEMP" -Initialize -Validation "string" -Description "The default output path when exporting a module into a nuget package."

0 commit comments

Comments
 (0)