Allow multiple publish targets based on condition #381

Closed
opened 2025-08-09 17:16:04 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @joeyeng on 10/5/2017

Maybe there is a way to do this or something similar that I'm unaware of, but it would be nice if you could specify in .csproj, multiple PublishRunWebpack targets based on a condition like configuration, so you can pass something other than env.prod:

<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish" Condition=" '$(Configuration)' == 'QA' ">
    <!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
    <Exec Command="npm install" />
    <Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.qa" />
    <Exec Command="node node_modules/webpack/bin/webpack.js --env.qa" />

    <!-- Include the newly-built files in the publish output -->
    <ItemGroup>
      <DistFiles Include="wwwroot\dist\**" />
      <ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
        <RelativePath>%(DistFiles.Identity)</RelativePath>
        <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
      </ResolvedFileToPublish>
    </ItemGroup>
</Target>
*Originally created by @joeyeng on 10/5/2017* Maybe there is a way to do this or something similar that I'm unaware of, but it would be nice if you could specify in .csproj, multiple PublishRunWebpack targets based on a condition like configuration, so you can pass something other than env.prod: ```xml <Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish" Condition=" '$(Configuration)' == 'QA' "> <!-- As part of publishing, ensure the JS resources are freshly built in production mode --> <Exec Command="npm install" /> <Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.qa" /> <Exec Command="node node_modules/webpack/bin/webpack.js --env.qa" /> <!-- Include the newly-built files in the publish output --> <ItemGroup> <DistFiles Include="wwwroot\dist\**" /> <ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)"> <RelativePath>%(DistFiles.Identity)</RelativePath> <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> </ResolvedFileToPublish> </ItemGroup> </Target> ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#381
No description provided.