-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathVirtualEngine.Build.psm1
More file actions
38 lines (34 loc) · 1.63 KB
/
VirtualEngine.Build.psm1
File metadata and controls
38 lines (34 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
$moduleRoot = Split-Path -Path $MyInvocation.MyCommand.Path -Parent
#region LocalizedData
$culture = 'en-us'
if (Test-Path -Path (Join-Path -Path $moduleRoot -ChildPath $PSUICulture)) {
$culture = $PSUICulture
}
$importLocalizedDataParams = @{
BindingVariable = 'localized';
Filename = 'VirtualEngine.Build.psd1';
BaseDirectory = $moduleRoot;
UICulture = $culture;
}
Import-LocalizedData @importLocalizedDataParams;
#endregion LocalizedData
## Dot source all (nested) .ps1 files in the folder, excluding Pester tests
$srcPath = Join-Path -Path $moduleRoot -ChildPath 'Src'
Get-ChildItem -Path $srcPath -Include *.ps1 -Recurse |
ForEach-Object {
Write-Verbose -Message ('Importing library\source file ''{0}''.' -f $_.FullName);
## https://becomelotr.wordpress.com/2017/02/13/expensive-dot-sourcing/
. ([System.Management.Automation.ScriptBlock]::Create(
[System.IO.File]::ReadAllText($_.FullName)
));
}
## Download Nuget.exe (if not present)
$moduleRoot = Split-Path -Parent $MyInvocation.MyCommand.Path;
Set-Variable -Name virtualEngineBuildNugetPath -Value (Join-Path -Path $moduleRoot -ChildPath 'Lib\Nuget.exe') -Scope Script;
if (-not (Test-Path -Path $virtualEngineBuildNugetPath)) {
$virtualEngineBuildNugetParentPath = Split-Path -Path $virtualEngineBuildNugetPath -Parent;
if (-not (Test-Path -Path $virtualEngineBuildNugetParentPath -PathType Container)) {
[ref] $null = New-Item -Path $virtualEngineBuildNugetParentPath -ItemType Directory -Force;
}
Invoke-WebRequest -Uri 'http://nuget.org/nuget.exe' -OutFile $virtualEngineBuildNugetPath;
}