PoshCode / ModuleBuilder

A PowerShell Module to help scripters write, version, sign, package, and publish.
MIT License
447 stars 53 forks source link

Feature: Where should the built module go? #31

Closed Jaykul closed 5 years ago

Jaykul commented 6 years ago

As a module author, I need to be able to specify where the build output should go.

Background

Because of how the using module statement works in PowerShell, I usually need to build output into the PSModule path without breaking the working versions -- however, by default the output should go in a folder in the project (let's call it "output" though, because plain English is good, and these aren't binaries).

Assumptions:

I have a source folder

That is, I have a project "root" folder. Within that I have a source folder with the build.psd1 file in it. It may be named "source" but it might also be named with the module name (e.g. "ModuleBuilder") or something else entirely. I might even have multiple modules within a single project. In that case, each one has it's own source folder (which obviously can't all be named "Source").

I sometimes want to add the version number

I can specify the module name in my build.psd1, but not the version, because that changes with each commit/build/release, but sometimes I want to build output into my PSModulePath, so it needs to be able to have the version number, so it doesn't "clean" the old versions out.

When building clean, we should clean this version

If we're adding version numbers to the build output path, we should leave any old version numbers. That way if we're building to the PSModulePath, we won't accidentally remove old versions that I might need for production work, or supporting users.

Proposal

We need a parameter -VersionedOutputDirectory that determines whether a version number is appended to the output folder path or not. This should be a switch that's used in addition to the -OutputDirectory parameter and can be defaulted in the build.psd1.

Possible results:

  1. If you specify -VersionedOutputDirectory and no -OutputDirectory the output should go in a numbered subdirectory of the "root" folder.
  2. If you specify -VersionedOutputDirectory and -OutputDirectory the output should go in a numbered subdirectory of the output directory.
  3. If you specify a relative -OutputDirectory the output should go in a path relative to the build.psd1 (Currently, this is wrong)