forked from Azure/azure-sdk-for-net
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.proj
351 lines (294 loc) · 17 KB
/
build.proj
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
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
Available Targets:
/t:Clean
Removes temporary build outputs.
/t:Build
Builds assemblies.
/t:Package
Builds NuGet packages using the binaries folder contents.
The packages will drop to .\binaries\packages.
/t:Test
Runs tests
/t:Publish
Publishes the built packages. You will need to include your
publishing key when running. Include: /p:NuGetKey=YOUR_PUBLISHING_KEY
Properties of interest:
/p:Scope
'Common' : build Azure Common
'<Path to a project file>': build that specific package
'Authentication': build the Authentication package
By default, it builds all.
/p:CodeGen
True if you want to invoke codegen tool to regenerate libraries. Default is false.
/P:CodeSign=True
Code sign binaries, mainly for official release. Default is false.
/p:CodeSign=True;DelaySign=True
Test the code sign workflow locally.
/p:NuGetKey=NUGET_PUBLISHING_KEY
Provides the key used to publish to a NuGet or MyGet server.
This key should never be committed to source control.
/p:PublishSymbolSourcePackages
A true/false value indicating whether to push the symbol + source
packages to a symbol server.
/p:NuGetPublishingSource=Uri
The NuGet Server to push packages to.
/p:NuGetSymbolPublishingSource=Uri
The NuGet Server to push symbol + source packages to.
-->
<PropertyGroup>
<LibraryRoot>$(MSBuildThisFileDirectory)</LibraryRoot>
<LibrarySourceFolder>$(LibraryRoot)src</LibrarySourceFolder>
<LibraryToolsFolder>$(LibraryRoot)tools</LibraryToolsFolder>
<LibraryFriendlyName>Microsoft Azure Management Libraries</LibraryFriendlyName>
<CommonSolution>AzureCommonLibraries.sln</CommonSolution>
<AuthenticationSolution>AzureAuthentication.sln</AuthenticationSolution>
<ManagementLibrariesSolution>AzureManagementLibraries.sln</ManagementLibrariesSolution>
<BinariesFolder>$(LibraryRoot)binaries</BinariesFolder>
<PackageOutputDir>$(BinariesFolder)\packages</PackageOutputDir>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<CodeSign Condition=" '$(CodeSign)' == '' ">false</CodeSign>
<!--Set this true only if you want to test the code sign workflow locally-->
<DelaySign Condition =" '$(DelaySign)' == '' ">false</DelaySign>
<!-- 'Common': only build common; 'All': Both common and servies; "Authentication": Azure Authentication; 'full path to a library project': build that project -->
<Scope Condition=" '$(Scope)' == '' ">All</Scope>
<CodeGen Condition=" '$(CodeGen)' == '' ">false</CodeGen>
<FxTargetList Condition=" '$(FxTargetList)' == '' and '$(Scope)' == 'Authentication' " >net45</FxTargetList>
<FxTargetList Condition=" '$(FxTargetList)' == '' and ('$(Scope)' == '' or '$(Scope)' == 'all' or '$(Scope)' == 'Common') ">portable;net40;net45</FxTargetList>
<!--If FxTargetList still has no value, it must be an individual maml package-->
<FxTargetList Condition=" '$(FxTargetList)' == '' ">portable;net40</FxTargetList>
</PropertyGroup>
<ItemGroup>
<ManagementLibrariesProjects Include="$(ManagementLibrariesSolution)" Condition="$(MamlProjectName) == ''" />
<ManagementLibrariesProjects Include="$(LibrarySourceFolder)\$(MamlProjectName)\*.csproj" Condition="$(MamlProjectName) != ''" />
<LibraryFxTargetList Include="$(FxTargetList)" />
</ItemGroup>
<PropertyGroup>
<NuGetCommand>"$(LibraryToolsFolder)\nuget.exe"</NuGetCommand>
</PropertyGroup>
<Import Project="$(LibraryToolsFolder)\Microsoft.WindowsAzure.Build.msbuild" />
<UsingTask AssemblyFile="$(LibraryToolsFolder)\Microsoft.WindowsAzure.Build.Tasks.dll" TaskName="RegexReplacementTask" />
<UsingTask AssemblyFile="$(LibraryToolsFolder)\Microsoft.WindowsAzure.Build.Tasks.dll" TaskName="ValidateStrongNameSignatureTask" />
<!--
CI build related
-->
<PropertyGroup>
<!--OnPremiseBuildTasks is not a good name, but CI server is using that, will update across soon-->
<CIToolsPath>$(OnPremiseBuildTasks)</CIToolsPath>
<OnPremiseBuild Condition=" Exists($(OnPremiseBuildTasks)) ">true</OnPremiseBuild>
<OnPremiseBuild Condition=" ! Exists($(OnPremiseBuildTasks)) ">false</OnPremiseBuild>
</PropertyGroup>
<UsingTask Condition=" $(OnPremiseBuild) " TaskName="CodeSigningTask" AssemblyFile="$(CIToolsPath)\Microsoft.WindowsAzure.Tools.Build.Tasks.OnPremise.dll" />
<UsingTask Condition=" $(OnPremiseBuild) " TaskName="CorporateValidation" AssemblyFile="$(CIToolsPath)\Microsoft.WindowsAzure.Tools.Build.Tasks.OnPremise.dll" />
<Import Condition=" $(OnPremiseBuild) " Project="$(CIToolsPath)\Microsoft.WindowsAzure.Build.OnPremise.msbuild" />
<Target Name="Build" DependsOnTargets="RestoreNugetPackages">
<PropertyGroup>
<_ExtraPropertyList>CodeSign=$(CodeSign);GenerateHydraSpecs=$(CodeGen)</_ExtraPropertyList>
</PropertyGroup>
<CallTarget Targets="BuildMsBuildTask" />
<CallTarget Targets="BuildServerPreparation" Condition=" '$(CodeSign)' == 'true' " />
<!--The solution contains configurations for each platform such as Net40-Debug, Net45-Release, etc
So when invoke msbuild, feed the right configuration name-->
<MSBuild Projects="$(CommonSolution)"
Properties="Configuration=%(LibraryFxTargetList.Identity)-$(Configuration);Platform=Any CPU;$(_ExtraPropertyList)"
Targets="Build"
Condition=" '$(Scope)' == 'Common' or '$(Scope)' == 'All' " />
<MSBuild Projects="$(AuthenticationSolution)"
Properties="Configuration=Net45-$(Configuration);Platform=Any CPU;$(_ExtraPropertyList)"
Targets="Build"
Condition=" '$(Scope)' == 'Authentication' or '$(Scope)' == 'All' " />
<MSBuild Projects="$(ManagementLibrariesSolution)"
Properties="Configuration=%(LibraryFxTargetList.Identity)-$(Configuration);Platform=Any CPU;$(_ExtraPropertyList)"
Targets="Build"
Condition=" '$(Scope)' == 'All' " />
<MSBuild Projects="$(Scope)"
Properties="Configuration=%(LibraryFxTargetList.Identity)-$(Configuration);Platform=AnyCPU;$(_ExtraPropertyList)"
Targets="Build"
Condition=" '$(Scope)' != 'Common' and '$(Scope)' != 'All' and '$(Scope)' != 'Authentication' " />
<CallTarget Targets="CodeSignBinaries" Condition=" '$(CodeSign)' == 'true' " />
</Target>
<Target Name="Clean" DependsOnTargets="RestoreNugetPackages">
<MSBuild Projects="$(CommonSolution)"
Properties="Configuration=%(LibraryFxTargetList.Identity)-$(Configuration);Platform=Any CPU"
Targets="Clean" />
<MSBuild Projects="$(AuthenticationSolution)"
Properties="Configuration=Net45-$(Configuration);Platform=Any CPU"
Targets="Clean" />
<MSBuild Projects="$(ManagementLibrariesSolution)"
Properties="Configuration=%(LibraryFxTargetList.Identity)-$(Configuration);Platform=Any CPU"
Targets="Clean" />
<RemoveDir Directories="$(BinariesFolder)" />
</Target>
<UsingTask TaskName="Xunit.Runner.msbuild.xunit" AssemblyFile="packages\xunit.1.9.2\lib\net20\xunit.runner.msbuild.dll" />
<Target Name="Test">
<ItemGroup>
<!--test projects should always have net45 in its target framework list-->
<TestDlls Include=".\src\*.Test\bin\*\*Test.dll"/>
</ItemGroup>
<MakeDir Directories="$(LibraryRoot)TestResults"/>
<Message Text="%(TestDlls.Filename)" />
<xunit Assemblies="@(TestDlls)" Html="$(MSBuildProjectDirectory)\TestResults\xunit.results.html" ContinueOnError="false" />
</Target>
<PropertyGroup>
<!--This property is used by build script at CI server. Do not remove it unless you will update CI as well -->
<CorporateScanPaths>$(LibrarySourceFolder)</CorporateScanPaths>
</PropertyGroup>
<Target Name="SignBinariesForAFxTarget">
<PropertyGroup>
<!--public token associated with MSSharedLibKey.snk-->
<StrongNameToken Condition=" '$(StrongNameToken)' == '' ">31bf3856ad364e35</StrongNameToken>
</PropertyGroup>
<GetFrameworkSdkPath>
<Output TaskParameter="Path" PropertyName="WindowsSdkPath"/>
</GetFrameworkSdkPath>
<ItemGroup>
<DelaySignedAssembliesToValidate Include="binaries\$(LibraryFxTarget)\unsigned\*.dll" />
</ItemGroup>
<ValidateStrongNameSignatureTask
WindowsSdkPath="$(WindowsSdkPath)"
Assembly="%(DelaySignedAssembliesToValidate.Identity)"
ExpectedTokenSignature="$(StrongNameToken)"
ExpectedDelaySigned="true"
ContinueOnError="false" />
<CodeSigningTask
Description="Microsoft Azure SDK"
Keywords="Microsoft Azure .NET SDK"
UnsignedFiles="@(DelaySignedAssembliesToValidate)"
DestinationPath="binaries\$(LibraryFxTarget)"
SigningLogPath="binaries\$(LibraryFxTarget)\signing.log"
ToolsPath="$(CIToolsPath)"
Condition="!$(DelaySign)"/>
<!--If we are testing locally then we copy the binaries and do not submit to the code sign server-->
<Copy SourceFiles="@(DelaySignedAssembliesToValidate)" DestinationFolder="binaries\$(LibraryFxTarget)" Condition="$(DelaySign)" />
<ItemGroup>
<AfterSignedAssembliesToValidate Include="binaries\$(LibraryFxTarget)\*.dll" />
</ItemGroup>
<ValidateStrongNameSignatureTask
WindowsSdkPath="$(WindowsSdkPath)"
Assembly="%(AfterSignedAssembliesToValidate.Identity)"
ExpectedTokenSignature="$(StrongNameToken)"
ExpectedDelaySigned="false"
ContinueOnError="false"
Condition="!$(DelaySign)"/>
<RemoveDir Directories="binaries\$(LibraryFxTarget)\unsigned;" ContinueOnError="true" />
</Target>
<Target Name="CodeSignBinaries">
<Error Condition=" !$(OnPremiseBuild) and !$(DelaySign) " Text="No CI tools path available, the code sign will be unable to continue. $(CIToolsPath)" />
<Message Text="Code signing" Importance="high" />
<MSBuild Projects="$(MSBuildProjectFullPath)"
Targets="SignBinariesForAFxTarget"
Properties="LibraryFxTarget=%(LibraryFxTargetList.Identity);StrongNameToken=$(StrongNameToken)">
</MSBuild>
<CallTarget Targets="ValidateCorporateCompliance" Condition="!$(DelaySign)"/>
</Target>
<!--
Pre-build the tasks file used for validating strong name signatures,
providing date-based build numbers, and processing regular expression
replacements in files such as NuGet specs.
-->
<Target Name="BuildMsBuildTask" DependsOnTargets="RestoreNugetPackages">
<MSBuild Projects="$(LibraryToolsFolder)\Microsoft.WindowsAzure.Build.Tasks\Microsoft.WindowsAzure.Build.Tasks.csproj"
Targets="Build"
Properties="Configuration=Debug;Platform=AnyCPU" />
</Target>
<Target Name="RestoreNugetPackages">
<CallTarget Targets="RestoreAllNugetPackages" Condition=" '$(CodeGen)' == 'true' " />
<CallTarget Targets="RestorePublicNugetPackages" Condition=" '$(CodeGen)' != 'true' " />
</Target>
<!--
Force nuget package restore so that packages that include .targets files
do not need to be checked into source control.
Assumes use of a private feed.
PRIVATE_FEED_URL: The url of the feed to pull from with specific credentials (in addition to the public default feed)
PRIVATE_FEED_USER_NAME: User name for access to the feed
PRIVATE_FEED_PASSWORD: Password for access to the feed
-->
<Target Name="RestoreAllNugetPackages">
<PropertyGroup>
<NuGetRestoreConfigFile>$(LibraryRoot)restore.config</NuGetRestoreConfigFile>
<NuGetRestoreConfigSwitch>-ConfigFile "$(NuGetRestoreConfigFile)"</NuGetRestoreConfigSwitch>
</PropertyGroup>
<!-- Create config for user name and password for private feed access -->
<Delete Files="$(NuGetRestoreConfigFile)" />
<WriteLinesToFile
File="$(NuGetRestoreConfigFile)"
Lines="<configuration></configuration>"
Overwrite="true"
Encoding="Unicode"/>
<!-- Private versions of packages are picked up from these feeds, defined with environment variables -->
<Exec Command="$(NuGetCommand) sources add -Name PrimaryFeed -Source "$(PRIVATE_FEED_URL)" $(NuGetRestoreConfigSwitch)" Condition=" '$(PRIVATE_FEED_URL)'!='' "/>
<Exec Command="$(NuGetCommand) sources Update -Name PrimaryFeed -UserName $(PRIVATE_FEED_USER_NAME) -Password "$(PRIVATE_FEED_PASSWORD)" $(NuGetRestoreConfigSwitch)" EchoOff="true" Condition=" '$(PRIVATE_FEED_PASSWORD)'!='' AND '$(PRIVATE_FEED_USER_NAME)'!='' "/>
<Exec Command="$(NuGetCommand) sources add -Name SecondaryFeed -Source "$(SECONDARY_FEED_URL)" $(NuGetRestoreConfigSwitch)" Condition=" '$(SECONDARY_FEED_URL)'!='' "/>
<Exec Command="$(NuGetCommand) sources Update -Name SecondaryFeed -UserName $(SECONDARY_FEED_USER_NAME) -Password "$(SECONDARY_FEED_PASSWORD)" $(NuGetRestoreConfigSwitch)" EchoOff="true" Condition=" '$(SECONDARY_FEED_PASSWORD)'!='' AND '$(SECONDARY_FEED_USER_NAME)'!='' "/>
<Exec Command="$(NuGetCommand) sources add -Name AzureSdkInternalFeed -Source "https://www.myget.org/F/azure-sdk-internal/" $(NuGetRestoreConfigSwitch)"/>
<!--TODO: respect the 'scope', and do not always restore all of them-->
<Exec Command="$(NuGetCommand) restore $(CommonSolution) $(NuGetRestoreConfigSwitch)"/>
<Exec Command="$(NuGetCommand) restore $(AuthenticationSolution) $(NuGetRestoreConfigSwitch)"/>
<Exec Command="$(NuGetCommand) restore $(ManagementLibrariesSolution) $(NuGetRestoreConfigSwitch)" />
<!-- delete config file, don't want to leave passwords hanging around on the build server file system -->
<Delete Files="$(NuGetRestoreConfigFile)" />
</Target>
<Target Name="RestorePublicNugetPackages">
<Exec Command="$(NuGetCommand) restore "$(LibraryToolsFolder)\Packages.config" -PackagesDirectory "$(LibraryRoot)\packages" -source "https://www.nuget.org/api/v2/;https://www.myget.org/F/azure-sdk-internal/" -NonInteractive" />
</Target>
<!--Smoke test the packages under the output dir-->
<Target Name="VerifyPackages">
<PropertyGroup>
<_TestProject>$(LibraryToolsFolder)\VerifyPackages\VerifyPackages.sln</_TestProject>
<_TestExecutable>$(LibraryToolsFolder)\VerifyPackages\bin\debug\VerifyPackages.exe</_TestExecutable>
</PropertyGroup>
<Error Text="Please provide a publish settings file for the 'Creds' property" Condition=" '$(Creds)' == '' " />
<Exec Command="$(NuGetCommand) restore $(_TestProject) -source "$(PackageOutputDir)""/>
<MSBuild Projects="$(_TestProject)" Targets="Build" Properties="Configuration=Debug;Platform=Any CPU" />
<Exec Command="$(_TestExecutable) $(Creds)" />
</Target>
<!--
We have some important work to do when building our official Library bits.
-->
<Target Name="ValidateCorporateCompliance">
<Error Text="This target must be run in an on-premise build server." Condition=" '$(OnPremiseBuild)'=='false' " />
<CallTarget Targets="CorporateValidation" />
</Target>
<!--
Tasks that should be performed on any build server before getting to work.
-->
<Target Name="BuildServerPreparation">
<!-- Log server information -->
<Message Text="Build Server Information" Importance="high" />
<Message Text="Hostname : $(COMPUTERNAME)" />
<Message Text="Build Account : $(USERDOMAIN)\$(USERNAME)" />
<!-- Useful variables to log -->
<Message Text="Build Properties and Variables" Importance="high" />
<Message Text="Common Solution : $(CommonSolution)" />
<Message Text="Libraries Solution : $(ManagementLibrariesSolution)" />
<Message Text="Library : $(LibraryFriendlyName)" />
<Message Text="Source folder : $(LibrarySourceFolder)" />
<!-- Modify local files -->
<CallTarget Targets="BurnBuildVersions" />
</Target>
<!--
Burn the build information into the assembly file information, NuGet specs,
and other source files before beginning a build.
This updates the AssemblyFileVersion for .NET assemblies.
If you accidentally run this within your enlistment, revert AssemblyInfo.cs
changes before commiting to Git.
-->
<Target Name="BurnBuildVersions"
DependsOnTargets="GetGeneratedBuildDate">
<Message Text="Destructive burn of assembly file versions to include the build number in the revision component." />
<ItemGroup>
<AssemblyInfoFilesToUpdate Include="$(LibrarySourceFolder)\*\Properties\AssemblyInfo.cs" />
</ItemGroup>
<RegexReplacementTask Files="@(AssemblyInfoFilesToUpdate)"
Find="AssemblyFileVersion\("(?<semver>\d{1,3}\.\d{1,3}\.\d{1,3}).(?<revision>)\d{1,3}"\)"
Replace="AssemblyFileVersion("${semver}.$(GeneratedBuildDate)")"
LogReplacement="true" />
</Target>
<Target Name="GetGeneratedBuildDate">
<GetBuildVersionTask>
<Output TaskParameter="Date" PropertyName="GeneratedBuildDate" />
</GetBuildVersionTask>
</Target>
<Import Project="$(LibraryToolsFolder)\nuget.targets" />
</Project>