psake / PowerShellBuild

Common build tasks for psake and Invoke-Build that build and test PowerShell modules
MIT License
133 stars 24 forks source link

Overriding variables #44

Open neopsyon opened 4 years ago

neopsyon commented 4 years ago

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?

pauby commented 4 years ago

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?

LaurentLienhard commented 4 years ago

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 ?

neopsyon commented 4 years ago

@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.

LaurentLienhard commented 4 years ago

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