-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Directory.Build.targets
211 lines (158 loc) · 13.9 KB
/
Directory.Build.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
<Project>
<Import Project="$(MSBuildThisFileDirectory)/.build/dependencies.props" Condition="Exists('$(MSBuildThisFileDirectory)/.build/dependencies.props')" />
<Import Project="$(MSBuildThisFileDirectory)/.build/nowarn.props" Condition="Exists('$(MSBuildThisFileDirectory)/.build/nowarn.props')" />
<!--Features in .NET 9+ only-->
<PropertyGroup Condition=" $(TargetFramework.StartsWith('net9.')) ">
<DefineConstants>$(DefineConstants);FEATURE_MEMORYEXTENSIONS_STARTSWITH_ENDSWITH_ELEMENT</DefineConstants>
</PropertyGroup>
<!--Features in .NET 7+ only-->
<PropertyGroup Condition=" $(TargetFramework.StartsWith('net7.')) Or $(TargetFramework.StartsWith('net8.')) ">
<DefineConstants>$(DefineConstants);FEATURE_IDICTIONARY_ASREADONLY</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_ILIST_ASREADONLY</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_INT128</DefineConstants>
</PropertyGroup>
<!--Features in .NET 6+ only-->
<PropertyGroup Condition=" $(TargetFramework.StartsWith('net6.')) Or $(TargetFramework.StartsWith('net7.')) Or $(TargetFramework.StartsWith('net8.')) ">
<DefineConstants>$(DefineConstants);FEATURE_SPANFORMATTABLE</DefineConstants>
</PropertyGroup>
<!--Features in .NET 5+ only-->
<PropertyGroup Condition=" $(TargetFramework.StartsWith('net5.')) Or $(TargetFramework.StartsWith('net6.')) Or $(TargetFramework.StartsWith('net7.')) Or $(TargetFramework.StartsWith('net8.')) ">
<DefineConstants>$(DefineConstants);FEATURE_HALF</DefineConstants>
</PropertyGroup>
<!-- Features in .NET Core 3.x, .NET 5.x, .NET 6.x, .NET 7.x, and .NET 8.x -->
<PropertyGroup Condition=" $(TargetFramework.StartsWith('netcoreapp3.')) Or $(TargetFramework.StartsWith('net5.')) Or $(TargetFramework.StartsWith('net6.')) Or $(TargetFramework.StartsWith('net7.')) Or $(TargetFramework.StartsWith('net8.')) ">
<DefineConstants>$(DefineConstants);FEATURE_MEMORYEXTENSIONS_CONTAINS_T</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_MEMORYEXTENSIONS_LASTINDEXOF_COMPARISONTYPE</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_MEMORYEXTENSIONS_TRIM_SPAN_MEMORY_READONLYMEMORY</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_RUNE</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_STRING_CONCAT_READONLYSPAN</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_STRING_GETHASHCODE_READONLYSPAN</DefineConstants>
</PropertyGroup>
<!--Features in .NET Standard 2.x or .NET Core-->
<PropertyGroup Condition=" $(TargetFramework.StartsWith('netstandard')) Or $(TargetFramework.StartsWith('netcoreapp')) Or $(TargetFramework.StartsWith('net5.')) Or $(TargetFramework.StartsWith('net6.')) Or $(TargetFramework.StartsWith('net7.')) Or $(TargetFramework.StartsWith('net8.')) ">
<DefineConstants>$(DefineConstants);NETSTANDARD</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_APPCONTEXT_BASEDIRECTORY</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_ARRAYEMPTY</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_ASYNCLOCAL</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_CULTUREINFO_CURRENTCULTURE_SETTER</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_RANDOMNUMBERGENERATOR_GETBYTES_OFFSET_COUNT</DefineConstants>
<DefineConstants Condition=" '$(TargetFramework)' != 'netstandard1.0' ">$(DefineConstants);FEATURE_RUNTIMEINFORMATION_ISOSPLATFORM</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_STRINGBUILDER_APPEND_CHARPTR</DefineConstants>
<DebugType>portable</DebugType>
</PropertyGroup>
<!-- Features in .NET Standard 2.1, .NET Core 2.1, .NET Core 3.x, .NET 5.x, .NET 6.x, .NET 7.x, and .NET 8.x -->
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' Or ($(TargetFramework.StartsWith('netcoreapp2.')) And '$(TargetFramework)' != 'netcoreapp2.0') Or $(TargetFramework.StartsWith('netcoreapp3.')) Or $(TargetFramework.StartsWith('net5.')) Or $(TargetFramework.StartsWith('net6.')) Or $(TargetFramework.StartsWith('net7.')) Or $(TargetFramework.StartsWith('net8.')) ">
<DefineConstants>$(DefineConstants);FEATURE_BIGINTEGER_TOBYTEARRAY_BIGENDIAN</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_RANDOMNUMBERGENERATOR_FILL_SPAN</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_STRING_CREATE</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_STRING_IMPLCIT_TO_READONLYSPAN</DefineConstants>
</PropertyGroup>
<!-- Features in .NET Framework 4.6+ only -->
<PropertyGroup Condition="$(TargetFramework.StartsWith('net46')) Or $(TargetFramework.StartsWith('net47')) Or $(TargetFramework.StartsWith('net48'))">
<DefineConstants>$(DefineConstants);FEATURE_ARRAYEMPTY</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_RANDOMNUMBERGENERATOR_GETBYTES_OFFSET_COUNT</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_STRINGBUILDER_APPEND_CHARPTR</DefineConstants>
</PropertyGroup>
<!-- Features in .NET Framework 4.5+, .NET Standard 2.x, .NET Core 2.x, .NET Core 3.x, .NET 5.x, .NET 6.x, .NET 7.x, and .NET 8.x -->
<!-- These features are not in .NET Framework 4.0 or .NET Framework 4.7 (the target framework we use for testing .NET Framework 4.0) -->
<PropertyGroup Condition=" ('$(TargetFramework)' != 'net40' And '$(TargetFramework)' != 'net47' And $(TargetFramework.StartsWith('net4'))) Or $(TargetFramework.StartsWith('netstandard2.')) Or $(TargetFramework.StartsWith('netcoreapp2.')) Or $(TargetFramework.StartsWith('netcoreapp3.')) Or $(TargetFramework.StartsWith('net5.')) Or $(TargetFramework.StartsWith('net6.')) Or $(TargetFramework.StartsWith('net7.')) Or $(TargetFramework.StartsWith('net8.')) ">
<DefineConstants>$(DefineConstants);FEATURE_CULTUREINFO_DEFAULTTHREADCURRENTCULTURE</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_EXCEPTION_HRESULT</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_EXCEPTIONDISPATCHINFO</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_IREADONLYCOLLECTIONS</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_METHODIMPLOPTIONS_AGRESSIVEINLINING</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_MICROSOFT_EXTENSIONS_CACHING</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_REGEX_MATCHTIMEOUT</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_SYSTEM_REFLECTION_METADATA</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_TASK_ASYNC_AWAIT</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_TASK_RUN</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_TYPE_GETCUSTOMATTRIBUTE_GENERIC</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_TYPEDWEAKREFERENCE</DefineConstants>
</PropertyGroup>
<!-- Features in .NET Framework 4+, .NET Standard 2.x, .NET Core 2.x, .NET Core 3.x, .NET 5.x, .NET 6.x, .NET 7.x, and .NET 8.x -->
<PropertyGroup Condition=" $(TargetFramework.StartsWith('net4')) Or $(TargetFramework.StartsWith('netstandard2.')) Or $(TargetFramework.StartsWith('netcoreapp2.')) Or $(TargetFramework.StartsWith('netcoreapp3.')) Or $(TargetFramework.StartsWith('net5.')) Or $(TargetFramework.StartsWith('net6.')) Or $(TargetFramework.StartsWith('net7.')) Or $(TargetFramework.StartsWith('net8.')) ">
<DefineConstants>$(DefineConstants);FEATURE_CULTUREINFO_GETCULTURES</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_CULTUREINFO_IETFLANGUAGETAG</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_CULTUREINFO_INSTALLEDUICULTURE</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_CULTUREINFO_KEYBOARDLAYOUTID</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_CULTUREINFO_LCID</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_CULTUREINFO_THREELETTERISOLANGUAGENAME</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_CULTUREINFO_THREELETTERWINDOWSLANGUAGENAME</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_CULTUREINFO_USEUSEROVERRIDE</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_SERIALIZABLE</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_STACKTRACE</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_THREADINTERRUPT</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_BITARRAY_COPYTO</DefineConstants>
<!-- NOTE: We have refactored the RuleBasedNumberFormat into the FormatNumberRuleBased class, but
it currently doesn't contain all of the features (parsing), nor do we have the DecimalFormat class functionality.
To add these features to the build, just add /p:IncludeLegacyNumberFormat to the command line. -->
<DefineConstants Condition=" '$(IncludeLegacyNumberFormat)' == 'true' ">$(DefineConstants);FEATURE_LEGACY_NUMBER_FORMAT</DefineConstants>
<!--
<DefineConstants>$(DefineConstants);FEATURE_FIELDPOSITION</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_CURRENCYFORMATTING</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_BIGMATH</DefineConstants>
-->
<!-- NOTE: Microsoft's recommendation is not to use the ICloneable interface.
To add it to the build, just add /p:IncludeICloneable to the command line. -->
<DefineConstants Condition=" '$(IncludeICloneable)' == 'true' ">$(DefineConstants);FEATURE_CLONEABLE</DefineConstants>
</PropertyGroup>
<!-- Features in .NET Framework 4.6+ only -->
<PropertyGroup Condition=" $(TargetFramework.StartsWith('net46')) Or $(TargetFramework.StartsWith('net47')) Or $(TargetFramework.StartsWith('net48')) ">
<DefineConstants>$(DefineConstants);FEATURE_APPCONTEXT_BASEDIRECTORY</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_ASYNCLOCAL</DefineConstants>
</PropertyGroup>
<!-- Features in .NET Framework 4+ only -->
<PropertyGroup Condition="$(TargetFramework.StartsWith('net4'))">
<DefineConstants>$(DefineConstants);FEATURE_CULTUREINFO_SERIALIZABLE</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_SERIALIZABLE_EXCEPTIONS</DefineConstants>
<DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DefineConstants>$(DefineConstants);DEBUG</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<!-- NuGet.org only supports portable debug symbol format:
https://docs.microsoft.com/en-us/nuget/create-packages/symbol-packages-snupkg#nugetorg-symbol-package-constraints -->
<DebugType Condition=" '$(PortableDebugTypeOnly)' == 'true' ">portable</DebugType>
</PropertyGroup>
<Target Name="AddInternalsVisibleTo" BeforeTargets="BeforeCompile" Label="Adds InternalsVisibleTo Attribute and PublicKey (if supplied)">
<ItemGroup Condition="'@(InternalsVisibleTo->Count())' > 0 ">
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>%(InternalsVisibleTo.Identity)</_Parameter1>
<_Parameter1 Condition=" '$(SignAssembly)' == 'true' And '$(PublicKey)' != '' ">%(InternalsVisibleTo.Identity), PublicKey=$(PublicKey)</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
</Target>
<Target Name ="AddCLSCompliant" BeforeTargets="AddInternalsVisibleTo" Label="Adds CLSCompliant Attribute (if specified)">
<ItemGroup Condition=" '$(CLSCompliant.ToLowerInvariant())' == 'true' Or '$(CLSCompliant.ToLowerInvariant())' == 'false' ">
<AssemblyAttribute Include="System.CLSCompliantAttribute">
<_Parameter1>$(CLSCompliant.ToLowerInvariant())</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
</Target>
<Target Name="PrintTargetFrameworks" Label="Prints the value for the $(TargetFrameworks) property or 'none' if no frameworks apply. Pass TestProjectsOnly=true to get results only if this is a test project.">
<PropertyGroup>
<DoOutputTargetFrameworks Condition=" '$(TestProjectsOnly)' != 'true' Or ('$(TestProjectsOnly)' == 'true' And '$(IsTestProject)' == 'true')">true</DoOutputTargetFrameworks>
<OutputTargetFrameworks Condition=" '$(DoOutputTargetFrameworks)' == 'true' ">$(TargetFramework)</OutputTargetFrameworks>
<!-- Fallback to TargetFrameworks field if TargetFramework is empty -->
<OutputTargetFrameworks Condition=" '$(DoOutputTargetFrameworks)' == 'true' And '$(OutputTargetFrameworks)' == '' ">$(TargetFrameworks)</OutputTargetFrameworks>
<OutputTargetFrameworks Condition=" '$(OutputTargetFrameworks)' == '' ">none</OutputTargetFrameworks>
</PropertyGroup>
<Message Text="$(OutputTargetFrameworks)" Importance="high"/>
</Target>
<!-- Global PackageReferences -->
<ItemGroup Condition=" $(TargetFramework.StartsWith('net4')) ">
<!-- This is to allow the .NET Framework references to be machine-indepenedent so builds can happen without installing prerequisites -->
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="$(MicrosoftNETFrameworkReferenceAssembliesPackageReferenceVersion)" PrivateAssets="All" />
</ItemGroup>
<!-- This is for testing only, we use SourceLink from any Azure DevOps git repo -->
<ItemGroup Condition=" '$(BUILD_REPOSITORY_PROVIDER)' == 'TfsGit' " Label="SourceLink Packages (experimental Azure Repos)">
<PackageReference Include="Microsoft.SourceLink.AzureRepos.Git" Version="$(MicrosoftSourceLinkAzureReposGitPackageReferenceVersion)" PrivateAssets="All"/>
</ItemGroup>
<ItemGroup Condition=" '$(BUILD_REPOSITORY_PROVIDER)' == 'GitHub' " Label="SourceLink Packages (main repo)">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="$(MicrosoftSourceLinkGitHubPackageReferenceVersion)" PrivateAssets="All"/>
</ItemGroup>
<ItemGroup Condition=" '$(SkipGitVersioning.ToLower())' != 'true' And '$(TF_BUILD.ToLower())' != 'true' ">
<PackageReference Include="Nerdbank.GitVersioning" Version="$(NerdBankGitVersioningPackageReferenceVersion)" PrivateAssets="All" />
</ItemGroup>
</Project>