Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 4 PSModuleDevelopment/PSModuleDevelopment.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Version number of this module.

ModuleVersion = '2.2.11.168'
ModuleVersion = '2.2.12.171'

# ID used to uniquely identify this module
GUID = '37dd5fce-e7b5-4d57-ac37-832055ce49d6'
Expand All @@ -28,7 +28,7 @@
# Modules that must be imported into the global environment prior to importing
# this module
RequiredModules = @(
@{ ModuleName = 'PSFramework'; ModuleVersion = '1.7.270' }
@{ ModuleName = 'PSFramework'; ModuleVersion = '1.12.346' }
@{ ModuleName = 'string'; ModuleVersion = '1.1.3' }
)

Expand Down
Binary file modified BIN +3 KB (110%) PSModuleDevelopment/bin/PSModuleDevelopment.dll
Binary file not shown.
Binary file modified BIN +6 KB (110%) PSModuleDevelopment/bin/PSModuleDevelopment.pdb
Binary file not shown.
46 changes: 46 additions & 0 deletions 46 PSModuleDevelopment/bin/PSModuleDevelopment.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions 6 PSModuleDevelopment/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 2.2.12.171 (2024-10-04)

+ Upd: Raised PSFramework dependency due to critical security update
+ Fix: Invoke-PSMDTemplate - fails on non-Windows
+ Fix: Invoke-PSMDTemplate - fails with latest PSFramework version

## 2.2.11.168 (2024-05-31)

+ Upd: Template AzureFunction - added config option to override http Endpoint methods (#198)
Expand Down
4 changes: 2 additions & 2 deletions 4 PSModuleDevelopment/functions/templating/New-PSMDTemplate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@

$template.CreatedOn = (Get-Date).Date

$template | Export-Clixml -Path (Join-Path $exportFolder $fileName)
$template.ToTemplateInfo() | Export-Clixml -Path (Join-Path $exportFolder $infoFileName)
$template | Export-PSFClixml -Path (Join-Path $exportFolder $fileName) -Depth 99
$template.ToTemplateInfo() | Export-PSFClixml -Path (Join-Path $exportFolder $infoFileName)
}
}
38 changes: 38 additions & 0 deletions 38 build/vsts-build-library.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<#
.SYNOPSIS
Builds the PSFramework binary library from source.

.DESCRIPTION
Builds the PSFramework binary library from source.

.PARAMETER WorkingDirectory
Path where the project root is.
Defaults to the parent folder this file is in.

.EXAMPLE
PS C:\> .\vsts-build-library.ps1

Builds the PSFramework binary library from source.
#>
[CmdletBinding()]
param (
$WorkingDirectory
)

#region Handle Working Directory Defaults
if (-not $WorkingDirectory)
{
if ($env:RELEASE_PRIMARYARTIFACTSOURCEALIAS)
{
$WorkingDirectory = Join-Path -Path $env:SYSTEM_DEFAULTWORKINGDIRECTORY -ChildPath $env:RELEASE_PRIMARYARTIFACTSOURCEALIAS
}
else { $WorkingDirectory = $env:SYSTEM_DEFAULTWORKINGDIRECTORY }
}
if (-not $WorkingDirectory) { $WorkingDirectory = Split-Path $PSScriptRoot }
#endregion Handle Working Directory Defaults

# Build Library
dotnet build "$WorkingDirectory\library\PSModuleDevelopment\PSModuleDevelopment.sln"
if ($LASTEXITCODE -ne 0) {
throw "Failed to build PSModuleDevelopment.dll!"
}
111 changes: 111 additions & 0 deletions 111 dev/launch.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
[CmdletBinding()]
param (
[switch]
$Local,

[switch]
$Build,

[ValidateSet('Desktop', 'Core')]
[string]
$PSVersion
)

#region Launch in new cponsole
if (-not $Local) {
$application = (Get-Process -id $PID).Path
if ($PSVersion -and $PSVersionTable.Edition -ne $PSVersion) {
$application = 'pwsh.exe'
if ($PSVersion -eq 'Desktop') { $application = 'powershell.exe'}
}

$arguments = @('-NoExit', '-NoProfile', '-File', "$PSScriptRoot\launch.ps1", '-Local')
if ($Build) { $arguments += '-Build' }

Start-Process $application -ArgumentList $arguments
return
}
#endregion Launch in new cponsole

$ErrorActionPreference = 'Stop'
trap {
Write-Warning "Script failed: $_"
throw $_
}

#region Functions
function New-TemporaryPath {
[OutputType([string])]
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string]
$Prefix
)

Write-Host "Creating new temporary path: $Prefix"

