Skip to content

Commit

Permalink
[ClickOnce] Consider CopyToPublishDirectory property before publishin…
Browse files Browse the repository at this point in the history
…g content items
  • Loading branch information
sujitnayak committed Dec 2, 2023
1 parent 195e7f5 commit 0247baa
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Tasks/Microsoft.Common.CurrentVersion.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4438,23 +4438,30 @@ Copyright (C) Microsoft Corporation. All rights reserved.
either have the .exe/.dll extension or their publish status has been overriden in VS so they will show up in the PublishFiles collection.
The PublishProtocol property is available only in .NET>=5 so we will used that to exclude .NET FX 4.X case.
-->
<_ClickOnceTransitiveContentItemsTemp Include="@(_TransitiveItemsToCopyToOutputDirectory->'%(TargetPath)')" Condition="'$(PublishProtocol)' == 'ClickOnce'" >
<_ClickOnceTransitiveContentItemsTemp Include="@(_TransitiveItemsToCopyToOutputDirectory->'%(TargetPath)')" Condition="'$(PublishProtocol)' == 'ClickOnce' AND '%(_TransitiveItemsToCopyToOutputDirectory.CopyToPublishDirectory)' != 'Never'" >
<SavedIdentity>%(Identity)</SavedIdentity>
</_ClickOnceTransitiveContentItemsTemp>
<_ClickOnceTransitiveContentItems Include="@(_ClickOnceTransitiveContentItemsTemp->'%(SavedIdentity)')" Condition="'%(Identity)'=='@(PublishFile)' Or '%(Extension)'=='.exe' Or '%(Extension)'=='.dll'" />

<!--
ClickOnce content items is union of transitive content items and content items from this project.
We also exclude content items from this project that have set CopyToPublishDirectory to Never.
-->
<_ClickOnceContentItems Include="@(ContentWithTargetPath)" Condition="'%(ContentWithTargetPath.CopyToPublishDirectory)' != 'Never'" />
<_ClickOnceContentItems Include="@(_ClickOnceTransitiveContentItems)" />

<!--
For .NET>=5, we need to check if we need to publish any copylocal items from None group. For such items to be published, they either
have .exe/.dll extension or their publish status has been overriden in VS so they will show up in the PublishFiles collection.
The PublishProtocol property is available only in .NET>=5 so we will used that to exclude .NET FX 4.X case.
-->
<!-- Include items from None group for publishing -->
<_ClickOnceNoneItemsTemp Include="@(_NoneWithTargetPath->'%(TargetPath)')" Condition="'$(PublishProtocol)'=='Clickonce' And ('%(_NoneWithTargetPath.CopyToOutputDirectory)'=='Always' or '%(_NoneWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest')">
<_ClickOnceNoneItemsTemp Include="@(_NoneWithTargetPath->'%(TargetPath)')" Condition="'$(PublishProtocol)'=='Clickonce' And '%(_NoneWithTargetPath.CopyToPublishDirectory)' != 'Never' And ('%(_NoneWithTargetPath.CopyToOutputDirectory)'=='Always' or '%(_NoneWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest')">
<SavedIdentity>%(Identity)</SavedIdentity>
</_ClickOnceNoneItemsTemp>
<_ClickOnceNoneItems Include="@(_ClickOnceNoneItemsTemp->'%(SavedIdentity)')" Condition="'%(Identity)'=='@(PublishFile)' Or '%(Extension)'=='.exe' Or '%(Extension)'=='.dll'" />

<_ClickOnceFiles Include="@(ContentWithTargetPath);@(_DeploymentManifestIconFile);@(AppConfigWithTargetPath);@(NetCoreRuntimeJsonFilesForClickOnce);@(_ClickOnceRuntimeCopyLocalItems);@(_ClickOnceNoneItems);@(_ClickOnceTransitiveContentItems)"/>
<_ClickOnceFiles Include="@(_ClickOnceContentItems);@(_DeploymentManifestIconFile);@(AppConfigWithTargetPath);@(NetCoreRuntimeJsonFilesForClickOnce);@(_ClickOnceRuntimeCopyLocalItems);@(_ClickOnceNoneItems)" />
</ItemGroup>

<!-- For single file publish, we need to include the SF bundle EXE, application icon file and files excluded from the bundle EXE in the clickonce manifest -->
Expand Down

0 comments on commit 0247baa

Please sign in to comment.