Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 2 additions & 23 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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 }

Copilot uses AI. Check for mistakes.
} 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
}
Expand Down
24 changes: 23 additions & 1 deletion src/Microsoft.PowerShell.SDK/Microsoft.PowerShell.SDK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,26 @@
<PackageReference Include="System.Windows.Extensions" Version="10.0.5" />
</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>
Loading