Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit b79c3e4

Browse files
committed
When items are copied to output directory, add to package from the target path
Instead of adding them to the package from the original source path. This makes it possible for targets that tweak the outputs during build to include those modified outputs in the package. Concrete use case in our own NuGet.Build.Packaging.Version.props which is modified during build to reflect the actual nugetizer version being built.
1 parent dca29e4 commit b79c3e4

1 file changed

Lines changed: 38 additions & 10 deletions

File tree

src/Build/NuGet.Build.Packaging.Tasks/NuGet.Build.Packaging.Inference.targets

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,24 +88,52 @@ Copyright (c) .NET Foundation. All rights reserved.
8888
</_InferredPackageFile>
8989

9090
<!-- NOTE: Content is opt-out (must have Pack=false to exclude if IncludeContentInPackage=true) -->
91-
<_InferredPackageFile Include="@(ContentWithTargetPath->'%(FullPath)')"
91+
<!-- Stuff that is copied to output should be included from that output location -->
92+
<_InferredPackageFile Include="@(ContentWithTargetPath->'$(OutputPath)%(TargetPath)')"
9293
Condition="
93-
'%(ContentWithTargetPath.Pack)' == 'true' or
94-
'%(ContentWithTargetPath.Kind)' != '' or
95-
('$(IncludeContentInPackage)' == 'true' and '%(ContentWithTargetPath.Pack)' != 'false')">
94+
'%(ContentWithTargetPath.CopyToOutputDirectory)' != '' and
95+
(
96+
'%(ContentWithTargetPath.Pack)' == 'true' or
97+
'%(ContentWithTargetPath.Kind)' != '' or
98+
('$(IncludeContentInPackage)' == 'true' and '%(ContentWithTargetPath.Pack)' != 'false')
99+
)">
96100
<Kind Condition="'%(ContentWithTargetPath.Kind)' == '' and '%(ContentWithTargetPath.CopyToOutputDirectory)' != ''">$(PrimaryOutputKind)</Kind>
97-
<Kind Condition="'%(ContentWithTargetPath.Kind)' == '' and '%(ContentWithTargetPath.CopyToOutputDirectory)' == ''">Content</Kind>
101+
</_InferredPackageFile>
102+
<!-- Otherwise, include from source location -->
103+
<_InferredPackageFile Include="@(ContentWithTargetPath->'%(FullPath)')"
104+
Condition="
105+
'%(ContentWithTargetPath.CopyToOutputDirectory)' == '' and
106+
(
107+
'%(ContentWithTargetPath.Pack)' == 'true' or
108+
'%(ContentWithTargetPath.Kind)' != '' or
109+
('$(IncludeContentInPackage)' == 'true' and '%(ContentWithTargetPath.Pack)' != 'false')
110+
)">
111+
<Kind Condition="'%(ContentWithTargetPath.Kind)' == ''">Content</Kind>
98112
</_InferredPackageFile>
99113

100114
<!-- NOTE: None is also opt-out (must have Pack=false to exclude if IncludeNoneInPackage=true, but this property defaults to false) -->
101-
<_InferredPackageFile Include="@(_NoneWithTargetPath->'%(FullPath)')"
115+
<!-- Likewise, include from target path if it's copied, from source path otherwise -->
116+
<_InferredPackageFile Include="@(_NoneWithTargetPath->'$(OutputPath)%(TargetPath)')"
102117
Condition="
103-
'%(_NoneWithTargetPath.Pack)' == 'true' or
104-
'%(_NoneWithTargetPath.Kind)' != '' or
105-
('$(IncludeNoneInPackage)' == 'true' and '%(_NoneWithTargetPath.Pack)' != 'false')">
118+
'%(_NoneWithTargetPath.CopyToOutputDirectory)' != '' and
119+
(
120+
'%(_NoneWithTargetPath.Pack)' == 'true' or
121+
'%(_NoneWithTargetPath.Kind)' != '' or
122+
('$(IncludeNoneInPackage)' == 'true' and '%(_NoneWithTargetPath.Pack)' != 'false')
123+
)">
106124
<Kind Condition="'%(_NoneWithTargetPath.Kind)' == '' and '%(_NoneWithTargetPath.CopyToOutputDirectory)' != ''">$(PrimaryOutputKind)</Kind>
107-
<Kind Condition="'%(_NoneWithTargetPath.Kind)' == '' and '%(_NoneWithTargetPath.CopyToOutputDirectory)' == ''">None</Kind>
108125
</_InferredPackageFile>
126+
<_InferredPackageFile Include="@(_NoneWithTargetPath->'%(FullPath)')"
127+
Condition="
128+
'%(_NoneWithTargetPath.CopyToOutputDirectory)' == '' and
129+
(
130+
'%(_NoneWithTargetPath.Pack)' == 'true' or
131+
'%(_NoneWithTargetPath.Kind)' != '' or
132+
('$(IncludeNoneInPackage)' == 'true' and '%(_NoneWithTargetPath.Pack)' != 'false')
133+
)">
134+
<Kind Condition="'%(_NoneWithTargetPath.Kind)' == ''">None</Kind>
135+
</_InferredPackageFile>
136+
109137

110138
<_InferredPackageFile Include="@(PackageReference)" Condition="'%(Identity)' != 'NuGet.Build.Packaging'">
111139
<Kind>Dependency</Kind>

0 commit comments

Comments
 (0)