Skip to content
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
5 changes: 5 additions & 0 deletions CHANGELOG/v3.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# v3 Changelog

## [v3.1.5]

- Improved module fingerprint detection to only warn if the actual module contents for the DSC schema
cache JSON file have changed.

## [v3.1.4]

- Fixed the fast host failing to compile any configuration with a resource property whose name matches
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

RootModule = 'PSDesiredStateConfiguration.psm1'

ModuleVersion = '3.1.4'
ModuleVersion = '3.1.5'

CompatiblePSEditions = @('Desktop', 'Core')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
RootModule = 'M365DSC.PSDesiredStateConfiguration.psm1'

# Version number of this module.
ModuleVersion = '3.1.4'
ModuleVersion = '3.1.5'

# Supported PSEditions
CompatiblePSEditions = @('Desktop', 'Core')
Expand Down
50 changes: 48 additions & 2 deletions M365DSC.PSDesiredStateConfiguration/SchemaCache.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,47 @@ function Test-DscSchemaCache
}
Export-ModuleMember -Function Test-DscSchemaCache

function Get-DscSchemaCacheSourceFingerprint
{
[OutputType([string])]
param (
[Parameter(Mandatory)]
[string]
$ModuleBase,

[Parameter(Mandatory)]
$Cache
)

if ($null -eq $Cache.module.sourceHash)
{
return $null
}

$entries = @($Cache.module.sourceHash.PSObject.Properties)
if ($entries.Count -eq 0)
{
return $null
}

$maxTicks = [long]0
foreach ($entry in $entries)
{
$file = Join-Path $ModuleBase $entry.Name
if (-not [System.IO.File]::Exists($file))
{
return $null
}
$ticks = [System.IO.File]::GetLastWriteTimeUtc($file).Ticks
if ($ticks -gt $maxTicks)
{
$maxTicks = $ticks
}
}

"$($entries.Count):$maxTicks"
}

function Get-DscSchemaCache
{
param (
Expand Down Expand Up @@ -326,9 +367,14 @@ function Get-DscSchemaCache
Write-Warning -Message "Schema cache '$candidate' is for $($cache.module.name) $($cache.module.version), not $($Module.Name) $($Module.Version)."
continue
}
if ($cache.module.fingerprint -ne $fingerprint)
$recorded = Get-DscSchemaCacheSourceFingerprint -ModuleBase $Module.ModuleBase -Cache $cache
if ($null -eq $recorded)
{
$recorded = $fingerprint
}
if ($cache.module.fingerprint -ne $recorded)
{
Write-Warning -Message "Schema cache '$candidate' is stale (module files changed)."
Write-Verbose -Message "Schema cache '$candidate' is stale (module files changed)."
continue
}
return $cache
Expand Down
Loading