< Back

Set-BuildEnvironment

Sun Jan 12, 2020 6:49 pm

NAME Set-BuildEnvironment



SYNOPSIS

Normalize build system and project details into environment variables





SYNTAX

Set-BuildEnvironment [[-Path] <Object>] [[-VariableNamePrefix] <String>] [[-BuildOutput] <String>] [-Force]

[-Passthru] [[-GitPath] <String>] [<CommonParameters>]





DESCRIPTION

Normalize build system and project details into environment variables



Creates the following environment variables:

$ENV:<VariableNamePrefix>ProjectPath via Get-BuildVariable

$ENV:<VariableNamePrefix>BranchName via Get-BuildVariable

$ENV:<VariableNamePrefix>CommitMessage via Get-BuildVariable

$ENV:<VariableNamePrefix>BuildNumber via Get-BuildVariable

$ENV:<VariableNamePrefix>ProjectName via Get-ProjectName

$ENV:<VariableNamePrefix>PSModuleManifest via Get-PSModuleManifest

$ENV:<VariableNamePrefix>ModulePath via Split-Path on PSModuleManifest

$ENV:<VariableNamePrefix>BuildOutput via BuildOutput parameter

$ENV:BHPSModulePath Legacy, via Split-Path on PSModuleManifest



If you don't specify a prefix or use BH, we create BHPSModulePath (This will be removed July 1st)





PARAMETERS

-Path <Object>

Path to project root. Defaults to the current working path



Required? false

Position? 1

Default value $PWD.Path

Accept pipeline input? false

Accept wildcard characters? false



-VariableNamePrefix <String>

Allow to set a custom Prefix to the Environment variable created. The default is BH such as $Env:BHProjectPath



Required? false

Position? 2

Default value BH

Accept pipeline input? false

Accept wildcard characters? false



-BuildOutput <String>

Specify a path to use for build output. Defaults to '$ProjectPath\\BuildOutput'



You may use build variables produced in this same call. Only include the variable, not ENV or the prefix.

Use a literal $.



Examples:

-BuildOutput '$ProjectPath\\BuildOutput'

-BuildOutput 'C:\\Build'

-BuildOutput 'C:\\Builds\\$ProjectName'



Required? false

Position? 3

Default value $ProjectPath\\BuildOutput

Accept pipeline input? false

Accept wildcard characters? false



-Force [<SwitchParameter>]

Overrides the Environment Variables even if they exist already



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-Passthru [<SwitchParameter>]

If specified, include output of the build variables we create



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-GitPath <String>

Path to git. Defaults to git (i.e. git is in $ENV:PATH)



Required? false

Position? 4

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





We assume you are in the project root, for several of the fallback options



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Set-BuildEnvironment



Get-Item ENV:BH*









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Set-BuildEnvironment -VariableNamePrefix '' -Force



Get-Item ENV:*









-------------------------- EXAMPLE 3 --------------------------



PS C:\\>Set-BuildEnvironment -Path C:\\sc\\PSDepend -BuildOutput 'C:\\Builds\\$ProjectName'



# Set BuildEnvironment pointing at C:\\sc\\PSDepend

# Assuming ProjectName evaluates to PSDepend, BuildOutput variable will be set to C:\\Builds\\PSDepend











RELATED LINKS

https://github.com/RamblingCookieMonster/BuildHelpers

Get-BuildVariable

Get-BuildEnvironment

Get-ProjectName

about_BuildHelpers