Skip to content

Add support for worker.config.json being determined by build target #1126

Description

@andystaples

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)' &lt; '{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>

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions