WIP [release/v7.5] rebuild based on packages #25894
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new build mode that allows building PowerShell modules and SDKs from pre-built packages instead of project references, controlled by a new
BuildFromPackagesswitch and theRebuildMSBuild property. This change streamlines the build process, especially for scenarios where consuming official package releases is preferred over local source builds. The implementation involves conditional logic in the build scripts and project files to switch between package references and project references based on the build mode.Build system enhancements:
BuildFromPackagesswitch to theStart-PSBuildfunction inbuild.psm1, which sets the/property:Rebuild=trueMSBuild property to control package-based builds. [1] [2]Module.Common.propsfile that conditionally includes eitherPackageReferenceorProjectReferenceforSystem.Management.Automationdepending on theRebuildproperty and platform, centralizing this logic for multiple projects.Project file conditional references:
.csprojfiles (such asMicrosoft.PowerShell.Commands.Management,Microsoft.PowerShell.Commands.Utility,Microsoft.PowerShell.Security, andMicrosoft.PowerShell.SDK) to importModule.Common.propsand/or conditionally switch between package and project references based on theRebuildproperty. This includes adding or moving relevantPackageReferenceandProjectReferenceentries. [1] [2] [3] [4] [5] [6]Windows-specific build logic:
Module.Common.props, added special handling for Windows builds by including a direct assembly reference toSystem.Management.Automation.dllfrom the NuGet package when rebuilding on Windows.SDK and host packaging:
powershell-win-core.csprojto use package references for SDK and related modules when in rebuild mode, and project references otherwise, aligning the packaging with the new build strategy.Graphical host build adjustments:
Microsoft.PowerShell.GraphicalHost.csprojto use package references for dependencies when rebuilding, and project references otherwise, supporting the new build mode.These changes collectively enable a more flexible build process, allowing developers and CI systems to choose between source-based and package-based builds as needed.