PowerShellBuild icon indicating copy to clipboard operation
PowerShellBuild copied to clipboard

Overriding variables

Open neopsyon opened this issue 4 years ago • 4 comments

I want to override variable values such as $PSBPreference.General.ModuleVersion when I call the build.ps1 file. Can someone please provide a valid example of how to pass the argument in the hashtable format?

neopsyon avatar Apr 22 '20 13:04 neopsyon

This is calculated during the build. The value is extracted from the manifest (I haven't had time to look at the actual code just now, so I'm going from memory).

What's the use case for overriding it?

pauby avatar Apr 23 '20 11:04 pauby

I've had the same thought. It would appear, in fact, that the version is recovered from the psm1 file. When you build the module, version does not increase nor during the task publish. Apart from modifying the version in the psm1 before the build, is there an "UpdateVersion" task for example ?

LaurentLienhard avatar May 08 '20 17:05 LaurentLienhard

@LaurentLienhard

I've had the same thought. It would appear, in fact, that the version is recovered from the psm1 file. When you build the module, version does not increase nor during the task publish. Apart from modifying the version in the psm1 before the build, is there an "UpdateVersion" task for example ?

I have traced the variable and it seems that the version is being passed as an argument to the publish task(PSGallery). Ended up building slightly different build script, some helpers and modified some variables in Pester tests etc. At the end module is being built locally with the proper path output/name/version/files, as well as updated psd1. This seems the issue if you want for example to publish to the Azure Artifacts, since they don't work well with psrepository classic Powershell approach - there are plenty of issues around, you have to use nuget - which is requiring proper module structure etc. Unfortunately I made it quite sticky to our internal company use, not really feasible for the pull request.

neopsyon avatar May 08 '20 18:05 neopsyon

Thank you for the return without going too far how did you pass the version in parameter

LaurentLienhard avatar May 09 '20 07:05 LaurentLienhard