Templates/NewModule/src/Module.psm1

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
39
40
41
42
43
44
45
46
47
48
<%
    if ($PLASTER_PARAM_Localization -eq 'Yes') {
        @"
# -------------------------- Load Localization ----------------------------
#
Data LocalizedData {
    # culture="en-US"
    ConvertFrom-StringData @'
    ErrorPathNotFound=Cannot find path '{0}' because it does not exist.
    ErrorLoadingScript=There was an error loading '{0}'.
    VerboseLoadingScript=Loading script file '{0}'.
'@
}
Microsoft.PowerShell.Utility\Import-LocalizedData LocalizedData -FileName ${PLASTER_PARAM_ModuleName}.Localization.psd1 -ErrorAction SilentlyContinue
 
"@

    }
%>
# -------------------------- Load Script Files ----------------------------
#
# Do not add Export-ModuleMember logic. All functions in .\Public are added to the manifest during build.
# If you need to import from \src\ run the build.ps1 in \tools\ with 'ExportFunctionsToSrc' as the task.
#
$ModuleScriptFiles = @(Get-ChildItem -Path $PSScriptRoot -Filter *.ps1 -Recurse  | Where-Object { $_.Name -notlike "*.ps1xml" } )

foreach ($ScriptFile in $ModuleScriptFiles) {
    try {
<%
    if ($PLASTER_PARAM_Localization -eq 'Yes') {
        ' Write-Verbose "$($LocalizedData.VerboseLoadingScript -f $ScriptFile.Name)"'
    }
    else {
        ' Write-Verbose "Loading script file $($ScriptFile.Name)"'
    }
%>
        . $ScriptFile.FullName
    }
    catch {
<%
    if ($PLASTER_PARAM_Localization -eq 'Yes') {
        ' Write-Error "$($LocalizedData.ErrorLoadingScript -f $ScriptFile.FullName)"'
    }
    else {
        ' Write-Error "Error loading script file $($ScriptFile.FullName)"'
    }
%>
    }
}