forked from Azure/azure-sdk-for-net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.proj
277 lines (230 loc) · 12.6 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
<?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: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>
<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="$(LibrarySourceFolder)\$(Scope)\*.csproj" Condition=" '$(Scope)' != 'Common' and '$(Scope)' != 'Authentication' and '$(Scope)' != 'All' " />
<LibraryFxTargetList Include="$(FxTargetList)" />
</ItemGroup>
<PropertyGroup>
<NuGetCommand>"$(LibraryToolsFolder)\nuget.exe"</NuGetCommand>
</PropertyGroup>
<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)</_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="@(ManagementLibrariesProjects)"
Properties="Configuration=%(LibraryFxTargetList.Identity)-$(Configuration);Platform=AnyCPU;$(_ExtraPropertyList)"
Targets="Build" />
<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" />
<Message Text="Signing project: $(MSBuildProjectFullPath)" />
<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">
<!--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)" />
</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)" />
</Target>
<Import Project="$(LibraryToolsFolder)\nuget.targets" />
</Project>