|
65 | 65 | ############################################################################### |
66 | 66 | Properties { |
67 | 67 | # The name of your module should match the basename of the PSD1 file. |
68 | | - $ModuleName = (Get-Item $PSScriptRoot\*.psd1)[0].BaseName |
| 68 | + $ModuleName = (Get-Item $PSScriptRoot\*.psd1 | |
| 69 | + Foreach-Object {$null = Test-ModuleManifest -Path $_ -ErrorAction SilentlyContinue; if ($?) {$_}})[0].BaseName |
69 | 70 |
|
70 | 71 | # Path to the release notes file. Set to $null if the release notes reside in the manifest file. |
71 | 72 | $ReleaseNotesPath = "$PSScriptRoot\ReleaseNotes.md" |
72 | 73 |
|
73 | 74 | # The directory used to publish the module from. If you are using Git, the |
74 | | - # $PublishDir should be ignored if it is under the workspace directory. |
75 | | - $PublishDir = "$PSScriptRoot\Release\$ModuleName" |
| 75 | + # $PublishRootDir should be ignored if it is under the workspace directory. |
| 76 | + $PublishRootDir = "$PSScriptRoot\Release" |
| 77 | + $PublishDir = "$PublishRootDir\$ModuleName" |
76 | 78 |
|
77 | 79 | # The following items will not be copied to the $PublishDir. |
78 | 80 | # Add items that should not be published with the module. |
79 | 81 | $Exclude = @( |
| 82 | + (Split-Path $PSCommandPath -Leaf), |
80 | 83 | 'Release', |
81 | 84 | 'Tests', |
82 | 85 | '.git*', |
83 | 86 | '.vscode', |
84 | | - # The next three files are unique to this examples dir. |
| 87 | + # These files are unique to this examples dir. |
85 | 88 | 'DebugTest.ps1', |
86 | | - 'Stop*.ps1', |
| 89 | + 'PSScriptAnalyzerSettings.psd1', |
87 | 90 | 'Readme.md', |
88 | | - (Split-Path $PSCommandPath -Leaf) |
| 91 | + 'Stop*.ps1' |
89 | 92 | ) |
90 | 93 |
|
91 | 94 | # Name of the repository you wish to publish to. Default repo is the PSGallery. |
@@ -170,8 +173,8 @@ Task Clean -depends Init -requiredVariables PublishDir { |
170 | 173 | # Sanity check the dir we are about to "clean". If $PublishDir were to |
171 | 174 | # inadvertently get set to $null, the Remove-Item commmand removes the |
172 | 175 | # contents of \*. That's a bad day. Ask me how I know? :-( |
173 | | - if ($PublishDir.Contains($PSScriptRoot)) { |
174 | | - Remove-Item $PublishDir\* -Recurse -Force |
| 176 | + if ($PublishRootDir.Contains($PSScriptRoot)) { |
| 177 | + Remove-Item $PublishRootDir\* -Recurse -Force |
175 | 178 | } |
176 | 179 | } |
177 | 180 |
|
|
0 commit comments