-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCISupport.props
254 lines (228 loc) · 13.7 KB
/
CISupport.props
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
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Support for building with dotnet in Linux -->
<!-- Most of the stuff is related to building .NET Desktop projects, but at the very bottom is some common code for all the projects. -->
<!-- We can't do this in Directory.Build.props, as NuGetPackageRoot property will evaluate to empty string there. -->
<!--
The PackageReference items to Microsoft.TargetingPack packages are required in order to compile at all.
The RedistList item is required in order to emit correct .(dll|exe).config files.
The actual XML file which RedistList item points at needs to be generated on-the-fly, see RedistListGenerator in CIPipeline repo.
-->
<PropertyGroup>
<Net40RefAssemblyDirName Condition=" '$(Net40RefAssemblyDirName)' == '' ">v4-ref-assemblies</Net40RefAssemblyDirName>
<RedistsListsSubDir Condition=" '$(RedistsListsSubDir)' == '' ">redistlists</RedistsListsSubDir>
<RedistListsBaseDir>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)/../$(RedistsListsSubDir)'))</RedistListsBaseDir>
</PropertyGroup>
<PropertyGroup>
<!-- Package IDs -->
<PID_net45>Microsoft.TargetingPack.NETFramework.v4.5</PID_net45>
<PID_net451>Microsoft.TargetingPack.NETFramework.v4.5.1</PID_net451>
<PID_net452>Microsoft.TargetingPack.NETFramework.v4.5.2</PID_net452>
<PID_net46>Microsoft.TargetingPack.NETFramework.v4.6</PID_net46>
<PID_net461>Microsoft.TargetingPack.NETFramework.v4.6.1</PID_net461>
<PID_net462>Microsoft.TargetingPack.NETFramework.v4.6.2</PID_net462>
<PID_net47>Microsoft.TargetingPack.NETFramework.v4.7</PID_net47>
<PID_net471>Microsoft.TargetingPack.NETFramework.v4.7.1</PID_net471>
<PID_net472>Microsoft.TargetingPack.NETFramework.v4.7.2</PID_net472>
<!-- Package versions -->
<PV_net45>1.0.1</PV_net45>
<PV_net451>1.0.1</PV_net451>
<PV_net452>1.0.1</PV_net452>
<PV_net46>1.0.1</PV_net46>
<PV_net461>1.0.1</PV_net461>
<PV_net462>1.0.1</PV_net462>
<PV_net47>1.0.1</PV_net47>
<PV_net471>1.0.0</PV_net471>
<PV_net472>1.0.0</PV_net472>
<!-- FrameworkPathOverrides -->
<FPOR_net45>$(PID_net45.ToLower())\$(PV_net45)\lib\net45\</FPOR_net45>
<FPOR_net451>$(PID_net451.ToLower())\$(PV_net451)\lib\net451\</FPOR_net451>
<FPOR_net452>$(PID_net452.ToLower())\$(PV_net452)\lib\net452\</FPOR_net452>
<FPOR_net46>$(PID_net46.ToLower())\$(PV_net46)\lib\net46\</FPOR_net46>
<FPOR_net461>$(PID_net461.ToLower())\$(PV_net461)\lib\net461\</FPOR_net461>
<FPOR_net462>$(PID_net462.ToLower())\$(PV_net462)\lib\net462\</FPOR_net462>
<FPOR_net47>$(PID_net47.ToLower())\$(PV_net47)\lib\net47\</FPOR_net47>
<FPOR_net471>$(PID_net471.ToLower())\$(PV_net471)\lib\net471\</FPOR_net471>
<FPOR_net472>$(PID_net472.ToLower())\$(PV_net472)\lib\net472\</FPOR_net472>
<FPO_net40>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..\$(Net40RefAssemblyDirName)'))\</FPO_net40>
<FPO_net45>$(NuGetPackageRoot)$(FPOR_net45)</FPO_net45>
<FPO_net451>$(NuGetPackageRoot)$(FPOR_net451)</FPO_net451>
<FPO_net452>$(NuGetPackageRoot)$(FPOR_net452)</FPO_net452>
<FPO_net46>$(NuGetPackageRoot)$(FPOR_net46)</FPO_net46>
<FPO_net461>$(NuGetPackageRoot)$(FPOR_net461)</FPO_net461>
<FPO_net462>$(NuGetPackageRoot)$(FPOR_net462)</FPO_net462>
<FPO_net47>$(NuGetPackageRoot)$(FPOR_net47)</FPO_net47>
<FPO_net471>$(NuGetPackageRoot)$(FPOR_net471)</FPO_net471>
<FPO_net472>$(NuGetPackageRoot)$(FPOR_net472)</FPO_net472>
</PropertyGroup>
<!-- Support for generating framework assembly list xml files on-the-fly. -->
<Target
Name="CheckGenerateRedistFrameworkLists"
AfterTargets="Restore"
Condition=" $([System.Text.RegularExpressions.Regex]::IsMatch('$(TargetFramework)', 'net(\d)+')) or $([System.Text.RegularExpressions.Regex]::IsMatch('$(TargetFrameworks)', 'net(\d)+')) "
>
<!-- This target generates, as needed, the FrameworkList.xml files used by ResolveAssemblyReference task so that correct .(dll|exe).config files would be generated under .NET Core running on Linux. -->
<ItemGroup>
<TFItem Include="$(TargetFramework)" />
<TFItem Include="$(TargetFrameworks)" />
<MissingTFItem Include="@(TFItem)" Condition=" $([System.Text.RegularExpressions.Regex]::IsMatch('%(Identity)', 'net(\d)+')) and !Exists('$(RedistListsBaseDir)/%(Identity)')" />
</ItemGroup>
<PropertyGroup>
<MissingTFItemCount>@(MissingTFItem->Count())</MissingTFItemCount>
</PropertyGroup>
<PropertyGroup Condition=" '$(MissingTFItemCount)' > 0 ">
<RedistListGenOut>/repo-dir/redistgenout/</RedistListGenOut>
<CIPipelineDir>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)/CIPipeline'))</CIPipelineDir>
<ThisTFM>$([System.Environment]::GetEnvironmentVariable('THIS_TFM'))</ThisTFM>
</PropertyGroup>
<!-- NuGetPackageRoot is not visible at this point so we have to do this ugly trick. -->
<MSBuild
Condition=" '$(MissingTFItemCount)' > 0 "
Projects="$(MSBuildThisFileFullPath)"
Properties="CISupportNuGetGeneratedPropsFile=$(IntermediateOutputPath)$(MSBuildProjectFile).nuget.g.props"
Targets="CalledRecursively"
>
<Output
TaskParameter="TargetOutputs"
ItemName="NuGetPackageRootItem"
/>
</MSBuild>
<PropertyGroup>
<NuGetPackageRootExtracted>@(NuGetPackageRootItem)</NuGetPackageRootExtracted>
<RedistListGeneratorCommand>dotnet '$(RedistListGenOut)/Release/bin/RedistListGenerator/$(ThisTFM)/RedistListGenerator.dll' '$(RedistListsBaseDir)' 'net40;net45;net451;net452;net46;net461;net462;net47;net471;net472' '$([MSBuild]::NormalizeDirectory('$(FPO_net40)'));$([MSBuild]::NormalizeDirectory('$(NuGetPackageRootExtracted)$(FPOR_net45)'));$([MSBuild]::NormalizeDirectory('$(NuGetPackageRootExtracted)$(FPOR_net451)'));$([MSBuild]::NormalizeDirectory('$(NuGetPackageRootExtracted)$(FPOR_net452)'));$([MSBuild]::NormalizeDirectory('$(NuGetPackageRootExtracted)$(FPOR_net46)'));$([MSBuild]::NormalizeDirectory('$(NuGetPackageRootExtracted)$(FPOR_net461)'));$([MSBuild]::NormalizeDirectory('$(NuGetPackageRootExtracted)$(FPOR_net462)'));$([MSBuild]::NormalizeDirectory('$(NuGetPackageRootExtracted)$(FPOR_net47)'));$([MSBuild]::NormalizeDirectory('$(NuGetPackageRootExtracted)$(FPOR_net471)'));$([MSBuild]::NormalizeDirectory('$(NuGetPackageRootExtracted)$(FPOR_net472)'))'</RedistListGeneratorCommand>
</PropertyGroup>
<Copy
Condition=" '$(MissingTFItemCount)' > 0 "
SourceFiles="$(MSBuildThisFileDirectory)/Source/Directory.Build.BuildTargetFolders.props"
DestinationFiles="$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)/../Directory.Build.props'))"
/>
<Exec
Condition=" '$(MissingTFItemCount)' > 0 "
Command="dotnet build -nologo /p:Configuration=Release "/p:TargetFramework=$(ThisTFM)" /p:BuildCommonOutputDir=$(RedistListGenOut) "$(CIPipelineDir)/RedistListGenerator/""
/>
<Message
Condition=" '$(MissingTFItemCount)' > 0 "
Text="Executing command $(RedistListGeneratorCommand)"
Importance="high"
/>
<Exec
Condition=" '$(MissingTFItemCount)' > 0 "
Command="$(RedistListGeneratorCommand)"
/>
</Target>
<Import Condition=" '$(CISupportNuGetGeneratedPropsFile)' != '' " Project="$(CISupportNuGetGeneratedPropsFile)" />
<Target
Name="CalledRecursively"
Outputs="$(NuGetPackageRoot)"
>
</Target>
<!-- Support for finding the framework assemblies during compilation, for each framework. -->
<!--
It would be great if this would work, but unfortunately when PropertyGroup is inside Project element, it can't access ItemGroups.
More info: https://stackoverflow.com/questions/14020789/using-msbuild-propertygroup-outside-of-target-block/14339180
-->
<!--
<ItemGroup Condition=" '$(TargetFramework)' != '' ">
<MatchingFrameworkPackageInfo
Include="@(FrameworkPackageInfo->WithMetadataValue('Identity', '$(TargetFramework)'))"
KeepMetadata="PackageID;PackageVersion;FrameworkPathOverride"
/>
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' != '' and '@(MatchingFrameworkPackageInfo->Metadata('PackageID'))' != '' ">
<PackageReference Include="@(MatchingFrameworkPackageInfo->Metadata('PackageID'))" Version="%(PackageVersion)" ExcludeAssets="All" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup>
<FrameworkPathOverride>%(MatchingFrameworkPackageInfo.FrameworkPathOverride)</FrameworkPathOverride>
</PropertyGroup>
-->
<!-- So, we have to do this manually. -->
<PropertyGroup Condition=" '$(TargetFramework)' == 'net47' ">
<FrameworkPathOverride>$(FPO_net47)</FrameworkPathOverride>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net47' ">
<PackageReference Include="$(PID_net47)" Version="$(PV_net47)" ExcludeAssets="All" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net471' ">
<FrameworkPathOverride>$(FPO_net471)</FrameworkPathOverride>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net471' ">
<PackageReference Include="$(PID_net471)" Version="$(PV_net471)" ExcludeAssets="All" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net472' ">
<FrameworkPathOverride>$(FPO_net472)</FrameworkPathOverride>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net472' ">
<PackageReference Include="$(PID_net472)" Version="$(PV_net472)" ExcludeAssets="All" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net46' ">
<FrameworkPathOverride>$(FPO_net46)</FrameworkPathOverride>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">
<PackageReference Include="$(PID_net46)" Version="$(PV_net46)" ExcludeAssets="All" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net461' ">
<FrameworkPathOverride>$(FPO_net461)</FrameworkPathOverride>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<PackageReference Include="$(PID_net461)" Version="$(PV_net461)" ExcludeAssets="All" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net462' ">
<FrameworkPathOverride>$(FPO_net462)</FrameworkPathOverride>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
<PackageReference Include="$(PID_net462)" Version="$(PV_net462)" ExcludeAssets="All" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' ">
<FrameworkPathOverride>$(FPO_net45)</FrameworkPathOverride>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<PackageReference Include="$(PID_net45)" Version="$(PV_net45)" ExcludeAssets="All" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net451' ">
<FrameworkPathOverride>$(FPO_net451)</FrameworkPathOverride>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
<PackageReference Include="$(PID_net451)" Version="$(PV_net451)" ExcludeAssets="All" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net452' ">
<FrameworkPathOverride>$(FPO_net452)</FrameworkPathOverride>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<PackageReference Include="$(PID_net452)" Version="$(PV_net452)" ExcludeAssets="All" PrivateAssets="All" />
</ItemGroup>
<!-- No targeting pack NuGet package for 4.0 (or older) -->
<PropertyGroup Condition=" '$(TargetFramework)' == 'net40' ">
<FrameworkPathOverride>$(FPO_net40)</FrameworkPathOverride>
</PropertyGroup>
<ItemGroup Condition=" $([System.Text.RegularExpressions.Regex]::IsMatch('$(TargetFramework)', 'net(\d)+'))">
<!-- It seems the FrameworkDirectory metadata for this item is not required. -->
<RedistList Include="$(RedistListsBaseDir)/$(TargetFramework)/FrameworkList.xml" />
</ItemGroup>
<PropertyGroup>
<PackageVersion Condition=" '$(PackageVersion)' != '' ">$(PackageVersion)+$(CIPackageVersionSuffix)</PackageVersion>
<!-- Using SemVer 2.0.0 implies client version 4.3 or higher. Lower clients still might fail, as they read package version before min client version.
See https://docs.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu5105 , https://github.com/NuGet/Home/wiki/SemVer-2.0.0-support . -->
<!-- But pushing to nuget.org with this min version causes error, and it seems other packages don't use this anyway. -->
<!--<MinClientVersion>4.3</MinClientVersion>-->
<!-- Disable warning about SemVer 2.0.0, as per https://github.com/NuGet/Home/issues/4687 . -->
<NoWarn>$(NoWarn);NU5105</NoWarn>
</PropertyGroup>
<!-- Fix the one assembly that has wrong case. -->
<Target
Condition=" '$(TargetFramework)' == 'net45' or '$(TargetFramework)' == 'net451' or '$(TargetFramework)' == 'net452'"
Name="FixSystemXmlCasing"
DependsOnTargets="GetFrameworkPaths"
BeforeTargets="ResolveAssemblyReferences"
>
<!-- FrameworkPathOverride, as well as NuGetPackageRoot is gone by now, so we must use differently named property. -->
<PropertyGroup>
<ActualTargetFrameworkDirectory>$(TargetFrameworkDirectory.Replace(';', ''))</ActualTargetFrameworkDirectory>
<WrongCasedPath>$(ActualTargetFrameworkDirectory)System.XML.dll</WrongCasedPath>
<CorrectCasedPath>$(ActualTargetFrameworkDirectory)System.Xml.dll</CorrectCasedPath>
</PropertyGroup>
<Move
Condition="Exists('$(WrongCasedPath)') and !Exists('$(CorrectCasedPath)')"
SourceFiles="$(WrongCasedPath)"
DestinationFiles="$(CorrectCasedPath)"
/>
</Target>
</Project>