Move _GetDependencies MSBuild target from dynamic generation in build.psm1 into Microsoft.PowerShell.SDK.csproj (#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>
This commit is contained in:
Copilot
2026-03-18 17:28:37 -04:00
committed by GitHub
co-authored by TravisEz13 Travis Plunk Copilot Autofix powered by AI
parent 73186fb138
commit 569eb7246c
2 changed files with 25 additions and 24 deletions
+2 -23
View File
@@ -2681,38 +2681,17 @@ function Start-TypeGen
# Add .NET CLI tools to PATH
Find-Dotnet
# This custom target depends on 'ResolveAssemblyReferencesDesignTime', whose definition can be found in the sdk folder.
# To find the available properties of '_ReferencesFromRAR' when switching to a new dotnet sdk, follow the steps below:
# 1. create a dummy project using the new dotnet sdk.
# 2. build the dummy project with this command:
# dotnet msbuild .\dummy.csproj /t:ResolveAssemblyReferencesDesignTime /fileLogger /noconsolelogger /v:diag
# 3. search '_ReferencesFromRAR' in the produced 'msbuild.log' file. You will find the properties there.
$GetDependenciesTargetPath = "$PSScriptRoot/src/Microsoft.PowerShell.SDK/obj/Microsoft.PowerShell.SDK.csproj.TypeCatalog.targets"
$GetDependenciesTargetValue = @'
<Project>
<Target Name="_GetDependencies"
DependsOnTargets="ResolveAssemblyReferencesDesignTime">
<ItemGroup>
<_RefAssemblyPath Include="%(_ReferencesFromRAR.OriginalItemSpec)%3B" Condition=" '%(_ReferencesFromRAR.NuGetPackageId)' != 'Microsoft.Management.Infrastructure' "/>
</ItemGroup>
<WriteLinesToFile File="$(_DependencyFile)" Lines="@(_RefAssemblyPath)" Overwrite="true" />
</Target>
</Project>
'@
New-Item -ItemType Directory -Path (Split-Path -Path $GetDependenciesTargetPath -Parent) -Force > $null
Set-Content -Path $GetDependenciesTargetPath -Value $GetDependenciesTargetValue -Force -Encoding Ascii
Push-Location "$PSScriptRoot/src/Microsoft.PowerShell.SDK"
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 }
} finally {
Pop-Location
}
Push-Location "$PSScriptRoot/src/TypeCatalogGen"
try {
dotnet run ../System.Management.Automation/CoreCLR/CorePsTypeCatalog.cs $IncFileName
Start-NativeExecution { dotnet run ../System.Management.Automation/CoreCLR/CorePsTypeCatalog.cs $IncFileName }
} finally {
Pop-Location
}
@@ -31,4 +31,26 @@
<PackageReference Include="Microsoft.Windows.Compatibility" Version="11.0.0-preview.1.26104.118" />
</ItemGroup>
</Project>
<!--
This target is invoked explicitly by Start-TypeGen in build.psm1 to collect the list of
reference assembly paths needed by TypeCatalogGen. It is not run during a normal build.
To find the available properties of '_ReferencesFromRAR' when switching to a new dotnet sdk:
1. Create a dummy project using the new dotnet sdk.
2. Build the dummy project with:
dotnet msbuild ./dummy.csproj /t:ResolveAssemblyReferencesDesignTime /fileLogger /noconsolelogger /v:diag
3. Search '_ReferencesFromRAR' in the produced 'msbuild.log' file.
-->
<Target Name="_GetDependencies"
DependsOnTargets="ResolveAssemblyReferencesDesignTime">
<ItemGroup>
<!--
Excludes 'Microsoft.Management.Infrastructure' from the type catalog reference list,
as it is provided separately at runtime and must not be included in the generated catalog.
-->
<_RefAssemblyPath Include="%(_ReferencesFromRAR.OriginalItemSpec)%3B" Condition=" '%(_ReferencesFromRAR.NuGetPackageId)' != 'Microsoft.Management.Infrastructure' "/>
</ItemGroup>
<WriteLinesToFile File="$(_DependencyFile)" Lines="@(_RefAssemblyPath)" Overwrite="true" />
</Target>
</Project>