[release/v7.6.1] Move _GetDependencies MSBuild target from dynamic generation in build.psm1 into Microsoft.PowerShell.SDK.csproj#27177
Conversation
…ild.psm1` into `Microsoft.PowerShell.SDK.csproj` (PowerShell#27052) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: TravisEz13 <10873629+TravisEz13@users.noreply.github.com> Co-authored-by: Travis Plunk <travis.plunk@microsoft.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Backports the build tooling change from #27052 to the release/v7.6.1 branch by moving the _GetDependencies MSBuild target into the SDK project file and simplifying Start-TypeGen to invoke it directly with consistent native-command error handling.
Changes:
- Adds
_GetDependenciestarget toMicrosoft.PowerShell.SDK.csproj(previously generated dynamically duringStart-TypeGen). - Removes dynamic
.targetsfile creation fromStart-TypeGen. - Wraps
dotnet msbuildanddotnet runcalls inStart-NativeExecutionfor consistent exit-code handling.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Microsoft.PowerShell.SDK/Microsoft.PowerShell.SDK.csproj | Adds the _GetDependencies target (and related guidance) directly to the project so TypeGen can query dependencies without generated targets. |
| build.psm1 | Removes dynamic target generation and uses Start-NativeExecution around TypeGen’s dotnet invocations. |
| try { | ||
| $ps_inc_file = "$PSScriptRoot/src/TypeCatalogGen/$IncFileName" | ||
| dotnet msbuild .\Microsoft.PowerShell.SDK.csproj /t:_GetDependencies "/property:DesignTimeBuild=true;_DependencyFile=$ps_inc_file" /nologo | ||
| Start-NativeExecution { dotnet msbuild .\Microsoft.PowerShell.SDK.csproj /t:_GetDependencies "/property:DesignTimeBuild=true;_DependencyFile=$ps_inc_file" /nologo } |
There was a problem hiding this comment.
The dotnet msbuild invocation uses a Windows-style relative path (.\Microsoft.PowerShell.SDK.csproj). This can be problematic on non-Windows agents and is inconsistent with the cross-platform ./dummy.csproj guidance added to the csproj comment. Use ./Microsoft.PowerShell.SDK.csproj (or just Microsoft.PowerShell.SDK.csproj since you’ve Push-Location’d into the directory) to keep the command line portable.
| Start-NativeExecution { dotnet msbuild .\Microsoft.PowerShell.SDK.csproj /t:_GetDependencies "/property:DesignTimeBuild=true;_DependencyFile=$ps_inc_file" /nologo } | |
| Start-NativeExecution { dotnet msbuild ./Microsoft.PowerShell.SDK.csproj /t:_GetDependencies "/property:DesignTimeBuild=true;_DependencyFile=$ps_inc_file" /nologo } |
Backport of #27052 to release/v7.6.1
Triggered by @adityapatwardhan on behalf of @app/copilot-swe-agent
Original CL Label: CL-BuildPackaging
/cc @PowerShell/powershell-maintainers
Impact
REQUIRED: Choose either Tooling Impact or Customer Impact (or both). At least one checkbox must be selected.
Tooling Impact
Ensures the SDK project carries the _GetDependencies target directly on the release/v7.6.1 branch and keeps Start-TypeGen native execution handling consistent for build tooling reliability.
Customer Impact
Regression
REQUIRED: Check exactly one box.
This is not a regression.
Testing
Cherry-pick applied cleanly with no merge conflicts; this backport preserves the already-validated change from main and is scoped to build/type generation plumbing in build.psm1 and Microsoft.PowerShell.SDK.csproj.
Risk
REQUIRED: Check exactly one box.
Low risk because this is a focused build-system maintenance change already merged on main, with no runtime feature behavior changes and no additional conflict resolution needed.