psake / PowerShellBuild

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

ModuleOutput documentation inconsistency #27

Closed pauby closed 5 years ago

pauby commented 5 years ago

Expected Behavior

When setting $PSBPreference.Build.OutDir I expect the Output Directory specified to be used but it is not.

Current Behavior

Instead of the value of $PSBPreference.Build.OutDir being used as the Output Directory, "$projectRoot/Output" is used.

Possible Solution

The problem is two fold:

  1. The docs state that the module output directory can be changed using $PSBPreference.Build.OutDir;
  2. The code says that the actual variable to be used should be $BuildEnvironment.Build.ModuleOutDir ($BuildEnvironment in this case is actually $PSBPreference)

There needs to be an agreement on which of the above is correct - the docs or the code. Once that's known we can change the other one.

devblackops commented 5 years ago

Thanks for reporting this @pauby. I see the reason this is happening. The value of $PSBPreference.Build.ModuleOutDir is based on the value of $PSBPreference.Build.OutDir and is set in the build.properties.ps1 which is called when the psakeFile in PowerShellBuild is run, not when your psakeFile is run. You would think to override $PSBPreference.Build.OutDir to set the output directory and that technically is correct but by the time your psakeFile is executed, $PSBPreference.Build.ModuleOutDir already has its value so unless you set that directly, it will keep the original value.

To make it simpler, I think we should just drop $PSBPreference.Build.ModuleOutDir from being a public value and just keep $PSBPreference.Build.OutDir. We can compute the full path to the module internally. This way, setting $PSBPreference.Build.OutDir in your psakeFile will behave as expected.

devblackops commented 5 years ago

@pauby This is fixed in 11e1b94f22b295cfa7a6494bc7d0c25e2fb52864 and will be a part of v0.5.0 if you want to give that a go.

tl:dr; $PSBPreference.Build.ModuleOutDir is now set internally during Initialize-PSBuild. Users should only need to set $PSBPreference.Build.OutDir and it will accept relative or full paths to the desired output directory.