psake.psm1
|
# psake # Copyright (c) 2012 James Kovacs # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. $script:IgnoreError = 'Ignore' $script:nl = [System.Environment]::NewLine # Dot source public/private functions $dotSourceParams = @{ Filter = '*.ps1' Recurse = $true ErrorAction = 'Stop' } $enums = @(Get-ChildItem -Path (Join-Path -Path $PSScriptRoot -ChildPath 'enums') @dotSourceParams ) $classes = @(Get-ChildItem -Path (Join-Path -Path $PSScriptRoot -ChildPath 'classes') @dotSourceParams ) $public = @(Get-ChildItem -Path (Join-Path -Path $PSScriptRoot -ChildPath 'public') @dotSourceParams ) $public = @(Get-ChildItem -Path (Join-Path -Path $PSScriptRoot -ChildPath 'public') @dotSourceParams ) $private = @(Get-ChildItem -Path (Join-Path -Path $PSScriptRoot -ChildPath 'private') @dotSourceParams) foreach ($import in @($enums + $classes + $public + $private)) { try { . $import.FullName } catch { Write-Error "Unable to dot source [$($import.FullName)]" throw $_ } } # Due to a bug in older version of Pwsh 7, we need to have a copy in the PSM # and then we can try to load from a locale folder. #region Auto-generated from YAML localization files. data msgs { ConvertFrom-StringData @' adding_task=Adding task [{0}] build_time_report=Build Time Report continue_on_error=Error in task {0}. {1} error_bad_command=Error executing command {0}. error_build_file_not_found=Could not find the build file {0}. error_circular_reference=Circular reference found for task {0}. error_corrupt_callstack=Call stack was corrupt. Expected {0}, but got {1}. error_default_task_cannot_have_action='default' task cannot specify an action. error_duplicate_alias_name=Alias {0} has already been defined. error_duplicate_task_name=Task {0} has already been defined. error_invalid_framework=Invalid .NET Framework version, {0} specified. error_invalid_include_path=Unable to include {0}. File not found. error_invalid_task_name=Task name should not be null or empty string. error_loading_module=Error loading module {0}. error_missing_action_parameter=Action parameter must be specified when using PreAction or PostAction parameters for task {0}. error_no_default_task='default' task required. error_no_framework_install_dir_found=No .NET Framework installation directory found at {0}. error_shared_task_cannot_have_action='{0} references a shared task from module {1} and cannot have an action. error_task_name_does_not_exist=Task {0} does not exist. error_unknown_bitnesspart=Unknown .NET Framework bitness, {0}, specified in {1}. error_unknown_framework=Unknown .NET Framework version, {0} specified in {1}. error_unknown_module=Unable to find module [{0}]. error_unknown_pointersize=Unknown pointer size ({0}) returned from System.IntPtr. exec_standard_error=Standard Error: {0} exec_standard_output=Standard Output: {0} loading_task_module=Loading tasks from task module [{0}] postcondition_failed=PostCondition failed for task {0}. precondition_was_false=Precondition was false, not executing task {0}. psake_success=psake succeeded executing {0} required_variable_not_set=Variable {0} must be set to run task {1}. retrying_execute=Try {0} failed, retrying again in 1 second... task_cached=Skipping task '{0}' (cached) warning_deprecated_framework_variable=Warning: Using global variable $framework to set .NET framework version used is deprecated. Instead use Framework function or configuration file psake-config.ps1. warning_missing_vsssetup_module=Warning: Cannot find build tools version {0} without the module VSSetup. You can install this module with the command: Install-Module VSSetup -Scope CurrentUser '@ } #endregion Auto-generated from YAML localization files. $importLocalizedDataSplat = @{ BindingVariable = 'msgs' BaseDirectory = $PSScriptRoot FileName = 'Messages.psd1' ErrorAction = $script:IgnoreError } Import-LocalizedData @importLocalizedDataSplat $scriptDir = Split-Path $MyInvocation.MyCommand.Path $manifestPath = Join-Path $scriptDir psake.psd1 $manifest = Test-ModuleManifest -Path $manifestPath -WarningAction SilentlyContinue $psakeConfigFile = 'psake-config.ps1' $psake = @{} $psake.version = $manifest.Version.ToString() $psake.Context = New-Object system.collections.stack # holds onto the current state of all variables $psake.run_by_psake_build_tester = $false # indicates that build is being run by psake-BuildTester $psake.LoadedTaskModules = @{} $psake.ReferenceTasks = @{} #region Default Psake Configuration # Contains default configuration, can be overridden in psake-config.ps1 in # directory with psake.psm1 or in directory with current build script $psake.ConfigDefault = [PSCustomObject]@{ BuildFileName = "psakefile.ps1" Framework = "4.7.2" TaskNameFormat = "Executing {0}" VerboseError = $False Modules = $Null ModuleScope = "" } #endregion $psake.build_success = $false # indicates that the current build was successful $psake.build_script_file = $null # contains a System.IO.FileInfo for the current build script $psake.build_script_dir = "" # contains a string with fully-qualified path to current build script $psake.error_message = $null # contains the error message which caused the script to fail Import-PsakeConfiguration Export-ModuleMember -Function $public.BaseName -Variable psake |