|
1 | 1 | [](https://ci.appveyor.com/project/MartinPugh/psmodulebuild) |
2 | 2 |
|
3 | | -#TOPIC |
4 | | - Building PowerShell Modules with PSModuleBuild |
| 3 | +# TOPIC |
5 | 4 |
|
6 | | -#SHORT DESCRIPTION |
7 | | - Creating a PowerShell module can be hard, and maintaining it can be even harder. PSModuleBuild has been designed to make |
8 | | - both tasks easier. In short, you put all of your advanced functions into individual .ps1 files and then invoke PSModuleBuild |
9 | | - and let it collect all the functions into a PowerShell module file (.psm1) and create the PowerShell module manifest |
10 | | - file (.psd1). |
| 5 | +Building PowerShell Modules with PSModuleBuild |
| 6 | + |
| 7 | +# SHORT DESCRIPTION |
| 8 | +Creating a PowerShell module can be hard, and maintaining it can be even harder. PSModuleBuild has been designed to make both tasks easier. In short, you put all of your advanced functions into individual .ps1 files and then invoke PSModuleBuild and let it collect all the functions into a PowerShell module file (.psm1) and create the PowerShell module manifest file (.psd1). |
11 | 9 |
|
12 | | -#DETAILED DESCRIPTION |
| 10 | +# DETAILED DESCRIPTION |
13 | 11 |
|
14 | | - Installation |
15 | | - ============ |
16 | | - Use the PowerShell Gallery to install PSModuleBuild: |
| 12 | +Installation |
| 13 | +============ |
| 14 | +Use the PowerShell Gallery to install PSModuleBuild: |
17 | 15 |
|
18 | 16 | Install-Module PSModuleBuild |
19 | 17 | Import-Module PSModuleBuild |
20 | 18 |
|
21 | 19 |
|
22 | | - Continuous Integration/Continuous Deployment Support |
23 | | - ==================================================== |
24 | | - I tried to make PSModuleBuild friendly to CI/CD, specifically some of the community accepted standards for CI like |
25 | | - Pester, Psake, etc. by putting in a filter that excludes files with certain keywords in them: |
| 20 | +Continuous Integration/Continuous Deployment Support |
| 21 | +==================================================== |
| 22 | +I tried to make PSModuleBuild friendly to CI/CD, specifically some of the community accepted standards for CI like Pester, Psake, etc. by putting in a filter that excludes files with certain keywords in them: |
26 | 23 |
|
27 | 24 | exclude |
28 | 25 | tests |
|
31 | 28 | \.psdeploy\. |
32 | 29 |
|
33 | 30 |
|
34 | | - Include.txt |
35 | | - =========== |
36 | | - If you have any scripts or cmdlets that need to be run at Import-Module time, you can put them in an Include.txt |
37 | | - file and PSModuleBuild will read this file first and put it in the module file first. This is not strictly needed |
38 | | - as PSModuleBuild will read in all .ps1 files and put them in but if you'd like to make sure these commands are run at |
39 | | - the beginning of the file you can. |
| 31 | +Include.txt |
| 32 | +=========== |
| 33 | +If you have any scripts or cmdlets that need to be run at Import-Module time, you can put them in an Include.txt file and PSModuleBuild will read this file first and put it in the module file first. This is not strictly needed as PSModuleBuild will read in all .ps1 files and put them in but if you'd like to make sure these commands are run at the beginning of the file you can. |
40 | 34 |
|
41 | | - Public/Private Functions |
42 | | - ======================== |
43 | | - PSModuleBuild will support public and private functions as well. In your project folder create a Public folder and a Private |
44 | | - folder and place your function files appropriately. |
| 35 | +Public/Private Functions |
| 36 | +======================== |
| 37 | +PSModuleBuild will support public and private functions as well. In your project folder create a Public folder and a Private folder and place your function files appropriately. |
45 | 38 |
|
46 | 39 |
|
47 | | -#EXAMPLES |
48 | | - Simple |
49 | | - ------ |
50 | | - Create a folder, put your function files in it. |
| 40 | +# EXAMPLES |
| 41 | + |
| 42 | +Simple |
| 43 | +------ |
| 44 | +Create a folder, put your function files in it. |
51 | 45 |
|
52 | 46 | Invoke-PSModuleBuild -Path c:\YourModule |
53 | 47 |
|
54 | | - This will read all of the function files in c:\YourModule and create a module named after the folder (YourModule). |
| 48 | +This will read all of the function files in c:\YourModule and create a module named after the folder (YourModule). |
55 | 49 |
|
56 | | - |
57 | | - Intermediate |
58 | | - ------------ |
59 | | - Same as simple, but you want to put more information in: |
| 50 | +Intermediate |
| 51 | +------------ |
| 52 | +Same as simple, but you want to put more information in: |
60 | 53 |
|
61 | 54 | $BuildSplat = @{ |
62 | 55 | Path = "c:\YourModule" |
|
70 | 63 | } |
71 | 64 | Invoke-PSModuleBuild @BuildSplat |
72 | 65 |
|
73 | | - This will create a new module, in a different location and fill the module manifest with the information. Invoke-PSModuleBuild |
74 | | - supports all of the parameters from New-ModuleManifest. |
| 66 | +This will create a new module, in a different location and fill the module manifest with the information. Invoke-PSModuleBuild supports all of the parameters from New-ModuleManifest. |
75 | 67 |
|
76 | 68 |
|
77 | | - Advanced - Additional supporting files |
78 | | - -------------------------------------- |
79 | | - If you have about files, or additional XML descriptor files, PSModuleBuild will support that. First create a project folder, |
80 | | - then create a source folder and place all of your function files in there. Now create another folder with the name of your |
81 | | - module (we'll use NewModule in this example) and place your about files, and other files there, in the proper folder structure |
82 | | - (en-US, etc). |
| 69 | +Advanced - Additional supporting files |
| 70 | +-------------------------------------- |
| 71 | +If you have about files, or additional XML descriptor files, PSModuleBuild will support that. First create a project folder, then create a source folder and place all of your function files in there. Now create another folder with the name of your module (we'll use NewModule in this example) and place your about files, and other files there, in the proper folder structure (en-US, etc). |
83 | 72 |
|
84 | 73 | $BuildSplat = @{ |
85 | 74 | Path = "c:\ProjectFolder\Source" |
|
94 | 83 | Invoke-PSModuleBuild @BuildSplat |
95 | 84 |
|
96 | 85 |
|
97 | | - Advanced - Include source files in the module |
98 | | - --------------------------------------------- |
99 | | - If you want to include the source function files in your module create a project folder, then create a folder with |
100 | | - the name of your project and place all your function files (and other supporting files) in it. |
| 86 | +Advanced - Include source files in the module |
| 87 | +--------------------------------------------- |
| 88 | +If you want to include the source function files in your module create a project folder, then create a folder with the name of your project and place all your function files (and other supporting files) in it. |
101 | 89 |
|
102 | 90 | $BuildSplat = @{ |
103 | 91 | Path = "c:\ProjectFolder\NewModule" |
|
112 | 100 | Invoke-PSModuleBuild @BuildSplat |
113 | 101 |
|
114 | 102 |
|
115 | | - Advanced - Mulitple Target Paths |
116 | | - -------------------------------- |
117 | | - Need to deploy the module to multiple paths? Maybe you have a primary production location but also a process running |
118 | | - in a DMZ? |
| 103 | +Advanced - Mulitple Target Paths |
| 104 | +-------------------------------- |
| 105 | +Need to deploy the module to multiple paths? Maybe you have a primary production location but also a process running in a DMZ? |
119 | 106 |
|
120 | 107 | $BuildSplat = @{ |
121 | 108 | Path = "c:\ProjectFolder\NewModule\Source" |
|
130 | 117 | Invoke-PSModuleBuild @BuildSplat |
131 | 118 |
|
132 | 119 |
|
133 | | -#SEE ALSO |
134 | | - Continuous Integration |
135 | | - Continuous Deployment |
136 | | - PSDeploy |
137 | | - Psake |
138 | | - PSScriptAnalyzer |
| 120 | +# SEE ALSO |
| 121 | + |
| 122 | +Continuous Integration |
| 123 | +- Continuous Deployment |
| 124 | +- PSDeploy |
| 125 | +- Psake |
| 126 | +- PSScriptAnalyzer |
139 | 127 |
|
0 commit comments