# Remove Previous Temporary Paths
Remove-Item -Path "$env:Temp\$Prefix*" -Force -Recurse -ErrorAction SilentlyContinue

# Create New Temporary Path
$item = New-Item -Path $env:TEMP -Name "$($Prefix)_$(Get-Random)" -ItemType Directory
$item.FullName
}

function Build-Template {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string]
$RootPath,

[Parameter(Mandatory = $true)]
[string]
$ProjectPath
)

Write-Host "Building Templates from Source"
$buildScriptPath = Join-Path -Path $ProjectPath -ChildPath "templates\build.ps1"
& $buildScriptPath -Path $RootPath

Set-PSFConfig -FullName 'PSModuleDevelopment.Template.Store.PSModuleDevelopment' -Value "$RootPath\output"
}

function Import-PsmdModule {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string]
$ProjectPath
)

Write-Host "Importing PSModuleDevelopment from source code"
Import-Module "$ProjectPath\PSModuleDevelopment\PSModuleDevelopment.psd1" -Global

# Does not work during initial start
# [Microsoft.PowerShell.PSConsoleReadLine]::AddToHistory("ipmo '$ProjectPath\PSModuleDevelopment\PSModuleDevelopment.psd1'")
}

function Build-PsmdModule {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string]
$ProjectPath
)

Write-Host "Building Library. This may require the .NET 4.8 Targeting Pack"
try { $null = & "$ProjectPath\build\vsts-build-library.ps1" }
catch {
Write-Host "Targeting pack Download Link: https://dotnet.microsoft.com/en-us/download/visual-studio-sdks?cid=getdotnetsdk"
throw
}
}
#endregion Functions

