Currently, we manually choose which PS worker contains the top-level worker.config.json file (powershell/worker.config.json) by adding it as a contentFile to the build output. Add a system that uses targets allowing the consumer of the worker to set PowerShellWorkerConfigVersion and choose which worker config takes precedence:
Rough sketch:
Target file
<PropertyGroup>
<_PowershellWorkerConfigCopyDependsOn>
$(_PowershellWorkerConfigCopyDependsOn);
_PowershellWorkerConfigVersionCheck_{Version}
</_PowershellWorkerConfigCopyDependsOn>
</PropertyGroup>
<Target Name="_PowershellWorkerConfigVersionCheck_{Version}">
<PropertyGroup>
<_PowershellWorkerVersion Condition="'$(_PowershellWorkerVersion)' < '{Version}'>{Version}</_PowershellWorkerVersion>
<_PowershellWorkerConfig Condition="'$(_PowershellWorkerVersion)' == '{Version}'>this_instances_worker_config</_PowershellWorkerConfig>
</PropertyGroup>
</Target>
<Target Name="_CopyPowershellWorkerConfig" BeforeTargets="AssignTargetPaths" DependsOnTargets="$(_PowershellWorkerConfigCopyDependsOn)">
<ItemGroup>
<None Include="$(_PowershellWorkerConfig)" TargetPath="<path>/worker.config.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</Target>
For csproj
<PowerShellVersion>7.6</PowerShellVersion>
Currently, we manually choose which PS worker contains the top-level worker.config.json file (
powershell/worker.config.json) by adding it as a contentFile to the build output. Add a system that uses targets allowing the consumer of the worker to set PowerShellWorkerConfigVersion and choose which worker config takes precedence:Rough sketch:
Target file
For csproj