fix: align BuiltModuleSubdirectory property default in WorkspaceDependencies task - #594
fix: align BuiltModuleSubdirectory property default in WorkspaceDependencies task#594raandree wants to merge 4 commits into
Conversation
| $linkedModuleRootParams = @{ | ||
| BuildRoot = $BuildRoot | ||
| OutputDirectory = $OutputDirectory | ||
| BuiltModuleSubdirectory = $BuiltModuleSubdirectory |
There was a problem hiding this comment.
I think we need to only pass BuiltModuleSubdirectory to Get-SamplerWorkspaceLinkedModuleRoot if it is a bound parameter. Otherwise this will pass empty string to the function and the function will go down another codepath than today. If not passing the parameter if it is null or empty string then the default value for the parameter in the function becomes 'module' which then will move into same code pah as today. 🤔
There was a problem hiding this comment.
Set-SamplerTaskVariable -AsNewBuild runs before this call and is dot-sourced into the task scope. When BuiltModuleSubdirectory is unset, it resolves the value to the absolute output root, so this call does not pass an empty string.
I verified both paths:
- passing the resolved value uses
output, matching the path added to
PSModulePathbybuild.ps1; - omitting the parameter uses the helper's
moduledefault and produces
output\module.
I also verified that Import-Module <Name> succeeds when the link is directly under output, but fails when it is under output\module while only output is on PSModulePath. Therefore I think the resolved value must continue to be passed through. I agree this dependency is not obvious, so adding a focused test for the value passed to the helper would make the intent clearer.
Description
Fixes #593.
WorkspaceDependencies.build.ps1was the only task file defaulting to(property BuiltModuleSubdirectory 'module')— every other one uses''.InvokeBuild dot-sources all task files into the same scope, and
propertytreatsan empty string as unset. Since this file is dot-sourced last, its non-empty
default overwrote
$BuiltModuleSubdirectoryfor the whole build. Projects thatdon't set it in
build.yamlbuild to the output root, but the tasks then lookedunder
output\moduleand died inBuild_DscResourcesToExport_ModuleBuilderwith"Could not find the built module manifest for module ''". Hit on
SharePointDsc; 0.119.1 was fine.
Changed the default to
''and updated the parameter help. The task still passesthe value to
Get-SamplerWorkspaceLinkedModuleRoot, so the link root followswherever the project actually builds.
Fixed
WorkspaceDependenciestask no longer leaks aBuiltModuleSubdirectorydefaultinto the shared build scope, which broke every project that does not set
BuiltModuleSubdirectoryinbuild.yaml. Fixes BuiltModuleSubdirectorydefault in theWorkspaceDependencies` task leaks into all tasks and breaks projects that do not set it #593.Tests
.build/tasks/*.build.ps1agree — that's the one thatcatches this class of bug next time.
Both fail on the unfixed file. Also verified end-to-end against a scratch project
without
BuiltModuleSubdirectory: fails before, builds after. Sampler itself setsBuiltModuleSubdirectory: moduleso it never reproduced the bug and is unaffected.Side note, not fixed here:
generateHelp.PlatyPS.build.ps1uses a relative(property OutputDirectory 'output')while the rest useJoin-Path $BuildRoot 'output'. Harmless today (it's always already set, and everything resolves it viaGet-SamplerAbsolutePath), but worth tidying separately.Checklist
Unreleased(format).build.ps1 -ResolveDependencybuilds and tests pass locally.This change is