$projectRoot = Resolve-Path -Path "$PSScriptRoot\.."
$templateRoot = New-TemporaryPath -Prefix PsmdTemplate
if ($Build) { Build-PsmdModule -ProjectPath $projectRoot }
Import-PsmdModule -ProjectPath $projectRoot
Build-Template -RootPath $templateRoot -ProjectPath $projectRoot
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"RootPath":"F:\\Code\\Github\\PSModuleDevelopment\\library\\PSModuleDevelopment\\PSModuleDevelopment","ProjectFileName":"PSModuleDevelopment.csproj","Configuration":"Debug|AnyCPU","FrameworkPath":"","Sources":[{"SourceFile":"Format\\Column.cs"},{"SourceFile":"Format\\Alignment.cs"},{"SourceFile":"Format\\ColumnTransformation.cs"},{"SourceFile":"Format\\Document.cs"},{"SourceFile":"Format\\TableDefinition.cs"},{"SourceFile":"Format\\ViewDefinitionBase.cs"},{"SourceFile":"Properties\\AssemblyInfo.cs"},{"SourceFile":"PsmdAssembly\\Constructor.cs"},{"SourceFile":"Template\\Parameter\\ParameterBase.cs"},{"SourceFile":"Template\\ParameterScript.cs"},{"SourceFile":"Template\\Parameter\\ParameterPrompt.cs"},{"SourceFile":"Template\\Parameter\\ParameterScript.cs"},{"SourceFile":"Template\\Parameter\\ScriptExecutionTime.cs"},{"SourceFile":"Template\\Store.cs"},{"SourceFile":"Template\\Template.cs"},{"SourceFile":"Template\\TemplateInfo.cs"},{"SourceFile":"Template\\TemplateItemBase.cs"},{"SourceFile":"Template\\TemplateItemFile.cs"},{"SourceFile":"Template\\TemplateItemFolder.cs"},{"SourceFile":"Template\\TemplateResult.cs"},{"SourceFile":"Template\\TemplateType.cs"},{"SourceFile":"Utility\\LinesOfCode.cs"},{"SourceFile":"Utility\\PropertySearchResult.cs"},{"SourceFile":"Utility\\TextAlignment.cs"},{"SourceFile":"Utility\\TextHeader.cs"},{"SourceFile":"Utility\\UtilityHost.cs"},{"SourceFile":"obj\\Debug\\.NETFramework,Version=v4.8.AssemblyAttributes.cs"}],"References":[{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\Microsoft.CSharp.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\mscorlib.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"F:\\Code\\Github\\psframework\\PSFramework\\bin\\PSFramework.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.DataSetExtensions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Windows\\Microsoft.NET\\assembly\\GAC_MSIL\\System.Management.Automation\\v4.0_3.0.0.0__31bf3856ad364e35\\System.Management.Automation.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Net.Http.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.Linq.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""}],"Analyzers":[],"Outputs":[{"OutputItemFullPath":"F:\\Code\\Github\\PSModuleDevelopment\\PSModuleDevelopment\\bin\\PSModuleDevelopment.dll","OutputItemRelativePath":"PSModuleDevelopment.dll"},{"OutputItemFullPath":"","OutputItemRelativePath":""}],"CopyToOutputEntries":[]}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<Compile Include="Template\Parameter\ScriptExecutionTime.cs" />
<Compile Include="Template\Store.cs" />
<Compile Include="Template\Template.cs" />
<Compile Include="Template\TemplateHost.cs" />
<Compile Include="Template\TemplateInfo.cs" />
<Compile Include="Template\TemplateItemBase.cs" />
<Compile Include="Template\TemplateItemFile.cs" />
Expand All @@ -74,6 +75,7 @@
<Compile Include="Template\TemplateType.cs" />
<Compile Include="Utility\LinesOfCode.cs" />
<Compile Include="Utility\PropertySearchResult.cs" />
<Compile Include="Utility\PSObjectExtension.cs" />
<Compile Include="Utility\TextAlignment.cs" />
<Compile Include="Utility\TextHeader.cs" />
<Compile Include="Utility\UtilityHost.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,15 @@ public ParameterScript(string Name, ScriptBlock ScriptBlock)
this.Name = Name;
this.ScriptBlock = ScriptBlock;
}

/// <summary>
/// Creates a prefilled parameter script. Usually used in fixing serialization the hard way.
/// </summary>
/// <param name="Item">The deserialized ParameterScript item</param>
public ParameterScript(PSObject Item)
{
Name = (string)Item.Properties["Name"].Value;
ScriptBlock = ScriptBlock.Create((string)Item.Properties["ScriptBlock"].Value);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Text;
using System.Threading.Tasks;
using PSModuleDevelopment.Utility;

namespace PSModuleDevelopment.Template
{
Expand Down Expand Up @@ -96,5 +98,46 @@ public TemplateInfo ToTemplateInfo()

return info;
}

/// <summary>
/// Create a blank template object
/// </summary>
public Template()
{

}

/// <summary>
/// Create a template object based on a deserialized template object
/// </summary>
/// <param name="Item">The deserialized tample object to restore</param>
/// <exception cref="ArgumentException">If anything at all is not as it should be.</exception>
public Template(PSObject Item)
{
try
{
Name = Item.GetValue<string>("Name");
Type = (TemplateType)Item.GetValue<int>("Type");
Version = Item.GetValue<Version>("Version");
Description = Item.GetValue<string>("Description");
Author = Item.GetValue<string>("Author");
CreatedOn = Item.GetValue<DateTime>("CreatedOn");
foreach (object item in Item.GetValue<ArrayList>("Tags"))
Tags.Add((string)item);
foreach (object item in Item.GetValue<ArrayList>("Parameters"))
Parameters.Add((string)item);
foreach (KeyValuePair<string, ParameterScript> entry in Item.GetDictionary<ParameterScript>("Scripts"))
Scripts[entry.Key] =entry.Value;
// Parameters2 not used
foreach (object item in Item.GetValue<ArrayList>("Children"))
Children.Add(TemplateHost.GetTemplateItem(item));

Generation = Item.GetValue<int>("Generation");
}
catch (Exception e)
{
throw new ArgumentException($"Cannot convert {Item} of type {Item.BaseObject.GetType().FullName} to type PSModuleDevelopment.Template.Template! {e.Message}", e);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Text;
using System.Threading.Tasks;
using PSModuleDevelopment.Utility;

namespace PSModuleDevelopment.Template
{
/// <summary>
/// Static helpers for the template system
/// </summary>
internal static class TemplateHost
{
internal static TemplateItemBase GetTemplateItem(object Item)
{
if (Item.GetType() == typeof(TemplateItemFile))
return (TemplateItemFile)Item;

TemplateItemFolder result = new TemplateItemFolder(); ;
PSObject PSItem = PSObject.AsPSObject(Item);

foreach (object child in PSItem.GetValue<ArrayList>("Children"))
result.Children.Add(GetTemplateItem(child));

result.Name = PSItem.GetValue<string>("Name");
result.RelativePath = PSItem.GetValue<string>("RelativePath");
result.Identifier = PSItem.GetValue<string>("Identifier");
foreach (string entry in PSItem.GetValue<ArrayList>("FileSystemParameterFlat"))
result.FileSystemParameterFlat.Add(entry);
foreach (string entry in PSItem.GetValue<ArrayList>("FileSystemParameterScript"))
result.FileSystemParameterScript.Add(entry);

return result;
}
}
}
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.