Skip to content

Conversation

@TravisEz13
Copy link
Member

@TravisEz13 TravisEz13 commented Aug 22, 2025

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 BuildFromPackages switch and the Rebuild MSBuild 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:

  • Added a BuildFromPackages switch to the Start-PSBuild function in build.psm1, which sets the /property:Rebuild=true MSBuild property to control package-based builds. [1] [2]
  • Introduced a shared Module.Common.props file that conditionally includes either PackageReference or ProjectReference for System.Management.Automation depending on the Rebuild property and platform, centralizing this logic for multiple projects.

Project file conditional references:

  • Updated multiple .csproj files (such as Microsoft.PowerShell.Commands.Management, Microsoft.PowerShell.Commands.Utility, Microsoft.PowerShell.Security, and Microsoft.PowerShell.SDK) to import Module.Common.props and/or conditionally switch between package and project references based on the Rebuild property. This includes adding or moving relevant PackageReference and ProjectReference entries. [1] [2] [3] [4] [5] [6]

Windows-specific build logic:

  • In Module.Common.props, added special handling for Windows builds by including a direct assembly reference to System.Management.Automation.dll from the NuGet package when rebuilding on Windows.

SDK and host packaging:

  • Modified powershell-win-core.csproj to 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:

  • Updated Microsoft.PowerShell.GraphicalHost.csproj to 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.

@TravisEz13 TravisEz13 changed the base branch from master to release/v7.5 August 22, 2025 19:08
@TravisEz13 TravisEz13 changed the title vpack75 WIP [release/v7.5] rebuild based on packages Aug 22, 2025
Copy link
Collaborator

@iSazonov iSazonov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our dev documentation is very outdated. Have you considered updating it?

Comment on lines +49 to +50
<ProjectReference Include="..\Microsoft.PowerShell.SDK\Microsoft.PowerShell.SDK.csproj" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.5.2" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repeat project reference.

<PackageReference Include="Microsoft.PowerShell.ConsoleHost" Version="7.5.2" />
<PackageReference Include="Microsoft.PowerShell.Commands.Diagnostics" Version="7.5.2" />
<PackageReference Include="Microsoft.Management.Infrastructure.CimCmdlets" Version="7.5.2" />
<PackageReference Include="Microsoft.WSMan.Management" Version="7.5.2" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we parameterize this 7.5.2 value? It is used in many places.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, parameterizing the version number 7.5.2 is a smart move—especially since it's repeated across multiple entries. This makes your project easier to maintain and update in the future. Instead of hunting down every instance of the version string, you can change it in one place.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Review - Needed The PR is being reviewed label Sep 2, 2025
@microsoft-github-policy-service
Copy link
Contributor

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@adityapatwardhan adityapatwardhan marked this pull request as draft October 9, 2025 20:14
@microsoft-github-policy-service microsoft-github-policy-service bot added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Oct 12, 2025
@microsoft-github-policy-service
Copy link
Contributor

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 15 days. It will be closed if no further activity occurs within 10 days of this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review - Needed The PR is being reviewed Stale Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants