-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
NuGetizer.Inference.targets
626 lines (552 loc) · 35.6 KB
/
NuGetizer.Inference.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
<!--
***********************************************************************************************
NuGetizer.Inference.targets
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.
Copyright (c) .NET Foundation. All rights reserved.
***********************************************************************************************
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="NuGetizer.Tasks.InferImplicitPackageReference" AssemblyFile="NuGetizer.Tasks.dll" />
<UsingTask TaskName="NuGetizer.Tasks.EvaluateWildcards" AssemblyFile="NuGetizer.Tasks.dll" />
<PropertyGroup>
<!-- When ToolCommandName is set, infer that packaging should default to PackAsTool -->
<PackAsTool Condition="'$(PackAsTool)' == '' and '$(ToolCommandName)' != ''">true</PackAsTool>
<!-- The PackFolder of primary output (build, symbols, doc and satellite assemblies) set if PackBuildOutput = true -->
<PackFolder Condition="'$(PackFolder)' == ''">lib</PackFolder>
<!-- Whether to automatically include the $(PackageReadmeFile) file (by default, `readme.md` alongside the project) -->
<PackReadme Condition="'$(PackReadme)' == ''">true</PackReadme>
<!-- Whether to include @(Content) items with CopyToOutputDirectory != '' in the package -->
<PackContent Condition="'$(PackContent)' == ''">true</PackContent>
<!-- Whether to include @(BuiltProjectOutputGroupOutput), @(DocumentationProjectOutputGroupOutput) and @(SatelliteDllsProjectOutputGroupOutput) items in the package -->
<!-- When packing as a tool (SDK compatibility mode), primary output should not be packed by us, since the SDK PackTool target will already collect the output of /publish instead. -->
<PackBuildOutput Condition="'$(PackBuildOutput)' == '' and '$(IsPackagingProject)' != 'true' and '$(PackAsTool)' != 'true'">true</PackBuildOutput>
<!-- Whether to @(SatelliteDllsProjectOutputGroupOutput) items in the package. Used when inferring for PackBuildOutput=true -->
<PackSatelliteDlls Condition="'$(PackSatelliteDlls)' == '' and '$(PackBuildOutput)' == 'true'">true</PackSatelliteDlls>
<!-- Whether to include @(DebugSymbolsProjectOutputGroupOutput) items in the package -->
<PackSymbols Condition="'$(PackSymbols)' == '' and '$(PackBuildOutput)' == 'true'">true</PackSymbols>
<!-- Whether to include framework references (%(ReferencePath.ResolvedFrom)' == '{TargetFrameworkDirectory}') in the package -->
<PackFrameworkReferences Condition="'$(PackFrameworkReferences)' == '' and '$(PackDependencies)' == 'false'">false</PackFrameworkReferences>
<!-- Only default to true if the project isn't a nuget packaging project itself and its primary output is lib. -->
<PackFrameworkReferences Condition="'$(PackFrameworkReferences)' == '' and '$(IsPackagingProject)' != 'true' and '$(PackFolder)' == 'lib'">true</PackFrameworkReferences>
<!-- When PackFolder is build/buildTransitive, we default to packing None since it's most intuitive in that case -->
<PackNone Condition="'$(PackNone)' == '' and ('$(PackFolder)' == 'build' or '$(PackFolder)' == 'buildTransitive')">true</PackNone>
<_OutputFullPath Condition="$([System.IO.Path]::IsPathRooted($(OutputPath)))">$(OutputPath)</_OutputFullPath>
<_OutputFullPath Condition="'$(_OutputFullPath)' == ''">$(MSBuildProjectDirectory.TrimEnd('\'))\$(OutputPath)</_OutputFullPath>
<!-- Ensure built-in RunResolvePackageDependencies target emits stuff we need for inference of transitive dependencies -->
<EmitLegacyAssetsFileItems>true</EmitLegacyAssetsFileItems>
</PropertyGroup>
<PropertyGroup Label="Package Readme" Condition="'$(PackReadme)' == 'true' and '$(IsPackable)' == 'true'">
<PackageReadmeFilename>readme</PackageReadmeFilename>
<PackageReadmeExtension>.md</PackageReadmeExtension>
<PackageReadmeFilename Condition="'$(PackageReadmeFile)' != ''">$([System.IO.Path]::GetFilenameWithoutExtension('$(PackageReadmeFile)'))</PackageReadmeFilename>
<PackageReadmeExtension Condition="'$(PackageReadmeFile)' != ''">$([System.IO.Path]::GetExtension('$(PackageReadmeFile)'))</PackageReadmeExtension>
<PackageReadmeFile Condition="'$(PackageReadmeFile)' == '' and Exists('$(MSBuildProjectDirectory)\$(PackageReadmeFilename)$(PackageReadmeExtension)')">$(PackageReadmeFilename)$(PackageReadmeExtension)</PackageReadmeFile>
</PropertyGroup>
<ItemDefinitionGroup Label="Inference Defaults">
<Compile>
<!-- For Compile, the CodeLanguage should default to the project's default source extension -->
<CodeLanguage>$(DefaultLanguageSourceExtension.TrimStart('.'))</CodeLanguage>
<DefaultPackFolder>content</DefaultPackFolder>
<Pack Condition="'$(PackCompile)' == 'true'">true</Pack>
<BuildAction>Compile</BuildAction>
</Compile>
<Content>
<DefaultPackFolder>content</DefaultPackFolder>
<Pack Condition="'$(PackContent)' == 'true'">true</Pack>
<BuildAction>Content</BuildAction>
</Content>
<EmbeddedResource>
<DefaultPackFolder>content</DefaultPackFolder>
<Pack Condition="'$(PackEmbeddedResource)' == 'true'">true</Pack>
<BuildAction>EmbeddedResource</BuildAction>
</EmbeddedResource>
<None>
<DefaultPackFolder>none</DefaultPackFolder>
<Pack Condition="'$(PackNone)' == 'true'">true</Pack>
<BuildAction>None</BuildAction>
</None>
<ApplicationDefinition>
<DefaultPackFolder>content</DefaultPackFolder>
<Pack Condition="'$(PackApplicationDefinition)' == 'true'">true</Pack>
<BuildAction>ApplicationDefinition</BuildAction>
</ApplicationDefinition>
<Page>
<DefaultPackFolder>content</DefaultPackFolder>
<Pack Condition="'$(PackPage)' == 'true'">true</Pack>
<BuildAction>Page</BuildAction>
</Page>
<Resource>
<DefaultPackFolder>content</DefaultPackFolder>
<Pack Condition="'$(PackResource)' == 'true'">true</Pack>
<BuildAction>Resource</BuildAction>
</Resource>
<SplashScreen>
<DefaultPackFolder>content</DefaultPackFolder>
<Pack Condition="'$(PackSplashScreen)' == 'true'">true</Pack>
<BuildAction>SplashScreen</BuildAction>
</SplashScreen>
<DesignData>
<DefaultPackFolder>content</DefaultPackFolder>
<Pack Condition="'$(PackDesignData)' == 'true'">true</Pack>
<BuildAction>DesignData</BuildAction>
</DesignData>
<DesignDataWithDesignTimeCreatableTypes>
<DefaultPackFolder>content</DefaultPackFolder>
<Pack Condition="'$(PackDesignDataWithDesignTimeCreatableTypes)' == 'true'">true</Pack>
<BuildAction>DesignDataWithDesignTimeCreatableTypes</BuildAction>
</DesignDataWithDesignTimeCreatableTypes>
<CodeAnalysisDictionary>
<DefaultPackFolder>content</DefaultPackFolder>
<Pack Condition="'$(PackCodeAnalysisDictionary)' == 'true'">true</Pack>
<BuildAction>CodeAnalysisDictionary</BuildAction>
</CodeAnalysisDictionary>
<AndroidAsset>
<DefaultPackFolder>content</DefaultPackFolder>
<Pack Condition="'$(PackAndroidAsset)' == 'true'">true</Pack>
<BuildAction>AndroidAsset</BuildAction>
</AndroidAsset>
<AndroidResource>
<DefaultPackFolder>content</DefaultPackFolder>
<Pack Condition="'$(PackAndroidResource)' == 'true'">true</Pack>
<BuildAction>AndroidResource</BuildAction>
</AndroidResource>
<BundleResource>
<DefaultPackFolder>content</DefaultPackFolder>
<Pack Condition="'$(PackBundleResource)' == 'true'">true</Pack>
<BuildAction>BundleResource</BuildAction>
</BundleResource>
<PackInference>
<PackExclude />
</PackInference>
<InferenceCandidate>
<DefaultPackFolder />
<Pack />
<PackFolder />
<PackagePath />
<PackageReference />
<ShouldPack />
<TargetPath />
</InferenceCandidate>
<_InferredPackageFile>
<FrameworkSpecific />
</_InferredPackageFile>
</ItemDefinitionGroup>
<!-- Extend some built-in items with metadata we use in our inference targets -->
<ItemDefinitionGroup>
<PackageReference>
<Pack />
<Pack Condition="'$(PackDependencies)' == 'false'">false</Pack>
<PrivateAssets />
</PackageReference>
<ImplicitPackageReference>
<Pack />
<Pack Condition="'$(PackDependencies)' == 'false'">false</Pack>
<PrivateAssets />
</ImplicitPackageReference>
<ReferenceCopyLocalPathsOutputGroupOutput>
<Facade>false</Facade>
<FrameworkFile>false</FrameworkFile>
<NuGetPackageId />
<Pack />
</ReferenceCopyLocalPathsOutputGroupOutput>
<ReferencePath>
<Facade>false</Facade>
<FrameworkFile>false</FrameworkFile>
<NuGetPackageId />
<Pack />
</ReferencePath>
<_ReferenceRelatedPaths>
<Facade>false</Facade>
<FrameworkFile>false</FrameworkFile>
<NuGetPackageId />
<Pack />
</_ReferenceRelatedPaths>
<PackageDependencies>
<ParentPackage />
</PackageDependencies>
</ItemDefinitionGroup>
<PropertyGroup>
<GetPackageContentsDependsOn>
$(GetPackageContentsDependsOn);
_SetDefaultPackageReferencePack;
_SetPackTargetFramework;
InferPackageContents
</GetPackageContentsDependsOn>
</PropertyGroup>
<ItemGroup>
<!-- NuGetizer should never pack transitively (i.e. SponsorLink assets), even
when PrivateAssets=all is used due to being a development dependency now. -->
<PackageReference Update="NuGetizer" PackTransitively="false" />
</ItemGroup>
<Target Name="_SetDefaultPackageReferencePack" Condition="'$(PackFolder)' == 'build' or '$(PackFolder)' == 'buildTransitive'"
BeforeTargets="InferPrimaryOutputDependencies;InferPackageContents">
<ItemGroup>
<PackageReference Update="@(PackageReference)"
Condition="$([MSBuild]::ValueOrDefault('%(Identity)', '').StartsWith('Microsoft.Build')) and '%(Pack)' != 'true'"
Pack="false" />
</ItemGroup>
</Target>
<!--
Updates None/Content to have the proper packaging metadata for the icon metadata.
The PackageIcon can point to a relative project directory path, or a root relative path.
In either case, the PackageIcon becomes the package path.
The item can be a linked file too, in which case the PackageIcon should match the link
within the project structure.
If the item was Content, we change its packing properties so it doesn't become a
contentFiles item in the package, which would end up in the users' solution.
-->
<Target Name="_InferPackageIcon" Condition="'$(PackageIcon)' != ''">
<ItemGroup>
<None Update="@(None)"
Pack="true"
PackagePath="%(None.Link)"
Condition="%(None.Identity) == '$(PackageIcon)' or %(None.Link) == '$(PackageIcon)'" />
<Content Update="@(Content)"
Pack="true"
BuildAction="None"
PackFolder="None"
PackagePath="%(Content.Link)"
Condition="%(Content.Identity) == '$(PackageIcon)' or %(Content.Link) == '$(PackageIcon)'" />
</ItemGroup>
</Target>
<Target Name="_CollectInferenceCandidates" Inputs="@(PackInference)" Outputs="|%(PackInference.Identity)|">
<PropertyGroup>
<PackExclude>%(PackInference.PackExclude)</PackExclude>
<PackInferenceIdentity>%(PackInference.Identity)</PackInferenceIdentity>
</PropertyGroup>
<ItemGroup Condition="'$(PackInferenceIdentity)' == 'None' and ('$(PackFolder)' == 'build' or '$(PackFolder)' == 'buildTransitive')">
<None Update="@(None)" Condition="'%(None.PackFolder)' == ''" PackFolder="$(PackFolder)" />
<None Update="@(None)" Condition="'%(None.FrameworkSpecific)' == ''" FrameworkSpecific="$(PackFrameworkSpecific)" />
</ItemGroup>
<!-- If we have an exclude wildcard to evaluate, do so and keep only non-matching items -->
<EvaluateWildcards Condition="'$(PackExclude)' != ''" Items="@(%(PackInference.Identity))" Wildcards="$(PackExclude)">
<Output TaskParameter="NonMatchingItems" ItemName="InferenceCandidate" />
</EvaluateWildcards>
<!-- Otherwise, just include all items as candidates -->
<ItemGroup Condition="'$(PackExclude)' == ''">
<InferenceCandidate Include="@(%(PackInference.Identity))" />
</ItemGroup>
</Target>
<Target Name="InferToolContents" BeforeTargets="_CollectInferenceCandidates"
Condition="'$(UsingMicrosoftNETSdk)' == 'true' and '$(PackAsTool)' == 'true'"
DependsOnTargets="PackTool">
<PropertyGroup>
<!-- When packing as SDK pack, primary output should not be packed by us, since the SDK PackTool will
already collect the output of /publish instead. -->
<PackBuildOutput>false</PackBuildOutput>
</PropertyGroup>
<ItemGroup>
<!-- Ensure we have a full relative path including file name as PackagePath -->
<TfmSpecificPackageFile>
<PackageFile>%(Filename)%(Extension)</PackageFile>
</TfmSpecificPackageFile>
<TfmSpecificPackageFile>
<PackagePathHasFilename>false</PackagePathHasFilename>
<PackagePathHasFilename Condition="$([MSBuild]::ValueOrDefault('%(PackagePath)', '').EndsWith('%(PackageFile)'))"></PackagePathHasFilename>
</TfmSpecificPackageFile>
<TfmSpecificPackageFile Condition="'%(PackagePathHasFilename)' == 'false'">
<PackagePath>$([MSBuild]::ValueOrDefault('%(PackagePath)', '').TrimEnd('/'))/%(PackageFile)</PackagePath>
</TfmSpecificPackageFile>
<None Include="@(TfmSpecificPackageFile)" />
</ItemGroup>
</Target>
<Target Name="InferPackageContents" DependsOnTargets="$(InferPackageContentsDependsOn);_InferPackageIcon;_CollectInferenceCandidates" Returns="@(PackageFile)">
<Error Code="NG1004" Condition="'$(PackAsTool)' == 'true' and '$(PackAsPublish)' == 'true'" Text="PackAsTool and PackAsPublish are mutually exclusive." />
<!-- Even if all these conditions are false, the user can still explicitly pack the file, of course -->
<ItemGroup Label="Readme" Condition="'$(PackReadme)' == 'true' and '$(PackageReadmeFile)' != '' and '$(IsPackable)' == 'true'">
<_ExistingReadme Include="@(None -> WithMetadataValue('Identity', '$(PackageReadmeFile)'))" />
<_ExistingReadme Include="@(Content -> WithMetadataValue('Identity', '$(PackageReadmeFile)'))" Condition="'@(_ExistingReadme)' == ''" />
<_ExistingReadme Include="$(MSBuildProjectDirectory)\$(PackageReadmeFile)" Condition="'@(_ExistingReadme)' == '' and Exists('$(MSBuildProjectDirectory)\$(PackageReadmeFile)')" />
<InferenceCandidate Include="@(_ExistingReadme -> Distinct())"
PackagePath="%(Filename)%(Extension)"
Condition="'%(Extension)' == '$(PackageReadmeExtension)'" />
</ItemGroup>
<ItemGroup Label="Icon" Condition="'$(PackageIcon)' != ''">
<_PackageIcon Include="$(PackageIcon)" />
</ItemGroup>
<PropertyGroup Label="Icon" Condition="'$(PackageIcon)' != '' and @(_PackageIcon -> Count()) == '1'">
<PackageIconExists Condition="Exists(@(_PackageIcon -> '%(FullPath)'))"></PackageIconExists>
<PackageIconFilename Condition="'$(PackageIconExists)' == 'true'">@(_PackageIcon -> '%(Filename)')</PackageIconFilename>
<PackageIconExtension Condition="'$(PackageIconExists)' == 'true'">@(_PackageIcon -> '%(Extension)')</PackageIconExtension>
</PropertyGroup>
<!-- Even if all these conditions are false, the user can still explicitly pack the icon file, of course -->
<ItemGroup Label="Icon" Condition="'$(PackageIcon)' != ''">
<_ExistingIcon Include="@(None -> WithMetadataValue('Filename', '$(PackageIconFilename)'))" />
<_ExistingIcon Include="@(Content -> WithMetadataValue('Filename', '$(PackageIconFilename)'))" Condition="'@(_ExistingIcon)' == ''" />
<_ExistingIcon Include="$(MSBuildProjectDirectory)\$(PackageIconFilename)$(PackageIconExtension)" Condition="'@(_ExistingIcon)' == '' and Exists('$(MSBuildProjectDirectory)\$(PackageIconFilename)$(PackageIconExtension)')" />
<InferenceCandidate Include="@(_ExistingIcon -> Distinct())"
PackagePath="%(Filename)%(Extension)"
Condition="'%(Extension)' == '$(PackageIconExtension)'" />
</ItemGroup>
<ItemGroup>
<InferenceCandidate>
<ShouldPack Condition="('%(Pack)' == 'true' or '%(PackagePath)' != '' or '%(PackFolder)' != '' or '%(PackageReference)' != '') and '%(Pack)' != 'false'">true</ShouldPack>
</InferenceCandidate>
<!-- No need to re-assign a target path if the item already provides one. We do this because otherwise the built-in AssignTargetPath
task unconditionally re-sets it. See https://github.com/dotnet/msbuild/blob/master/src/Tasks/AssignTargetPath.cs -->
<_InferenceCandidateWithTargetPath Include="@(InferenceCandidate)" Condition="'%(ShouldPack)' == 'true' and '%(TargetPath)' != ''" />
</ItemGroup>
<AssignTargetPath Files="@(InferenceCandidate)" RootFolder="$(MSBuildProjectDirectory)"
Condition="'%(ShouldPack)' == 'true' and '%(TargetPath)' == ''">
<Output TaskParameter="AssignedFiles" ItemName="_InferenceCandidateWithTargetPath" />
</AssignTargetPath>
<ItemGroup Label="PackInference">
<_InferenceCandidateWithTargetPath Condition="'%(PackFolder)' == ''">
<!-- Items that are copied to the output directory adopt the kind of the build output -->
<PackFolder Condition="'%(_InferenceCandidateWithTargetPath.CopyToOutputDirectory)' != '' or
'%(_InferenceCandidateWithTargetPath.CopyToOutputDirectory)' != 'Never'">$(PackFolder)</PackFolder>
<!-- Otherwise they take on whichever is the default for their item type, as defined by their PackInference item -->
<PackFolder Condition="'%(_InferenceCandidateWithTargetPath.CopyToOutputDirectory)' == '' or
'%(_InferenceCandidateWithTargetPath.CopyToOutputDirectory)' == 'Never'">%(_InferenceCandidateWithTargetPath.DefaultPackFolder)</PackFolder>
</_InferenceCandidateWithTargetPath>
<!-- Items that are copied to the output directory are included from the target path -->
<_InferredPackageFile Include="@(_InferenceCandidateWithTargetPath -> '$(_OutputFullPath)\%(TargetPath)')"
Condition="'%(_InferenceCandidateWithTargetPath.CopyToOutputDirectory)' != '' and
'%(_InferenceCandidateWithTargetPath.CopyToOutputDirectory)' != 'Never'" />
<!-- Otherwise, they are included from the source location -->
<_InferredPackageFile Include="@(_InferenceCandidateWithTargetPath->'%(FullPath)')"
Condition="'%(_InferenceCandidateWithTargetPath.CopyToOutputDirectory)' == '' or
'%(_InferenceCandidateWithTargetPath.CopyToOutputDirectory)' == 'Never'" />
</ItemGroup>
<ItemGroup Label="BuildOutput Inference" Condition="'$(PackBuildOutput)' == 'true' and '$(PackAsPublish)' != 'true'">
<!-- Unfortunately, even with https://github.com/Microsoft/msbuild/pull/1115, when multi-targeting
.NETFramework, the desktop WinFX.targets are imported which don't have the fix, so we need to
do it "the old way" for this particular output group -->
<_SatelliteDllsProjectOutputGroupOutput Include="@(SatelliteDllsProjectOutputGroupOutput)"
FinalOutputPath="%(FullPath)"
Condition="'$(PackSatelliteDlls)' != 'false'"/>
<_InferredProjectOutput Include="@(BuiltProjectOutputGroupOutput -> '%(FinalOutputPath)');
@(BuiltProjectOutputGroupKeyOutput -> '%(FinalOutputPath)');
@(DocumentationProjectOutputGroupOutput -> '%(FinalOutputPath)');
@(_SatelliteDllsProjectOutputGroupOutput -> '%(FinalOutputPath)')">
<PackFolder>$(PackFolder)</PackFolder>
<FrameworkSpecific>$(PackFrameworkSpecific)</FrameworkSpecific>
</_InferredProjectOutput>
<_InferredProjectOutput Include="@(DebugSymbolsProjectOutputGroupOutput -> '%(FinalOutputPath)')"
Condition="'$(PackSymbols)' != 'false'">
<PackFolder>$(PackFolder)</PackFolder>
<FrameworkSpecific>$(PackFrameworkSpecific)</FrameworkSpecific>
</_InferredProjectOutput>
<_InferredPackageFile Include="@(_InferredProjectOutput -> Distinct())" />
</ItemGroup>
<ItemGroup Label="SatelliteDll Resources from Dependencies" Condition="'$(PackBuildOutput)' == 'true' and '$(PackAsPublish)' != 'true'">
<!-- Include transitive resources if their NuGetPackageId has PrivateAssets=all and Pack!=false only. -->
<_InferredPackageFile Include="@(ResourceCopyLocalItems)"
PackFolder="$(PackFolder)"
TargetPath="%(ResourceCopyLocalItems.DestinationSubPath)"
FrameworkSpecific="$(PackFrameworkSpecific)"
Condition="$(PrivatePackageReferenceIds.Contains(';%(ResourceCopyLocalItems.NuGetPackageId);'))" />
</ItemGroup>
<ItemGroup Label="Publishable Inference" Condition="'$(PackAsPublish)' == 'true' and '$(PackAsTool)' != 'true'">
<_InferredPublishItem Include="@(PublishItemsOutputGroupOutputs -> '%(OutputPath)')" />
<_InferredPackageFile Include="@(_InferredPublishItem -> '%(FullPath)')">
<PackFolder>$(PackFolder)</PackFolder>
<FrameworkSpecific>false</FrameworkSpecific>
<!-- NOTE: we don't set `PackFrameworkSpecific` since we're not packing the build output
but rather the *publish* output. Users could change that by setting a TF-specific PackFolder -->
</_InferredPackageFile>
</ItemGroup>
<ItemGroup Label="References Inference">
<_InferredPackageFile Include="@(PackageReference)"
Condition="'$(PackAsTool)' != 'true' and
'$(PackAsPublish)' != 'true' and
'%(PackageReference.Identity)' != 'NuGetizer' and
'%(PackageReference.Identity)' != 'NETStandard.Library' and
'%(PackageReference.Pack)' != 'false' and
('%(PackageReference.PrivateAssets)' != 'all' or '%(PackageReference.Pack)' == 'true')">
<PackFolder>Dependency</PackFolder>
<!--<FrameworkSpecific Condition="'$(PackFrameworkSpecific)' == 'true'">true</FrameworkSpecific>-->
</_InferredPackageFile>
<!-- We can't use %(FrameworkFile)==true because it's not defined for raw file references and
it also includes mscorlib which we don't need
TBD: maybe include ResolvedFrom=ImplicitlyExpandDesignTimeFacades too? -->
<_InferredPackageFile Include="@(ReferencePath->'%(OriginalItemSpec)')"
Condition="'$(PackAsTool)' != 'true' and
'$(PackAsPublish)' != 'true' and
'$(PackFrameworkReferences)' == 'true' and
'%(ReferencePath.ResolvedFrom)' == '{TargetFrameworkDirectory}' and
'%(ReferencePath.Pack)' != 'false'">
<PackFolder>FrameworkReference</PackFolder>
</_InferredPackageFile>
</ItemGroup>
<ItemGroup>
<!-- PackageId metadata on all PackageFile items means we can tell appart which ones came from which dependencies
NOTE: if PackageId is empty, we won't generate a manifest and it means the files need to be packed with the
current project. -->
<PackageFile Include="@(_InferredPackageFile)">
<Source>Implicit</Source>
<PackageId Condition="'$(IsPackable)' == 'true'">$(PackageId)</PackageId>
<Platform>$(Platform)</Platform>
<OriginalTargetFramework>$(PackTargetFramework)</OriginalTargetFramework>
<DefaultTargetFramework Condition="'$(IsPackagingProject)' != 'true' or '$(PackFrameworkSpecific)' == 'true'">$(PackTargetFramework)</DefaultTargetFramework>
</PackageFile>
</ItemGroup>
</Target>
<Target Name="_UpdatePackageReferenceVersions"
Inputs="@(PackageReference)"
Outputs="|%(Identity)|"
Condition="'$(UsingMicrosoftNETSdk)' == 'true'"
DependsOnTargets="RunResolvePackageDependencies"
Returns="@(_CentrallyManagedDependency)">
<PropertyGroup>
<_CandidatePackageId>%(PackageReference.Identity)</_CandidatePackageId>
<_CandidatePackageVersion>%(PackageReference.Version)</_CandidatePackageVersion>
<_CandidatePackageIsImplicit>%(PackageReference.IsImplicitlyDefined)</_CandidatePackageIsImplicit>
</PropertyGroup>
<ItemGroup Condition="$(_CandidatePackageIsImplicit) != 'true' and
($(_CandidatePackageVersion) == '' or $(_CandidatePackageVersion.Contains('*')))">
<_ResolvedPackageDependency Include="@(PackageDependencies)"
Condition="$([MSBuild]::ValueOrDefault('%(Identity)', '').StartsWith('$(_CandidatePackageId)/')) and
$([MSBuild]::ValueOrDefault('%(ParentPackage)', '')) == ''" />
</ItemGroup>
<PropertyGroup Condition="'@(_ResolvedPackageDependency)' != ''">
<_ResolvedPackageDependency>%(_ResolvedPackageDependency.Identity)</_ResolvedPackageDependency>
<_ResolvedPackageVersion>$(_ResolvedPackageDependency.Replace('$(_CandidatePackageId)/', ''))</_ResolvedPackageVersion>
</PropertyGroup>
<ItemGroup Condition="'$(_ResolvedPackageVersion)' != ''">
<PackageReference Update="@(PackageReference)" Version="$(_ResolvedPackageVersion)" />
</ItemGroup>
</Target>
<Target Name="_CollectPrimaryOutputDependencies"
DependsOnTargets="ReferenceCopyLocalPathsOutputGroup;RunResolvePackageDependencies"
Returns="@(ImplicitPackageReference)">
<Error Code="NG1003" Text="Centrally managed package versions is only supported when using the Microsoft.NET.Sdk."
Condition="'$(ManagePackageVersionsCentrally)' == 'true' and '$(UsingMicrosoftNETSdk)' != 'true'" />
<ItemGroup>
<!-- By adding the files in this order, we ensure that Distinct() will preserve this preference order.
We add them with identities that will find the duplicate files resolved from the same package id,
so we can de-duplicate using the given preference order. -->
<_CopyLocalReference Include="@(ReferenceCopyLocalPathsOutputGroupOutput->'%(NuGetPackageId)|%(Filename)%(Extension)')" OriginalItemSpec="%(Identity)" />
<_CopyLocalReference Include="@(ReferencePath->'%(NuGetPackageId)|%(Filename)%(Extension)')" OriginalItemSpec="%(Identity)" />
<_CopyLocalReference Include="@(_ReferenceRelatedPaths->'%(NuGetPackageId)|%(Filename)%(Extension)')" OriginalItemSpec="%(Identity)" />
<_CopyLocalReferenceDistinct Include="@(_CopyLocalReference->Distinct())" />
<_ReferenceCopyLocalPaths Include="@(_CopyLocalReferenceDistinct->'%(OriginalItemSpec)')" />
<_PrimaryOutputRelatedFile Include="@(_ReferenceCopyLocalPaths)"
Condition="'%(NuGetPackageId)' != 'NETStandard.Library' and
'%(Facade)' != 'true' and
'%(FrameworkFile)' != 'true' and
'%(Pack)' != 'false'"/>
<_TransitivePackageReference Include="@(PackageReference -> WithMetadataValue('PrivateAssets', 'all'))"
Condition="'%(PackageReference.IsImplicitlyDefined)' != 'true' and '%(PackageReference.Pack)' != 'false' and '%(PackageReference.PackTransitive)' != 'false'"/>
</ItemGroup>
<InferImplicitPackageReference Condition="'@(_TransitivePackageReference)' != '' and '@(PackageDependencies)' != ''"
PackageReferences="@(_TransitivePackageReference)"
PackageDependencies="@(PackageDependencies)">
<Output TaskParameter="ImplicitPackageReferences" ItemName="ImplicitPackageReference" />
</InferImplicitPackageReference>
<ItemGroup>
<_PrivatePackageReference Include="@(PackageReference)" Condition="%(PackageReference.Pack) != 'false' and '%(PackageReference.PrivateAssets)' == 'all'" />
<_PrivatePackageReference Include="@(ImplicitPackageReference)" Condition="%(PackageReference.Pack) != 'false' and '%(PackageReference.PrivateAssets)' == 'all'" />
</ItemGroup>
<PropertyGroup>
<PrivatePackageReferenceIds>;@(_PrivatePackageReference);</PrivatePackageReferenceIds>
</PropertyGroup>
</Target>
<Target Name="_ResolvePackageDependencies" Condition="'$(UsingMicrosoftNETSdk)' == 'true'" DependsOnTargets="RunResolvePackageDependencies" />
<Target Name="InferPrimaryOutputDependencies"
Condition="'$(PackAsTool)' != 'true' and '$(PackAsPublish)' != 'true'"
Inputs="@(_PrimaryOutputRelatedFile)"
Outputs="|%(_PrimaryOutputRelatedFile.NuGetPackageId)|"
Returns="@(_InferredPackageFile)"
DependsOnTargets="_ResolvePackageDependencies;_CollectPrimaryOutputDependencies">
<ItemGroup>
<_NuGetPackageId Include="@(_PrimaryOutputRelatedFile -> '%(NuGetPackageId)')" Condition="'%(NuGetPackageId)' != 'NETStandard.Library'" />
</ItemGroup>
<PropertyGroup>
<_NuGetPackageId>@(_NuGetPackageId -> Distinct())</_NuGetPackageId>
</PropertyGroup>
<ItemGroup>
<_PrimaryPackageReference Include="@(ImplicitPackageReference);@(PackageReference)" Condition="'$(_NuGetPackageId)' != '' and '%(Identity)' == '$(_NuGetPackageId)'" />
</ItemGroup>
<PropertyGroup>
<_PrivateAssets>%(_PrimaryPackageReference.PrivateAssets)</_PrivateAssets>
<_ShouldPack>%(_PrimaryPackageReference.Pack)</_ShouldPack>
<_ShouldIncludeAssetsRegex>$(_NuGetPackageId)\\.+\\$(_PrivateAssets)\\.*</_ShouldIncludeAssetsRegex>
</PropertyGroup>
<ItemGroup>
<_PrimaryOutputRelatedFileRef Include="@(_PrimaryOutputRelatedFile)"
Condition="$([MSBuild]::ValueOrDefault('%(Directory)', '').Contains('/ref/')) or
$([MSBuild]::ValueOrDefault('%(Directory)', '').Contains('\ref\'))" />
<_PrimaryOutputRelatedFileLib Include="@(_PrimaryOutputRelatedFileRef -> '$([MSBuild]::ValueOrDefault('%(FullPath)', '').Replace(/ref/, /lib/).Replace(\ref\, \lib\))')">
<OriginalItemSpec>%(_PrimaryOutputRelatedFileRef.Identity)</OriginalItemSpec>
</_PrimaryOutputRelatedFileLib>
<_ReplacedRefRelatedFile Include="@(_PrimaryOutputRelatedFileLib)" Condition="Exists('%(FullPath)')" />
<_PrimaryOutputFinalFile Include="@(_ReplacedRefRelatedFile)"
Condition="'%(_ReplacedRefRelatedFile.FrameworkFile)' != 'true'" />
<_PrimaryOutputFinalFile Include="@(_PrimaryOutputRelatedFile)" Exclude="@(_ReplacedRefRelatedFile -> '%(OriginalItemSpec)')"
Condition="'%(_PrimaryOutputRelatedFile.FrameworkFile)' != 'true'" />
</ItemGroup>
<ItemGroup Condition="'$(_ShouldPack)' != 'false' and '$(_PrivateAssets)' == 'all'">
<_InferredPackageFile Include="@(_PrimaryOutputFinalFile)">
<PackFolder>$(PackFolder)</PackFolder>
<FrameworkSpecific>$(PackFrameworkSpecific)</FrameworkSpecific>
</_InferredPackageFile>
</ItemGroup>
<ItemGroup Condition="'$(_ShouldPack)' != 'false' and '$(_PrivateAssets)' != 'all' and '$(_PrivateAssets)' != 'none' and '$(_PrivateAssets)' != ''">
<!-- In this case, we only add files that have a matching path to the private assets value.
i.e. for Mono.Options, PrivateAssets=lib, we'll include the file if its full path contains
'Mono.Options\*\lib\*', meaning the file is a lib. -->
<_InferredPackageFile Include="@(_PrimaryOutputFinalFile)"
Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('%(_PrimaryOutputFinalFile.FullPath)', '$(_ShouldIncludeAssetsRegex)', 'RegexOptions.IgnoreCase')) == 'true'">
<PackFolder>$(PackFolder)</PackFolder>
<FrameworkSpecific>$(PackFrameworkSpecific)</FrameworkSpecific>
</_InferredPackageFile>
</ItemGroup>
</Target>
<Target Name="_SetInferenceProperties" AfterTargets="_SetPropertiesFromCapabilities">
<PropertyGroup>
<!-- NOTE: this avoids taking dependencies on targets that are only available when the project supports the concept of references -->
<_SupportsReferences Condition="
$(_AllProjectCapabilities.Contains('AssemblyReferences')) or
$(_AllProjectCapabilities.Contains('COMReferences')) or
$(_AllProjectCapabilities.Contains('ProjectReferences')) or
$(_AllProjectCapabilities.Contains('PackageReferences')) or
$(_AllProjectCapabilities.Contains('WinRTReferences')) or
$(_AllProjectCapabilities.Contains('SDKReferences'))">true</_SupportsReferences>
<!-- Very constrained scenario for CLI pack with dotnet pack -no-build, which otherwise triggers
transitive project references to be built when that's not what the user wants. -->
<DisableTransitiveProjectReferences Condition="'$(_SupportsReferences)' == 'true' and
'$(_IsPacking)' == 'true' and
'$(NoBuild)' == 'true' and
'$(BuildingInsideVisualStudio)' != 'true' and
'$(DesignTimeBuild)' != 'true'" >true</DisableTransitiveProjectReferences>
<InferPackageContentsDependsOn Condition="'$(_SupportsReferences)' == 'true'">
ResolveReferences;
_UpdatePackageReferenceVersions;
InferPrimaryOutputDependencies
</InferPackageContentsDependsOn>
<InferPackageContentsDependsOn Condition="$(_AllProjectCapabilities.Contains('PackageReferences')) and
'$(UsingMicrosoftNETSdk)' == 'true' and
'$(ManagePackageVersionsCentrally)' == 'true'">
$(InferPackageContentsDependsOn);
_UpdatePackageReferenceVersions
</InferPackageContentsDependsOn>
<InferPackageContentsDependsOn>
$(InferPackageContentsDependsOn);
GetPackageTargetPath
</InferPackageContentsDependsOn>
<InferPackageContentsDependsOn Condition="$(_AllProjectCapabilities.Contains('AllTargetOutputGroups'))">
$(InferPackageContentsDependsOn);
AllProjectOutputGroups
</InferPackageContentsDependsOn>
<!-- Smarter inference for publishable console apps
* PackAsTool should still do what SDK Pack does.
* PackAsPublish=false turns off this inference.
* IsPublishable is set by the SDK, but for everything, even libs :(,
but we can use that as an alternative off switch too.
* Finally, the CrossPlatformExecutable capability is set by the SDK for
.NETCoreApp projects that are actually executable (Exe or WinExe)
-->
<PackAsPublish Condition="'$(PackAsPublish)' == '' and
'$(PackAsTool)' != 'true' and
'$(IsPublishable)' == 'true' and
$(_AllProjectCapabilities.Contains('CrossPlatformExecutable'))">true</PackAsPublish>
<InferPackageContentsDependsOn Condition="'$(PackAsPublish)' == 'true'">
$(InferPackageContentsDependsOn);
PublishItemsOutputGroup
</InferPackageContentsDependsOn>
</PropertyGroup>
</Target>
</Project>