You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ReadMe.md
+17-21Lines changed: 17 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -32,53 +32,49 @@ cd Modulebuilder
32
32
33
33
#### 2. Install dependencies
34
34
35
-
We have a few modules which are required for building. They're listed in `RequiredModules.psd1` -- the `.\Install-RequiredModule.ps1` script installs them (it defaults to CurrentUser scope, but has a `-Scope` parameter if you're running elevated and want to install them for the `AllUsers`). They only change rarely, so you won't need to run this repeatedly.
35
+
We have a few modules which are required for building. They're listed in `RequiredModules.psd1` -- the `Install-RequiredModule` script installs them (it defaults to CurrentUser scope, but has a `-Scope` parameter if you're running elevated and want to install them for the `AllUsers`). They only change rarely, so you shouldn't need to run this repeatedly, but it does _import_ the modules too, so if you need to use newer versions of these modules (like Pester 5), you can use this to import the ones we need:
36
36
37
37
```powershell
38
-
.\Install-RequiredModule.ps1
38
+
./Install-RequiredModule.ps1
39
39
```
40
40
41
41
#### 3. Run the `build.ps1` script.
42
42
43
-
By default, the build script uses [gitversion](/gittols/gitversion) to calculate the version of the build automatically:
43
+
By default, the build script uses [gitversion](/gittols/gitversion) to calculate the version of the build automatically, and will put the build in a folder like "ModuleBuilder\2.0.0" where 2.0.0 is the current version number.
44
44
45
45
```powershell
46
-
.\build.ps1
46
+
./build.ps1
47
47
```
48
48
49
-
If you don't have gitversion handy, you can just specify a version for the `-Semver` parameter:
49
+
If you don't have `gitversion` handy, you can just specify a version for the `-Semver` parameter:
50
50
51
51
```powershell
52
-
.\build.ps1 -Semver 2.0.0-beta
52
+
./build.ps1 -Semver 2.1.0-beta
53
53
```
54
54
55
-
#### 4. Make the compiled module available to Powershell
55
+
#### 4. Run tests with Pester
56
56
57
-
The `.\build.ps1` process will output the path to the folder named with the current version number, like "1.0.0" -- the compiled psm1 and psd1 files are in that folder. In order for PowerShell to find them when you ask it to import, they need to be in the PSModulePath. PowerShell expects to find modules in a folder with a matching name that sits in one of the folders in your PSModulePath.
58
-
59
-
Since we cloned the "ModuleBuilder" project into a "ModuleBuilder" folder, the easiest thing to do is just add the parent of the `ModuleBuilder` folder to your PSModulePath. Personally, I keep all my git repos in my user folder at `~\Projects` and I add that to my PSModulePath in my profile script. You could do it temporarily for your current PowerShell session by running this:
57
+
The `test.ps1` script runs Pester and ScriptAnalyzer. It finds the build output from our `build.ps1` script in the default build output location -- that is, right next to these scripts in the root of the repository. It actually removes the `ModuleBuilder` module and re-imports the highest version in that root:
60
58
61
59
```powershell
62
-
$Env:PSModulePath += ';' + (Resolve-Path ..)
60
+
./test.ps1
63
61
```
64
62
65
-
Alternatively, you could copy the build output to your PSModulePath -- but then you need to start by creating the new "ModuleBuilder" folder to put the version number folder in. You could do that as you build by running something like this instead of just running the `.\build.ps1` script:
63
+
If you want to test against a different version, you can import it manually and `Invoke-Pester` yourself.
64
+
65
+
##### You have a lot of other options here ...
66
+
67
+
You could import the module explicitly from the output path:
0 commit comments