-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Microsoft.NET.Sdk.targets
1302 lines (1109 loc) · 74.1 KB
/
Microsoft.NET.Sdk.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
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!--
***********************************************************************************************
Microsoft.NET.Sdk.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 ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="Microsoft.NET.Sdk.Common.targets" />
<PropertyGroup>
<EnableDynamicLoading Condition="'$(EnableDynamicLoading)' == '' and '$(EnableComHosting)' == 'true'">true</EnableDynamicLoading>
</PropertyGroup>
<ImportGroup>
<Import Project="$(MSBuildThisFileDirectory)Microsoft.PackageDependencyResolution.targets" Condition="Exists('$(MSBuildThisFileDirectory)Microsoft.PackageDependencyResolution.targets') and ('$(Language)' != 'C++' or '$(_EnablePackageReferencesInVCProjects)' == 'true')" />
<Import Project="$(MSBuildThisFileDirectory)Microsoft.PackageDependencyResolutionStubs.targets" Condition="Exists('$(MSBuildThisFileDirectory)Microsoft.PackageDependencyResolutionStubs.targets') and ('$(Language)' == 'C++' and '$(_EnablePackageReferencesInVCProjects)' != 'true')" />
</ImportGroup>
<Import Project="Microsoft.NET.Sdk.DefaultItems.targets" />
<Import Project="Microsoft.NET.Sdk.FrameworkReferenceResolution.targets" />
<UsingTask TaskName="GenerateDepsFile" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />
<UsingTask TaskName="GenerateRuntimeConfigurationFiles" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />
<UsingTask TaskName="GetAssemblyVersion" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />
<UsingTask TaskName="GenerateSatelliteAssemblies" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />
<PropertyGroup>
<DisableStandardFrameworkResolution Condition="'$(DisableStandardFrameworkResolution)' == ''">$(_IsNETCoreOrNETStandard)</DisableStandardFrameworkResolution>
</PropertyGroup>
<PropertyGroup>
<GenerateRuntimeConfigurationFiles Condition=" '$(GenerateRuntimeConfigurationFiles)' == '' and '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and ('$(HasRuntimeOutput)' == 'true' or '$(EnableComHosting)' == 'true' or '$(EnableDynamicLoading)' == 'true') ">true</GenerateRuntimeConfigurationFiles>
<AlwaysIncludeCoreFrameworkInRuntimeConfig Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionLessThan('$(TargetFrameworkVersion)', '6.0'))">false</AlwaysIncludeCoreFrameworkInRuntimeConfig>
<AlwaysIncludeCoreFrameworkInRuntimeConfig Condition="'$(AlwaysIncludeCoreFrameworkInRuntimeConfig)' == ''">true</AlwaysIncludeCoreFrameworkInRuntimeConfig>
<UserRuntimeConfig Condition=" '$(UserRuntimeConfig)' == '' ">$(MSBuildProjectDirectory)/runtimeconfig.template.json</UserRuntimeConfig>
<GenerateSatelliteAssembliesForCore Condition=" '$(GenerateSatelliteAssembliesForCore)' == '' and '$(MSBuildRuntimeType)' == 'Core' ">true</GenerateSatelliteAssembliesForCore>
<ComputeNETCoreBuildOutputFiles Condition=" '$(ComputeNETCoreBuildOutputFiles)' == '' and '$(TargetFrameworkIdentifier)' == '.NETCoreApp'">true</ComputeNETCoreBuildOutputFiles>
<_GenerateRuntimeConfigurationPropertyInputsCache Condition="'$(_GenerateRuntimeConfigurationPropertyInputsCache)' == ''">$(IntermediateOutputPath)$(MSBuildProjectName).genruntimeconfig.cache</_GenerateRuntimeConfigurationPropertyInputsCache>
<_GenerateRuntimeConfigurationPropertyInputsCache>$([MSBuild]::NormalizePath($(MSBuildProjectDirectory), $(_GenerateRuntimeConfigurationPropertyInputsCache)))</_GenerateRuntimeConfigurationPropertyInputsCache>
<_GeneratePublishDependencyFilePropertyInputsCache Condition="'$(_GeneratePublishDependencyFilePropertyInputsCache)' == ''">$(IntermediateOutputPath)$(MSBuildProjectName).genpublishdeps.cache</_GeneratePublishDependencyFilePropertyInputsCache>
<_GeneratePublishDependencyFilePropertyInputsCache>$([MSBuild]::NormalizePath($(MSBuildProjectDirectory), $(_GeneratePublishDependencyFilePropertyInputsCache)))</_GeneratePublishDependencyFilePropertyInputsCache>
<_GenerateSingleFileBundlePropertyInputsCache Condition="'$(_GenerateSingleFileBundlePropertyInputsCache)' == ''">$(IntermediateOutputPath)$(MSBuildProjectName).genbundle.cache</_GenerateSingleFileBundlePropertyInputsCache>
<_GenerateSingleFileBundlePropertyInputsCache>$([MSBuild]::NormalizePath($(MSBuildProjectDirectory), $(_GenerateSingleFileBundlePropertyInputsCache)))</_GenerateSingleFileBundlePropertyInputsCache>
</PropertyGroup>
<ItemGroup>
<GenerateRuntimeConfigurationFilesInputs Include="$(ProjectAssetsFile)" />
<GenerateRuntimeConfigurationFilesInputs Include="$(ProjectAssetsCacheFile)" />
<GenerateRuntimeConfigurationFilesInputs Include="$(UserRuntimeConfig)" Condition=" Exists($(UserRuntimeConfig)) " />
</ItemGroup>
<ItemGroup Condition="'$(TargetFrameworks)' != '' And '$(TargetFramework)' != ''">
<ProjectConfigurationDescription Include="TargetFramework=$(TargetFramework)" />
</ItemGroup>
<PropertyGroup Condition="'$(GenerateRuntimeConfigDevFile)' == ''">
<GenerateRuntimeConfigDevFile>true</GenerateRuntimeConfigDevFile>
<!-- Post-net6.0, stop generating *.runtimeconfig.dev.json files to reduce probing paths. -->
<!-- https://github.com/dotnet/sdk/issues/16818 -->
<GenerateRuntimeConfigDevFile Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '6.0'))">false</GenerateRuntimeConfigDevFile>
</PropertyGroup>
<PropertyGroup>
<ProjectDepsFileName Condition="'$(ProjectDepsFileName)' == ''">$(AssemblyName).deps.json</ProjectDepsFileName>
<ProjectDepsFilePath Condition="'$(ProjectDepsFilePath)' == ''">$(TargetDir)$(ProjectDepsFileName)</ProjectDepsFilePath>
<ProjectRuntimeConfigFileName Condition="'$(ProjectRuntimeConfigFileName)' == ''">$(AssemblyName).runtimeconfig.json</ProjectRuntimeConfigFileName>
<ProjectRuntimeConfigFilePath Condition="'$(ProjectRuntimeConfigFilePath)' == ''">$(TargetDir)$(ProjectRuntimeConfigFileName)</ProjectRuntimeConfigFilePath>
<ProjectRuntimeConfigDevFilePath Condition="'$(ProjectRuntimeConfigDevFilePath)' == '' and $(GenerateRuntimeConfigDevFile) == 'true'">$(TargetDir)$(AssemblyName).runtimeconfig.dev.json</ProjectRuntimeConfigDevFilePath>
<IncludeMainProjectInDepsFile Condition=" '$(IncludeMainProjectInDepsFile)' == '' ">true</IncludeMainProjectInDepsFile>
</PropertyGroup>
<Import Project="Microsoft.NET.Sdk.Shared.targets" />
<PropertyGroup>
<_DefaultUserProfileRuntimeStorePath>$(HOME)</_DefaultUserProfileRuntimeStorePath>
<_DefaultUserProfileRuntimeStorePath Condition="$([MSBuild]::IsOSPlatform(`Windows`))">$(USERPROFILE)</_DefaultUserProfileRuntimeStorePath>
<_DefaultUserProfileRuntimeStorePath>$([System.IO.Path]::Combine($(_DefaultUserProfileRuntimeStorePath), '.dotnet', 'store'))</_DefaultUserProfileRuntimeStorePath>
<UserProfileRuntimeStorePath Condition="'$(UserProfileRuntimeStorePath)' == ''">$(_DefaultUserProfileRuntimeStorePath)</UserProfileRuntimeStorePath>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '6.0'))">
<PredefinedCulturesOnly Condition="'$(PredefinedCulturesOnly)' == '' and '$(InvariantGlobalization)' == 'true'">true</PredefinedCulturesOnly>
</PropertyGroup>
<PropertyGroup Condition="'$(GenerateResourceWarnOnBinaryFormatterUse)' == '' and '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '8.0'))">
<GenerateResourceWarnOnBinaryFormatterUse>true</GenerateResourceWarnOnBinaryFormatterUse>
</PropertyGroup>
<!-- Set the IsRidAgnostic property if this project should NOT accept global RuntimeIdentifier and SelfContained
property values from referencing projects. -->
<PropertyGroup Condition="'$(IsRidAgnostic)' == ''">
<IsRidAgnostic Condition="('$(_IsExecutable)' == 'true' And '$(IsTestProject)' != 'true') Or
'$(RuntimeIdentifier)' != '' Or
'$(RuntimeIdentifiers)' != ''">false</IsRidAgnostic>
<IsRidAgnostic Condition="'$(IsRidAgnostic)' == ''">true</IsRidAgnostic>
</PropertyGroup>
<!-- Opt into .NET Core resource-serialization strategy by default when targeting frameworks
that support it by default.
-->
<PropertyGroup>
<GenerateResourceUsePreserializedResources
Condition="'$(GenerateResourceUsePreserializedResources)' == '' and
('$(TargetFrameworkIdentifier)' == '.NETCoreApp' and '$(_TargetFrameworkVersionWithoutV)' >= '3.0')">true</GenerateResourceUsePreserializedResources>
</PropertyGroup>
<PropertyGroup>
<EmbeddedResourceUseDependentUponConvention
Condition="'$(EmbeddedResourceUseDependentUponConvention)' == '' and
(('$(TargetFrameworkIdentifier)' == '.NETCoreApp' and '$(_TargetFrameworkVersionWithoutV)' >= '3.0') or
('$(TargetFrameworkIdentifier)' == '.NETStandard' and '$(_TargetFrameworkVersionWithoutV)' >= '2.1'))">true</EmbeddedResourceUseDependentUponConvention>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '2.1'))">
<AvailablePlatforms>$(AvailablePlatforms),ARM32</AvailablePlatforms>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '3.1'))">
<AvailablePlatforms>$(AvailablePlatforms),ARM64</AvailablePlatforms>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '4.8.1'))">
<AvailablePlatforms>$(AvailablePlatforms),ARM64</AvailablePlatforms>
</PropertyGroup>
<PropertyGroup>
<!-- Turn off support for metadata updates in non-Debug builds by default. -->
<MetadataUpdaterSupport Condition="'$(MetadataUpdaterSupport)' == '' and '$(Configuration)' != 'Debug'">false</MetadataUpdaterSupport>
</PropertyGroup>
<PropertyGroup>
<!-- Turn on IncludeProjectsNotInAssetsFileInDepsFile by default. -->
<IncludeProjectsNotInAssetsFileInDepsFile Condition="'$(IncludeProjectsNotInAssetsFileInDepsFile)' == ''">true</IncludeProjectsNotInAssetsFileInDepsFile>
</PropertyGroup>
<!--
BinaryFormatter Disabling
===========================
The EnableUnsafeBinaryFormatterSerialization setting controls both runtime and compile-time behavior.
The behavior is slightly different depending on the project type and target runtime.
If the property is explicitly set to TRUE:
- The APIs are obsolete as warning, and calls to the APIs will succeed at runtime.
If the property is explicitly set to FALSE:
- On .NET 5 & 6, the APIs are obsolete as warning, and calls to the APIs will fail at runtime.
- On .NET 7+, the APIs are obsolete as error, and calls to the APIs will fail at runtime.
If the property is not explicitly TRUE or FALSE:
- On .NET 5 & 6, the APIs are obsolete as warning, and calls to the APIs will succeed at runtime.
- On .NET 7, the APIs are obsolete as error, but calls to the APIs will succeed at runtime.
- On .NET 8+, the APIs are obsolete as error, and calls to the APIs will fail at runtime
unless the SDK has opted in to keeping legacy BinaryFormatter behavior around.
n.b. The APIs are already marked obsolete (as warning) in .NET 5, so we don't need to special-case
them unless we want to upgrade them to warn-as-error.
-->
<PropertyGroup Condition="'$(EnableUnsafeBinaryFormatterSerialization)' != 'true' AND '$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '7.0'))">
<!--
Certain project types need to re-enable BinaryFormatter by default; it will still be warn-as-error but will work at runtime.
WinForms: enabled through 8.0 (but not after)
WPF: enabled through 8.0 (but not after)
-->
<_ProjectTypeRequiresBinaryFormatter Condition="'$(UseWindowsForms)' == 'true' AND $([MSBuild]::VersionLessThanOrEquals($(TargetFrameworkVersion), '8.0'))">true</_ProjectTypeRequiresBinaryFormatter>
<_ProjectTypeRequiresBinaryFormatter Condition="'$(UseWPF)' == 'true' AND $([MSBuild]::VersionLessThanOrEquals($(TargetFrameworkVersion), '8.0'))">true</_ProjectTypeRequiresBinaryFormatter>
<!-- controls warn as error -->
<_BinaryFormatterObsoleteAsError>true</_BinaryFormatterObsoleteAsError>
<!-- controls runtime behavior (AppContext & trimming) -->
<EnableUnsafeBinaryFormatterSerialization Condition="'$(EnableUnsafeBinaryFormatterSerialization)' == '' AND '$(_ProjectTypeRequiresBinaryFormatter)' == 'true'">true</EnableUnsafeBinaryFormatterSerialization>
<EnableUnsafeBinaryFormatterSerialization Condition="$([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '8.0')) AND '$(_ProjectTypeRequiresBinaryFormatter)' != 'true'">false</EnableUnsafeBinaryFormatterSerialization>
</PropertyGroup>
<PropertyGroup>
<CoreBuildDependsOn>
_CheckForBuildWithNoBuild;
$(CoreBuildDependsOn);
GenerateBuildDependencyFile;
GenerateBuildRuntimeConfigurationFiles
</CoreBuildDependsOn>
</PropertyGroup>
<PropertyGroup>
<CoreCleanDependsOn>
_SdkBeforeClean;
$(CoreCleanDependsOn)
</CoreCleanDependsOn>
</PropertyGroup>
<PropertyGroup>
<RebuildDependsOn>
_SdkBeforeRebuild;
$(RebuildDependsOn)
</RebuildDependsOn>
</PropertyGroup>
<Target Name="_AddMicrosoftNetCompilerToolsetFrameworkPackage" BeforeTargets="CollectPackageReferences">
<!-- Users should not be setting Microsoft.Net.Compilers.Toolset.Framework directly.
If they do, and they also set BuildWithNetFrameworkHostedCompiler, we will have
a duplicate PackageReference. This makes it more explicit that that is not supported. -->
<NETSdkWarning ResourceName="CannotDirectlyReferenceMicrosoftNetCompilersToolsetFramework"
Condition="'@(PackageReference->AnyHaveMetadataValue('Identity', 'Microsoft.Net.Compilers.Toolset.Framework'))' == 'true'" />
<ItemGroup Condition="'$(BuildWithNetFrameworkHostedCompiler)' == 'true' and '$(OS)' == 'Windows_NT'">
<PackageReference Include="Microsoft.Net.Compilers.Toolset.Framework" PrivateAssets="all" Version="$(_NetFrameworkHostedCompilersVersion)" IsImplicitlyDefined="true" />
</ItemGroup>
</Target>
<!-- TODO: this target should not check GeneratePackageOnBuild.
remove when https://github.com/NuGet/Home/issues/7801 is fixed.
-->
<Target Name="_CheckForBuildWithNoBuild"
Condition="'$(NoBuild)' == 'true' and '$(GeneratePackageOnBuild)' != 'true'">
<NETSdkError ResourceName="NoBuildRequested" />
</Target>
<!--
============================================================
GenerateBuildDependencyFile
Generates the $(project).deps.json file during Build
============================================================
-->
<Target Name="GenerateBuildDependencyFile"
DependsOnTargets="_DefaultMicrosoftNETPlatformLibrary;
_HandlePackageFileConflicts;
_ComputeReferenceAssemblies;
_ComputeUserRuntimeAssemblies;
ResolveRuntimePackAssets;
_ComputePackageReferencePublish"
BeforeTargets="CopyFilesToOutputDirectory"
Condition="'$(GenerateDependencyFile)' == 'true'"
Inputs="$(ProjectAssetsFile);$(ProjectAssetsCacheFile);$(MSBuildAllProjects)"
Outputs="$(ProjectDepsFilePath)">
<!-- Set a dummy Version if it hasn't been set by DefaultAssemblyInfo.targets -->
<PropertyGroup Condition="'$(UsingNETSdkDefaults)' != 'true'">
<Version Condition="'$(Version)' == ''">1.0.0</Version>
</PropertyGroup>
<ItemGroup>
<ResolvedCompileFileDefinitions Remove="@(_ConflictPackageFiles)" Condition="'%(_ConflictPackageFiles.ConflictItemType)' == 'Reference'" />
<NativeCopyLocalItems Remove="@(_ConflictPackageFiles)" Condition="'%(_ConflictPackageFiles.ConflictItemType)' != 'Reference'" />
<ResourceCopyLocalItems Remove="@(_ConflictPackageFiles)" Condition="'%(_ConflictPackageFiles.ConflictItemType)' != 'Reference'" />
<RuntimeCopyLocalItems Remove="@(_ConflictPackageFiles)" Condition="'%(_ConflictPackageFiles.ConflictItemType)' != 'Reference'" />
<RuntimeTargetsCopyLocalItems Remove="@(_ConflictPackageFiles)" Condition="'%(_ConflictPackageFiles.ConflictItemType)' != 'Reference'" />
<RuntimePackAsset Remove="@(_ConflictPackageFiles)" Condition="'%(_ConflictPackageFiles.ConflictItemType)' != 'Reference'" />
</ItemGroup>
<!-- Set valid RID platforms for runtime assets if targeting .NET 8+ and using the RID graph is not enabled. -->
<ItemGroup Condition="$([MSBuild]::VersionGreaterThanOrEquals($(_TargetFrameworkVersionWithoutV), '8.0'))
and @(RuntimeHostConfigurationOption->WithMetadataValue('Identity', 'System.Runtime.Loader.UseRidGraph')->WithMetadataValue('Value', 'true')->Count()) == 0">
<!-- Known RID platforms for all target frameworks comes from BundledVersions -->
<_ValidRuntimeIdentifierPlatformsForAssets Include="@(_KnownRuntimeIdentiferPlatforms)" />
<!-- Known RID platforms for current target framework comes from ProcessFrameworkReferences output -->
<_ValidRuntimeIdentifierPlatformsForAssets Include="@(_KnownRuntimeIdentifierPlatformsForTargetFramework)" Exclude="@(_ExcludedKnownRuntimeIdentiferPlatforms)"/>
</ItemGroup>
<GenerateDepsFile ProjectPath="$(MSBuildProjectFullPath)"
AssetsFilePath="$(ProjectAssetsFile)"
DepsFilePath="$(ProjectDepsFilePath)"
TargetFramework="$(TargetFramework)"
AssemblyName="$(AssemblyName)"
AssemblyExtension="$(TargetExt)"
AssemblyVersion="$(Version)"
AssemblySatelliteAssemblies="@(IntermediateSatelliteAssembliesWithTargetPath)"
ReferencePaths="@(ReferencePath)"
ReferenceDependencyPaths="@(ReferenceDependencyPaths)"
ReferenceSatellitePaths="@(ReferenceSatellitePaths)"
ReferenceAssemblies="@(_ReferenceAssemblies)"
RuntimePackAssets="@(RuntimePackAsset)"
IncludeMainProject="$(IncludeMainProjectInDepsFile)"
RuntimeIdentifier="$(RuntimeIdentifier)"
PlatformLibraryName="$(MicrosoftNETPlatformLibrary)"
RuntimeFrameworks="@(RuntimeFramework)"
CompilerOptions="@(DependencyFileCompilerOptions)"
CompileReferences="@(ResolvedCompileFileDefinitions)"
ResolvedNuGetFiles="@(NativeCopyLocalItems);@(ResourceCopyLocalItems);@(RuntimeCopyLocalItems)"
UserRuntimeAssemblies="@(UserRuntimeAssembly)"
ResolvedRuntimeTargetsFiles="@(RuntimeTargetsCopyLocalItems)"
IsSelfContained="$(SelfContained)"
IncludeRuntimeFileVersions="$(IncludeFileVersionsInDependencyFile)"
RuntimeGraphPath="$(BundledRuntimeIdentifierGraphFile)"
IncludeProjectsNotInAssetsFile="$(IncludeProjectsNotInAssetsFileInDepsFile)"
ValidRuntimeIdentifierPlatformsForAssets="@(_ValidRuntimeIdentifierPlatformsForAssets)"/>
<ItemGroup>
<!-- Do this in an ItemGroup instead of as an output parameter of the GenerateDepsFile task so that it still gets added to the item set
during incremental builds when the task is skipped -->
<FileWrites Include="$(ProjectDepsFilePath)" Condition="Exists('$(ProjectDepsFilePath)')"/>
</ItemGroup>
</Target>
<!-- To achieve incremental build with property change. When any property changes, WriteOnlyWhenDifferent will be triggered to write cache file.
And the cache file's timestamp will be later, and it then triggers the incremental build.-->
<Target Name="_GenerateRuntimeConfigurationFilesInputCache" DependsOnTargets="_DefaultMicrosoftNETPlatformLibrary">
<ItemGroup>
<GenerateRuntimeConfigurationFilesInputs Include="$(_GenerateRuntimeConfigurationPropertyInputsCache)" />
<_GenerateRuntimeConfigurationPropertyInputsCacheToHash Include="@(AdditionalProbingPath->'%(Identity)')"/>
<_GenerateRuntimeConfigurationPropertyInputsCacheToHash Include="$(EnableDynamicLoading)"/>
<_GenerateRuntimeConfigurationPropertyInputsCacheToHash Include="$(RollForward)"/>
<_GenerateRuntimeConfigurationPropertyInputsCacheToHash Include="@(RuntimeHostConfigurationOption->'%(Identity)%(Value)')"/>
<_GenerateRuntimeConfigurationPropertyInputsCacheToHash Include="$(RuntimeIdentifier)"/>
<_GenerateRuntimeConfigurationPropertyInputsCacheToHash Include="$(SelfContained)"/>
<_GenerateRuntimeConfigurationPropertyInputsCacheToHash Include="$(TargetFramework)"/>
<_GenerateRuntimeConfigurationPropertyInputsCacheToHash Include="$(UserRuntimeConfig)"/>
<_GenerateRuntimeConfigurationPropertyInputsCacheToHash Include="$(_WriteIncludedFrameworks)"/>
</ItemGroup>
<Hash ItemsToHash="@(_GenerateRuntimeConfigurationPropertyInputsCacheToHash)">
<Output TaskParameter="HashResult" PropertyName="_GenerateRuntimeConfigurationPropertyInputsCacheHash" />
</Hash>
<WriteLinesToFile
Lines="$(_GenerateRuntimeConfigurationPropertyInputsCacheHash)"
File="$(_GenerateRuntimeConfigurationPropertyInputsCache)"
Overwrite="True"
WriteOnlyWhenDifferent="True" />
<ItemGroup>
<FileWrites Include="$(_GenerateRuntimeConfigurationPropertyInputsCache)" />
</ItemGroup>
</Target>
<!--
============================================================
GenerateBuildRuntimeConfigurationFiles
Generates the $(project).runtimeconfig.json and $(project).runtimeconfig.dev.json files during Build
============================================================
-->
<Target Name="GenerateBuildRuntimeConfigurationFiles"
DependsOnTargets="_GenerateRuntimeConfigurationFilesInputCache"
BeforeTargets="CopyFilesToOutputDirectory"
Condition=" '$(GenerateRuntimeConfigurationFiles)' == 'true'"
Inputs="@(GenerateRuntimeConfigurationFilesInputs)"
Outputs="$(ProjectRuntimeConfigFilePath);$(ProjectRuntimeConfigDevFilePath)">
<PropertyGroup>
<_IsRollForwardSupported Condition="'$(_TargetFrameworkVersionWithoutV)' >= '3.0'">true</_IsRollForwardSupported>
<RollForward Condition="'$(RollForward)' == '' and '$(EnableDynamicLoading)' == 'true' and '$(_IsRollForwardSupported)' == 'true'">LatestMinor</RollForward>
</PropertyGroup>
<!-- RollForward is only supported since .NET Core 3.0, but we should allow limited usage when the app is targeting even lower versions
This is to let 2.* apps specify that they are OK to run on 3.0 and above. So explicitly allow just Major and LatestMajor
other values should still keep failing as they won't have any effect when run on 2.*. -->
<NETSdkError Condition="'$(RollForward)' != '' and '$(RollForward)' != 'Major' and '$(RollForward)' != 'LatestMajor' and '$(_IsRollForwardSupported)' != 'true'"
ResourceName="RollForwardRequiresVersion30"/>
<PropertyGroup>
<_WriteIncludedFrameworks Condition="'$(SelfContained)' == 'true' and '$(_TargetFrameworkVersionWithoutV)' >= '3.1'">true</_WriteIncludedFrameworks>
</PropertyGroup>
<GenerateRuntimeConfigurationFiles AssetsFilePath="$(ProjectAssetsFile)"
TargetFramework="$(TargetFramework)"
TargetFrameworkMoniker="$(TargetFrameworkMoniker)"
RuntimeConfigPath="$(ProjectRuntimeConfigFilePath)"
RuntimeConfigDevPath="$(ProjectRuntimeConfigDevFilePath)"
RuntimeIdentifier="$(RuntimeIdentifier)"
PlatformLibraryName="$(MicrosoftNETPlatformLibrary)"
RuntimeFrameworks="@(RuntimeFramework)"
RollForward="$(RollForward)"
UserRuntimeConfig="$(UserRuntimeConfig)"
HostConfigurationOptions="@(RuntimeHostConfigurationOption)"
AdditionalProbingPaths="@(AdditionalProbingPath)"
IsSelfContained="$(SelfContained)"
WriteIncludedFrameworks="$(_WriteIncludedFrameworks)"
GenerateRuntimeConfigDevFile="$(GenerateRuntimeConfigDevFile)"
AlwaysIncludeCoreFramework="$(AlwaysIncludeCoreFrameworkInRuntimeConfig)">
</GenerateRuntimeConfigurationFiles>
<ItemGroup>
<!-- Do this in an ItemGroup instead of as an output parameter of the GenerateDepsFile task so that it still gets added to the item set
during incremental builds when the task is skipped -->
<FileWrites Include="$(ProjectRuntimeConfigFilePath)" Condition="Exists('$(ProjectRuntimeConfigFilePath)')"/>
<FileWrites Include="$(ProjectRuntimeConfigDevFilePath)" Condition="Exists('$(ProjectRuntimeConfigDevFilePath)')"/>
</ItemGroup>
</Target>
<!-- Add runtimeconfig.json file to BuiltProjectOutputGroupOutput, so that it will get included in the NuGet package by the Pack target -->
<Target Name="AddRuntimeConfigFileToBuiltProjectOutputGroupOutput"
Condition=" '$(GenerateRuntimeConfigurationFiles)' == 'true'"
BeforeTargets="BuiltProjectOutputGroup">
<ItemGroup>
<BuiltProjectOutputGroupOutput Include="$(ProjectRuntimeConfigFilePath)"
TargetPath="$(ProjectRuntimeConfigFileName)"
FinalOutputPath="$(ProjectRuntimeConfigFilePath)" />
</ItemGroup>
</Target>
<Target Name="AddDepsJsonAndRuntimeConfigToCopyItemsForReferencingProjects"
BeforeTargets="GetCopyToOutputDirectoryItems;_GetCopyToOutputDirectoryItemsFromThisProject"
Condition="'$(HasRuntimeOutput)' == 'true'">
<ItemGroup Condition="'$(GenerateDependencyFile)' == 'true'">
<AllItemsFullPathWithTargetPath Include="$(ProjectDepsFilePath)"
TargetPath="$([System.IO.Path]::GetFileName($(ProjectDepsFilePath)))"
CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<ItemGroup Condition=" '$(GenerateRuntimeConfigurationFiles)' == 'true'">
<AllItemsFullPathWithTargetPath Include="$(ProjectRuntimeConfigFilePath)"
TargetPath="$([System.IO.Path]::GetFileName($(ProjectRuntimeConfigFilePath)))"
CopyToOutputDirectory="PreserveNewest" />
<AllItemsFullPathWithTargetPath Include="$(ProjectRuntimeConfigDevFilePath)"
TargetPath="$([System.IO.Path]::GetFileName($(ProjectRuntimeConfigDevFilePath)))"
CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</Target>
<Target Name="AddDepsJsonAndRuntimeConfigToPublishItemsForReferencingProjects"
DependsOnTargets="_ComputeUseBuildDependencyFile"
BeforeTargets="GetCopyToPublishDirectoryItems"
Condition="'$(HasRuntimeOutput)' == 'true'">
<ItemGroup Condition="'$(GenerateDependencyFile)' == 'true'">
<AllPublishItemsFullPathWithTargetPath Include="$(ProjectDepsFilePath)"
TargetPath="$([System.IO.Path]::GetFileName($(ProjectDepsFilePath)))"
CopyToPublishDirectory="PreserveNewest"
Condition="'$(_UseBuildDependencyFile)' == 'true'"/>
<AllPublishItemsFullPathWithTargetPath Include="$(PublishDepsFilePath)"
TargetPath="$([System.IO.Path]::GetFileName($(PublishDepsFilePath)))"
CopyToPublishDirectory="PreserveNewest"
Condition="'$(PublishDepsFilePath)' != '' and '$(_UseBuildDependencyFile)' != 'true'"/>
</ItemGroup>
<ItemGroup Condition=" '$(GenerateRuntimeConfigurationFiles)' == 'true'">
<AllPublishItemsFullPathWithTargetPath Include="$(ProjectRuntimeConfigFilePath)"
TargetPath="$([System.IO.Path]::GetFileName($(ProjectRuntimeConfigFilePath)))"
CopyToPublishDirectory="PreserveNewest" />
</ItemGroup>
</Target>
<Target Name="_SdkBeforeClean">
<PropertyGroup Condition="'$(_CleaningWithoutRebuilding)' == ''">
<_CleaningWithoutRebuilding>true</_CleaningWithoutRebuilding>
<EmitAssetsLogMessages>false</EmitAssetsLogMessages>
</PropertyGroup>
</Target>
<Target Name="_SdkBeforeRebuild">
<PropertyGroup>
<_CleaningWithoutRebuilding>false</_CleaningWithoutRebuilding>
</PropertyGroup>
</Target>
<!--
============================================================
DefaultRuntimeHostConfigurationOptions
Defaults @(RuntimeHostConfigurationOption) items based on MSBuild properties.
============================================================
-->
<ItemGroup>
<RuntimeHostConfigurationOption Include="Microsoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmability"
Condition="'$(VerifyDependencyInjectionOpenGenericServiceTrimmability)' != ''"
Value="$(VerifyDependencyInjectionOpenGenericServiceTrimmability)"
Trim="true" />
<RuntimeHostConfigurationOption Include="System.AggressiveAttributeTrimming"
Condition="'$(_AggressiveAttributeTrimming)' != ''"
Value="$(_AggressiveAttributeTrimming)"
Trim="true" />
<RuntimeHostConfigurationOption Include="System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization"
Condition="'$(EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization)' != ''"
Value="$(EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization)"
Trim="true" />
<RuntimeHostConfigurationOption Include="System.Diagnostics.Debugger.IsSupported"
Condition="'$(DebuggerSupport)' != ''"
Value="$(DebuggerSupport)"
Trim="true" />
<RuntimeHostConfigurationOption Include="System.Diagnostics.Tracing.EventSource.IsSupported"
Condition="'$(EventSourceSupport)' != ''"
Value="$(EventSourceSupport)"
Trim="true" />
<RuntimeHostConfigurationOption Include="System.GC.Concurrent"
Condition="'$(ConcurrentGarbageCollection)' != ''"
Value="$(ConcurrentGarbageCollection)" />
<RuntimeHostConfigurationOption Include="System.GC.Server"
Condition="'$(ServerGarbageCollection)' != ''"
Value="$(ServerGarbageCollection)" />
<RuntimeHostConfigurationOption Include="System.GC.DynamicAdaptationMode"
Condition="'$(GarbageCollectionAdaptationMode)' != ''"
Value="$(GarbageCollectionAdaptationMode)" />
<RuntimeHostConfigurationOption Include="System.GC.RetainVM"
Condition="'$(RetainVMGarbageCollection)' != ''"
Value="$(RetainVMGarbageCollection)" />
<RuntimeHostConfigurationOption Include="System.Globalization.Invariant"
Condition="'$(InvariantGlobalization)' != ''"
Value="$(InvariantGlobalization)"
Trim="true" />
<RuntimeHostConfigurationOption Include="System.Globalization.PredefinedCulturesOnly"
Condition="'$(PredefinedCulturesOnly)' != ''"
Value="$(PredefinedCulturesOnly)"
Trim="true" />
<RuntimeHostConfigurationOption Include="System.Net.Http.EnableActivityPropagation"
Condition="'$(HttpActivityPropagationSupport)' != ''"
Value="$(HttpActivityPropagationSupport)"
Trim="true" />
<RuntimeHostConfigurationOption Include="System.Net.Http.UseNativeHttpHandler"
Condition="'$(UseNativeHttpHandler)' != ''"
Value="$(UseNativeHttpHandler)"
Trim="true" />
<RuntimeHostConfigurationOption Include="System.Reflection.Metadata.MetadataUpdater.IsSupported"
Condition="'$(MetadataUpdaterSupport)' != ''"
Value="$(MetadataUpdaterSupport)"
Trim="true" />
<RuntimeHostConfigurationOption Include="System.Reflection.NullabilityInfoContext.IsSupported"
Condition="'$(NullabilityInfoContextSupport)' != ''"
Value="$(NullabilityInfoContextSupport)"
Trim="true" />
<RuntimeHostConfigurationOption Include="System.Resources.ResourceManager.AllowCustomResourceTypes"
Condition="'$(CustomResourceTypesSupport)' != ''"
Value="$(CustomResourceTypesSupport)"
Trim="true" />
<RuntimeHostConfigurationOption Include="System.Resources.UseSystemResourceKeys"
Condition="'$(UseSystemResourceKeys)' != ''"
Value="$(UseSystemResourceKeys)"
Trim="true" />
<RuntimeHostConfigurationOption Include="System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeSupported"
Condition="'$(DynamicCodeSupport)' != ''"
Value="$(DynamicCodeSupport)"
Trim="true" />
<RuntimeHostConfigurationOption Include="System.Runtime.InteropServices.BuiltInComInterop.IsSupported"
Condition="'$(BuiltInComInteropSupport)' != ''"
Value="$(BuiltInComInteropSupport)"
Trim="true" />
<RuntimeHostConfigurationOption Include="System.Runtime.InteropServices.EnableConsumingManagedCodeFromNativeHosting"
Condition="'$(_EnableConsumingManagedCodeFromNativeHosting)' != ''"
Value="$(_EnableConsumingManagedCodeFromNativeHosting)"
Trim="true" />
<RuntimeHostConfigurationOption Include="System.Runtime.InteropServices.EnableCppCLIHostActivation"
Condition="'$(EnableCppCLIHostActivation)' != ''"
Value="$(EnableCppCLIHostActivation)"
Trim="true" />
<RuntimeHostConfigurationOption Include="System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization"
Condition="'$(EnableUnsafeBinaryFormatterSerialization)' != ''"
Value="$(EnableUnsafeBinaryFormatterSerialization)"
Trim="true" />
<RuntimeHostConfigurationOption Include="System.Runtime.TieredCompilation"
Condition="'$(TieredCompilation)' != ''"
Value="$(TieredCompilation)" />
<RuntimeHostConfigurationOption Include="System.Runtime.TieredCompilation.QuickJit"
Condition="'$(TieredCompilationQuickJit)' != ''"
Value="$(TieredCompilationQuickJit)" />
<RuntimeHostConfigurationOption Include="System.Runtime.TieredCompilation.QuickJitForLoops"
Condition="'$(TieredCompilationQuickJitForLoops)' != ''"
Value="$(TieredCompilationQuickJitForLoops)" />
<RuntimeHostConfigurationOption Include="System.Runtime.TieredPGO"
Condition="'$(TieredPGO)' != ''"
Value="$(TieredPGO)" />
<RuntimeHostConfigurationOption Include="System.StartupHookProvider.IsSupported"
Condition="'$(StartupHookSupport)' != ''"
Value="$(StartupHookSupport)"
Trim="true" />
<RuntimeHostConfigurationOption Include="System.Text.Encoding.EnableUnsafeUTF7Encoding"
Condition="'$(EnableUnsafeUTF7Encoding)' != ''"
Value="$(EnableUnsafeUTF7Encoding)"
Trim="true" />
<RuntimeHostConfigurationOption Include="System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault"
Condition="'$(JsonSerializerIsReflectionEnabledByDefault)' != ''"
Value="$(JsonSerializerIsReflectionEnabledByDefault)"
Trim="true" />
<RuntimeHostConfigurationOption Include="System.Threading.Thread.EnableAutoreleasePool"
Condition="'$(AutoreleasePoolSupport)' != ''"
Value="$(AutoreleasePoolSupport)"
Trim="true" />
<RuntimeHostConfigurationOption Include="System.Threading.ThreadPool.MinThreads"
Condition="'$(ThreadPoolMinThreads)' != ''"
Value="$(ThreadPoolMinThreads)" />
<RuntimeHostConfigurationOption Include="System.Threading.ThreadPool.MaxThreads"
Condition="'$(ThreadPoolMaxThreads)' != ''"
Value="$(ThreadPoolMaxThreads)" />
</ItemGroup>
<!--
============================================================
DefaultAdditionalProbingPaths
Adds the default @(AdditionalProbingPath) items.
============================================================
-->
<ItemGroup Condition="'$(GenerateRuntimeConfigurationFiles)' == 'true' and '$(SkipDefaultAdditionalProbingPaths)' != 'true'">
<!-- Note: can't use Path.Combine here since `|` is an illegal path character -->
<AdditionalProbingPath Include="$(UserProfileRuntimeStorePath)$([System.IO.Path]::DirectorySeparatorChar)|arch|$([System.IO.Path]::DirectorySeparatorChar)|tfm|" />
</ItemGroup>
<PropertyGroup>
<CompileDependsOn>
$(CompileDependsOn);
_CreateAppHost;
_CreateComHost;
_GetIjwHostPaths;
</CompileDependsOn>
</PropertyGroup>
<!--
============================================================
_CreateAppHost
If we found a restored apphost, create the modified destination apphost
with options from the project.
============================================================
-->
<UsingTask TaskName="CreateAppHost" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />
<Target Name="_CreateAppHost"
Inputs="@(IntermediateAssembly);$(AppHostSourcePath)"
Outputs="$(AppHostIntermediatePath)"
DependsOnTargets="_ChooseAppHost;CoreCompile"
Condition="'$(ComputeNETCoreBuildOutputFiles)' == 'true' and
'$(AppHostSourcePath)' != '' and
Exists('@(IntermediateAssembly)') and
Exists('$(AppHostSourcePath)')">
<PropertyGroup>
<_UseWindowsGraphicalUserInterface Condition="($(RuntimeIdentifier.StartsWith('win')) or $(DefaultAppHostRuntimeIdentifier.StartsWith('win'))) and '$(OutputType)'=='WinExe'">true</_UseWindowsGraphicalUserInterface>
<_EnableMacOSCodeSign Condition="'$(_EnableMacOSCodeSign)' == '' and $([MSBuild]::IsOSPlatform(`OSX`)) and Exists('/usr/bin/codesign') and
($(RuntimeIdentifier.StartsWith('osx')) or $(AppHostRuntimeIdentifier.StartsWith('osx')))">true</_EnableMacOSCodeSign>
</PropertyGroup>
<CreateAppHost AppHostSourcePath="$(AppHostSourcePath)"
AppHostDestinationPath="$(AppHostIntermediatePath)"
AppBinaryName="$(AssemblyName)$(TargetExt)"
IntermediateAssembly="@(IntermediateAssembly->'%(FullPath)')"
WindowsGraphicalUserInterface="$(_UseWindowsGraphicalUserInterface)"
Retries="$(CopyRetryCount)"
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
EnableMacOSCodeSign="$(_EnableMacOSCodeSign)"
/>
</Target>
<!--
============================================================
_ChooseAppHost
Choose the correct app-host for the build scenario:
* SingleFileHost if an app being published as a self-contained single-file .net5+ app
* AppHost otherwise
============================================================
-->
<Target Name="_ChooseAppHost"
DependsOnTargets="_GetAppHostPaths"
Condition="'$(UseAppHost)' == 'true' and '$(_IsExecutable)' == 'true'">
<PropertyGroup Condition="'$(PublishSingleFile)' == 'true' and
'$(SelfContained)' == 'true' and
'$(_TargetFrameworkVersionWithoutV)' >= '5.0' and
'$(SingleFileHostSourcePath)' != ''">
<AppHostSourcePath>$(SingleFileHostSourcePath)</AppHostSourcePath>
<AppHostIntermediatePath>$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)singlefilehost$(_NativeExecutableExtension)'))</AppHostIntermediatePath>
</PropertyGroup>
</Target>
<!--
============================================================
_GetAppHostPaths
Gets the path to apphost (restored via packages or in an apphost pack),
and computes the path for the destination apphost.
============================================================
-->
<Target Name="_GetAppHostPaths"
DependsOnTargets="ResolvePackageAssets;ResolveFrameworkReferences"
Condition="'$(UseAppHost)' == 'true' and '$(_IsExecutable)' == 'true'">
<NETSdkError Condition="'@(_NativeRestoredAppHostNETCore->Count())' > 1"
ResourceName="MultipleFilesResolved"
FormatArguments="$(_DotNetAppHostExecutableName)" />
<PropertyGroup>
<!-- AppHostSourcePath will be set from ProcessFrameworkReferences if not using the apphost from the assets file -->
<AppHostSourcePath Condition="'$(UseAppHostFromAssetsFile)' == 'true'">@(_NativeRestoredAppHostNETCore)</AppHostSourcePath>
</PropertyGroup>
<PropertyGroup Condition="'$(UseAppHostFromAssetsFile)' == 'false' Or '@(_NativeRestoredAppHostNETCore)' != ''">
<AppHostIntermediatePath>$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)apphost$(_NativeExecutableExtension)'))</AppHostIntermediatePath>
</PropertyGroup>
</Target>
<ItemGroup>
<ClsidMap Include="$(IntermediateOutputPath)$(AssemblyName).clsidmap" />
<RegFreeComManifest Include="$(IntermediateOutputPath)$(AssemblyName).X.manifest" />
</ItemGroup>
<!--
============================================================
_GenerateClsidMap
Generates a *.clsidmap file from the built assembly.
============================================================
-->
<UsingTask TaskName="GenerateClsidMap" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />
<Target Name="_GenerateClsidMap"
Inputs="@(IntermediateAssembly)"
Outputs="@(ClsidMap)"
DependsOnTargets="CoreCompile"
Condition="'$(ComputeNETCoreBuildOutputFiles)' == 'true' and
'$(EnableComHosting)' == 'true'">
<GenerateClsidMap
IntermediateAssembly="@(IntermediateAssembly->'%(FullPath)')"
CLsidMapDestinationPath="@(ClsidMap->'%(FullPath)')" />
</Target>
<UsingTask TaskName="CreateComHost" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />
<!--
============================================================
_CreateComHost
If we found a restored comhost, create the modified destination apphost
with options from the project.
============================================================
-->
<Target Name="_CreateComHost"
Inputs="@(IntermediateAssembly);$(ComHostSourcePath)"
Outputs="$(ComHostIntermediatePath)"
DependsOnTargets="_GetComHostPaths;CoreCompile;_GenerateClsidMap;_GenerateRegFreeComManifest"
Condition="'$(ComputeNETCoreBuildOutputFiles)' == 'true' and
'$(ComHostIntermediatePath)' != '' and
Exists('@(IntermediateAssembly)') and
Exists('$(ComHostSourcePath)')">
<CreateComHost
ComHostSourcePath="$(ComHostSourcePath)"
ComHostDestinationPath="$(ComHostIntermediatePath)"
ClsidMapPath="@(ClsidMap)"
TypeLibraries="@(ComHostTypeLibrary)" />
</Target>
<UsingTask TaskName="GenerateRegFreeComManifest" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />
<!--
============================================================
_GenerateRegFreeComManifest
Gets the path to the restored comhost, and if the restored comhost
was present, computes the path for the destination comhost.
============================================================
-->
<Target Name="_GenerateRegFreeComManifest"
DependsOnTargets="_GenerateClsidMap;_GetComHostPaths"
Inputs="@(ClsidMap);@(IntermediateAssembly)"
Outputs="@(RegFreeComManifest)"
Condition="'$(ComputeNETCoreBuildOutputFiles)' == 'true' and
'$(EnableComHosting)' == 'true' and
'$(EnableRegFreeCom)' == 'true'">
<GenerateRegFreeComManifest
IntermediateAssembly="@(IntermediateAssembly)"
ComHostName="$(ComHostFileName)"
ClsidMapPath="@(ClsidMap)"
TypeLibraries="@(ComHostTypeLibrary)"
ComManifestPath="@(RegFreeComManifest)" />
</Target>
<!--
============================================================
_GetComHostPaths
Gets the path to the restored comhost, and if the restored comhost
was present, computes the path for the destination comhost.
============================================================
-->
<Target Name="_GetComHostPaths"
DependsOnTargets="ResolvePackageAssets;ResolveFrameworkReferences"
Condition="'$(EnableComHosting)' == 'true' and '$(_IsExecutable)' != 'true'">
<PropertyGroup>
<ComHostFileName>$(AssemblyName).comhost$(_ComHostLibraryExtension)</ComHostFileName>
<ComHostIntermediatePath>$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)$(ComHostFileName)'))</ComHostIntermediatePath>
</PropertyGroup>
<NETSdkError Condition="'$(ComHostSourcePath)' == '' or !Exists('$(ComHostSourcePath)')"
ResourceName="CannotFindComhost" />
</Target>
<!--
============================================================
_GetIjwHostPaths
Gets the path to the restored Ijwhost, and if the restored Ijwhost
was present, Computes the path for the destination Ijwhost.
============================================================
-->
<Target Name="_GetIjwHostPaths"
DependsOnTargets="ResolvePackageAssets;ResolveFrameworkReferences"
Condition="'$(UseIJWHost)' == 'true'">
<NETSdkError Condition="'$(IjwHostSourcePath)' == '' or !Exists('$(IjwHostSourcePath)')"
ResourceName="CannotFindIjwhost" />
</Target>
<!--
============================================================
_ComputeNETCoreBuildOutputFiles
Computes any files that need to be copied to the build output folder for .NET Core.
============================================================
-->
<Target Name="_ComputeNETCoreBuildOutputFiles"
DependsOnTargets="_ChooseAppHost;_GetComHostPaths;_GetIjwHostPaths"
BeforeTargets="AssignTargetPaths"
Condition="'$(ComputeNETCoreBuildOutputFiles)' == 'true'">
<!-- Fallback to renaming the dotnet host if there is no apphost for self-contained builds. -->
<PropertyGroup Condition="'$(AppHostIntermediatePath)' == '' and '$(SelfContained)' == 'true'">
<_CopyAndRenameDotnetHost Condition="'$(_CopyAndRenameDotnetHost)' == ''">true</_CopyAndRenameDotnetHost>
</PropertyGroup>
<ItemGroup Condition="'$(_CopyAndRenameDotnetHost)' == 'true'">
<None Include="@(NativeCopyLocalItems)"
Condition="'%(NativeCopyLocalItems.FileName)%(NativeCopyLocalItems.Extension)' == '$(_DotNetHostExecutableName)'">
<Link>$(AssemblyName)$(_NativeExecutableExtension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup Condition="'$(AppHostIntermediatePath)' != '' or '$(_CopyAndRenameDotnetHost)' == 'true'">
<!--
If not copying local lock file assemblies, copy the host policy and host fxr libraries for self-contained builds.
This is required to allow the host to activate in self-contained mode.
-->
<None Include="@(NativeCopyLocalItems)"
Condition="'$(SelfContained)' == 'true' and
'$(CopyLocalLockFileAssemblies)' != 'true' and
('%(NativeCopyLocalItems.FileName)%(NativeCopyLocalItems.Extension)' == '$(_DotNetHostPolicyLibraryName)' or
'%(NativeCopyLocalItems.FileName)%(NativeCopyLocalItems.Extension)' == '$(_DotNetHostFxrLibraryName)')">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup Condition="'$(AppHostIntermediatePath)' != ''">
<None Include="$(AppHostIntermediatePath)">
<Link>$(AssemblyName)$(_NativeExecutableExtension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<!-- Always copy the AppHost because the contents of the apphost binary can change during the publish step (due to single-file bundling).
Always copying the apphost ensures that that the sequence
dotnet publish /p:PublishSingleFile=true
dotnet publish /p:PublishSingleFile=false
places the correct unbundled apphost in the publish directory. -->
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup Condition="'$(ComHostIntermediatePath)' != ''">
<None Include="$(ComHostIntermediatePath)">
<Link>$(AssemblyName).$(_DotNetComHostLibraryName)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Include="@(RegFreeComManifest)" Condition="'$(EnableRegFreeCom)' == 'true'">
<Link>%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup Condition="'$(IjwHostSourcePath)' != '' and '$(UseIJWHost)' == 'true'">
<None Include="$(IjwHostSourcePath)">
<Link>$(_DotNetIjwHostLibraryName)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>
</Target>
<!--
============================================================
_ComputeReferenceAssemblies
Computes references that are only used at compile-time.
============================================================
-->
<Target Name="_ComputeReferenceAssemblies"
DependsOnTargets="ResolveAssemblyReferences">
<ItemGroup>
<_FrameworkReferenceAssemblies Include="@(ReferencePath)"
Condition="(%(ReferencePath.FrameworkFile) == 'true' or
%(ReferencePath.ResolvedFrom) == 'ImplicitlyExpandDesignTimeFacades')
and ('%(ReferencePath.NuGetSourceType)' == '' or
'%(ReferencePath.NuGetIsFrameworkReference)' == 'true')" />
<!--
"ReferenceOnly" assemblies are assemblies that are only used at compile-time, and they can't be resolved
by the normal compile-assembly resolvers at runtime:
1. App local
2. NuGet/Package layout
3. ProgramFiles\Reference Assemblies
These assemblies need to be copied to the 'refs' folder for both build and publish.
-->
<_ReferenceOnlyAssemblies Include="@(ReferencePath)"
Exclude="@(_FrameworkReferenceAssemblies)"
Condition="%(ReferencePath.CopyLocal) != 'true' and
%(ReferencePath.NuGetSourceType) == ''" />
<_ReferenceAssemblies Include="@(_FrameworkReferenceAssemblies)" />
<_ReferenceAssemblies Include="@(_ReferenceOnlyAssemblies)" />
</ItemGroup>
</Target>
<!--
============================================================
_ComputeUserRuntimeAssemblies
Computes references or reference dependencies that are copy local.
NOTE: NuGet and framework references are never copy local so those are not included here.
These will be project references and direct references and their copy local dependencies.
============================================================
-->
<Target Name="_ComputeUserRuntimeAssemblies">
<ItemGroup>
<!-- IncludeRuntimeDependency=true metadata is escape hatch to include a non-copy local reference in deps file as a runtime dependency -->
<ReferencePath>
<IncludeRuntimeDependency Condition="'%(ReferencePath.IncludeRuntimeDependency)' == '' and '%(ReferencePath.CopyLocal)' == 'true'">true</IncludeRuntimeDependency>
</ReferencePath>
<ReferenceDependencyPaths>
<IncludeRuntimeDependency Condition="'%(ReferenceDependencyPaths.IncludeRuntimeDependency)' == '' and '%(ReferenceDependencyPaths.CopyLocal)' == 'true'">true</IncludeRuntimeDependency>
</ReferenceDependencyPaths>
<UserRuntimeAssembly Include="@(ReferencePath->WithMetadataValue('IncludeRuntimeDependency', 'true'))" />
<UserRuntimeAssembly Include="@(ReferenceDependencyPaths->WithMetadataValue('IncludeRuntimeDependency', 'true'))" />
</ItemGroup>
</Target>
<!--
============================================================
Run Information
The ProcessStart information that can be used to run this project.
============================================================
-->
<PropertyGroup>
<RunWorkingDirectory Condition="'$(RunWorkingDirectory)' == ''">$(StartWorkingDirectory)</RunWorkingDirectory>
</PropertyGroup>
<Choose>
<When Condition="'$(StartAction)' == 'Program'">
<PropertyGroup>
<RunCommand Condition="'$(RunCommand)' == ''">$(StartProgram)</RunCommand>
<RunArguments Condition="'$(RunArguments)' == ''">$(StartArguments)</RunArguments>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and '$(_IsExecutable)' == 'true'">
<PropertyGroup Condition="'$(UseAppHost)' != 'true'">
<!-- TODO: https://github.com/dotnet/sdk/issues/20 Need to get the DotNetHost path from MSBuild -->
<RunCommand Condition="'$(RunCommand)' == ''">dotnet</RunCommand>
<_NetCoreRunArguments>exec "$(TargetPath)"</_NetCoreRunArguments>
<RunArguments Condition="'$(RunArguments)' == '' and '$(StartArguments)' != ''">$(_NetCoreRunArguments) $(StartArguments)</RunArguments>
<RunArguments Condition="'$(RunArguments)' == ''">$(_NetCoreRunArguments)</RunArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(UseAppHost)' == 'true'">
<RunCommand Condition="'$(RunCommand)' == ''">$(TargetDir)$(AssemblyName)$(_NativeExecutableExtension)</RunCommand>
<RunArguments Condition="'$(RunArguments)' == ''">$(StartArguments)</RunArguments>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and '$(_IsExecutable)' == 'true'">
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform(`Windows`))">
<RunCommand Condition="'$(RunCommand)' == ''">$(TargetPath)</RunCommand>
<RunArguments Condition="'$(RunArguments)' == ''">$(StartArguments)</RunArguments>
</PropertyGroup>
<PropertyGroup Condition="$([MSBuild]::IsOSUnixLike())">
<RunCommand Condition="'$(RunCommand)' == ''">mono</RunCommand>
<RunArguments Condition="'$(RunArguments)' == ''">"$(TargetPath)" $(StartArguments)</RunArguments>
</PropertyGroup>