forked from Azure/azure-functions-host
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWebJobs.Script.proj
357 lines (307 loc) · 15.7 KB
/
WebJobs.Script.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
352
353
354
355
356
357
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="PackageScriptHost;PackageWebHost;UnitTest" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildInParallel Condition=" '$(BuildInParallel)' == ''">true</BuildInParallel>
<NuGetExe>tools\NuGet.exe</NuGetExe>
<SkipStrongNamesExe>packages\Microsoft.Web.SkipStrongNames.1.0.0\tools\SkipStrongNames.exe</SkipStrongNamesExe>
<SkipStrongNamesXml>tools\SkipStrongNames.xml</SkipStrongNamesXml>
<PublishPath Condition=" '$(PublishPath)' == '' ">bin</PublishPath>
<BuildNumber Condition=" '$(BuildNumber)' == '' ">0</BuildNumber>
<SiteExtensionVersion>1.0.$(BuildNumber)</SiteExtensionVersion>
<SiteExtensionBasePath>$(PublishPath)\Packages\SiteExtension</SiteExtensionBasePath>
<SiteExtensionPath>$(SiteExtensionBasePath)\$(SiteExtensionVersion)</SiteExtensionPath>
<ExtensionXml>src\SiteExtension\extension.xml</ExtensionXml>
<SetConfiguration Condition=" '$(Configuration)' != '' ">Configuration=$(Configuration)</SetConfiguration>
<SetPlatform Condition=" '$(Platform)' != '' ">Platform=$(Platform)</SetPlatform>
</PropertyGroup>
<ItemGroup>
<!-- The Assembly items below MUST be kept in dependency order. -->
<Build Include="src\WebJobs.Script\WebJobs.Script.csproj">
<PublishType>Assembly</PublishType>
<PublishPath>$(PublishPath)\Binaries</PublishPath>
</Build>
<Build Include="src\WebJobs.Script.Host\WebJobs.Script.Host.csproj">
<PublishType>Assembly</PublishType>
<PublishPath>$(PublishPath)\Binaries</PublishPath>
</Build>
<Build Include="src\WebJobs.Script.NuGet\WebJobs.Script.nuproj">
<PublishType>File</PublishType>
<PublishPath>$(PublishPath)\Packages</PublishPath>
</Build>
<Build Include="src\WebJobs.Script.Extensibility.NuGet\WebJobs.Script.Extensibility.nuproj">
<PublishType>File</PublishType>
<PublishPath>$(PublishPath)\Packages</PublishPath>
</Build>
<Build Include="src\WebJobs.Script.WebHost.NuGet\WebJobs.Script.WebHost.nuproj">
<PublishType>File</PublishType>
<PublishPath>$(PublishPath)\Packages</PublishPath>
</Build>
</ItemGroup>
<UsingTask TaskName="SkipStrongNames.CheckSkipStrongNamesStatus" AssemblyFile="$(SkipStrongNamesExe)" />
<Target Name="DownloadNuGet">
<DownloadNuGet OutputFileName="$(NuGetExe)" MinimumVersion="3.3.0" />
</Target>
<Target Name="RestoreSkipStrongNames" DependsOnTargets="DownloadNuGet">
<Exec Command='"$(NuGetExe)" restore .nuget\packages.config -PackagesDirectory packages -NonInteractive -Verbosity quiet -ConfigFile .nuget\NuGet.Config' />
</Target>
<Target Name="CheckSkipStrongNames" DependsOnTargets="RestoreSkipStrongNames">
<CheckSkipStrongNamesStatus AssembliesFile="$(SkipStrongNamesXml)">
<Output TaskParameter="Status" PropertyName="Status" />
</CheckSkipStrongNamesStatus>
<Error Text="Unit tests will not run correctly unless SkipStrongNames is Enabled. Current status: $(Status). Run the EnableSkipStrongNames target to fix this problem." Condition="'$(Status)' != 'Enabled'" />
</Target>
<Target Name="EnableSkipStrongNames" DependsOnTargets="RestoreSkipStrongNames">
<Exec Command='"$(SkipStrongNamesExe)" -e "$(SkipStrongNamesXml)"' />
<CheckSkipStrongNamesStatus AssembliesFile="$(SkipStrongNamesXml)">
<Output TaskParameter="Status" PropertyName="Status" />
</CheckSkipStrongNamesStatus>
<Message Text="SkipStrongNames: $(Status)" Importance="High" />
</Target>
<Target Name="DisableSkipStrongNames" DependsOnTargets="RestoreSkipStrongNames">
<Exec Command='"$(SkipStrongNamesExe)" -d "$(SkipStrongNamesXml)"' />
<CheckSkipStrongNamesStatus AssembliesFile="$(SkipStrongNamesXml)">
<Output TaskParameter="Status" PropertyName="Status" />
</CheckSkipStrongNamesStatus>
<Message Text="SkipStrongNames: $(Status)" Importance="High" />
</Target>
<Target Name="RestorePackages" DependsOnTargets="DownloadNuGet">
<Message Text="Restoring NuGet packages..." Importance="High" />
<Exec Command='"$(NuGetExe)" restore WebJobs.Script.sln -PackagesDirectory packages -NonInteractive -Verbosity quiet -ConfigFile .nuget\NuGet.Config' />
</Target>
<Target Name="GetBinplace">
<PropertyGroup>
<NestedBuildProperties Condition=" '$(SetConfiguration)' != '' or '$(SetPlatform)' != ''">$(SetConfiguration); $(SetPlatform)</NestedBuildProperties>
</PropertyGroup>
<ItemGroup>
<Binplace Include="tools\Binplace\%(Build.PublishType).proj">
<Properties>ProjectFile=%(FullPath); BinplaceOutputPath=$([System.IO.Path]::GetFullPath('%(PublishPath)')); Properties=$(NestedBuildProperties)</Properties>
</Binplace>
</ItemGroup>
</Target>
<Target Name="UpdateAssemblyInfo" Condition="'$(BuildNumber)' != '0'">
<PropertyGroup>
<CommonAssemblyInfoFile>$(MSBuildProjectDirectory)\src\Common\CommonAssemblyInfo.cs</CommonAssemblyInfoFile>
</PropertyGroup>
<Message Text="Updating the AssemblyFileVersion to include the build number: $(BuildNumber)" />
<ReplaceFileText
FileName="$(CommonAssemblyInfoFile)"
MatchExpression="(?<=\[assembly: AssemblyFileVersion\("\d+.\d+.)\d+(?=.\d+"\)\])"
ReplacementText="$(BuildNumber)" />
</Target>
<Target Name="Build" DependsOnTargets="RestorePackages;GetBinplace;UpdateAssemblyInfo">
<MSBuild Projects="@(Binplace)"
BuildInParallel="$(BuildInParallel)"/>
</Target>
<Target Name="PackageScriptHost" DependsOnTargets="Build">
<PropertyGroup>
<ScriptHostOutput>.\src\WebJobs.Script.Host\bin\$(Configuration)</ScriptHostOutput>
</PropertyGroup>
<ItemGroup>
<ScriptHostBinaries Include="$(ScriptHostOutput)\*.dll;$(ScriptHostOutput)\*.exe*;$(ScriptHostOutput)\*.optdata;$(ScriptHostOutput)\*.sigdata"/>
<EdgeJsFiles Include="$(ScriptHostOutput)\edge\**\*.*"/>
<StaticContent Include="$(ScriptHostOutput)\azurefunctions\**\*.*"/>
</ItemGroup>
<Copy SourceFiles="@(ScriptHostBinaries)" DestinationFolder="$(PublishPath)\Binaries\WebJobs.Script.Host" />
<Copy SourceFiles="@(EdgeJsFiles)" DestinationFiles="@(EdgeJsFiles->'$(PublishPath)\Binaries\WebJobs.Script.Host\edge\%(RecursiveDir)%(Filename)%(Extension)')" />
<Copy SourceFiles="@(StaticContent)" DestinationFiles="@(StaticContent->'$(PublishPath)\Binaries\WebJobs.Script.Host\azurefunctions\%(RecursiveDir)%(Filename)%(Extension)')" />
<Zip
InputPath="$(PublishPath)\Binaries\WebJobs.Script.Host"
OutputFileName="$(PublishPath)\Packages\WebJobs.Script.Host.$(SiteExtensionVersion).zip"
OverwriteExistingFile="true"
/>
</Target>
<Target Name="PackageWebHost" DependsOnTargets="Build">
<MSBuild Projects="src\WebJobs.Script.WebHost\WebJobs.Script.WebHost.csproj"
Properties="DeployOnBuild=true; PublishProfile=FileSystem">
</MSBuild>
<Zip
InputPath=".\src\WebJobs.Script.WebHost\Publish"
OutputFileName="$(PublishPath)\Packages\Functions.Private.$(SiteExtensionVersion).zip"
OverwriteExistingFile="true"/>
<!--Create site extension package -->
<MakeDir Directories="@(SiteExtensionPath)"/>
<ItemGroup>
<SiteExtensionSource Include=".\src\WebJobs.Script.WebHost\Publish\SiteExtensions\Functions\**\*.*" />
</ItemGroup>
<Copy SourceFiles="@(SiteExtensionSource)" DestinationFiles="@(SiteExtensionSource->'$(SiteExtensionPath)\%(RecursiveDir)%(Filename)%(Extension)')" />
<Copy SourceFiles="$(ExtensionXml)" DestinationFolder="$(SiteExtensionBasePath)" />
<Zip
InputPath="$(SiteExtensionBasePath)"
OutputFileName="$(PublishPath)\Packages\Functions.$(SiteExtensionVersion).zip"
OverwriteExistingFile="true"/>
<RemoveDir Directories="$(SiteExtensionBasePath)" />
</Target>
<UsingTask TaskName="Xunit.Runner.MSBuild.xunit" AssemblyFile="packages\xunit.MSBuild.2.0.0.0\tools\xunit.runner.msbuild.dll"/>
<Target Name="TestBuild" DependsOnTargets="CheckSkipStrongNames;Build">
<ItemGroup>
<UnitTestProjects Include="test\WebJobs.Script.Tests\WebJobs.Script.Tests.csproj"/>
<IntegrationTestProjects Include="test\WebJobs.Script.Tests.Integration\WebJobs.Script.Tests.Integration.csproj"/>
</ItemGroup>
<MSBuild Projects="@(UnitTestProjects)"
Properties="$(SetConfiguration); $(SetPlatform)"
BuildInParallel="$(BuildInParallel)">
<Output TaskParameter="TargetOutputs" ItemName="UnitTestAssemblies"/>
</MSBuild>
<MSBuild Projects="@(IntegrationTestProjects)"
Properties="$(SetConfiguration); $(SetPlatform)"
BuildInParallel="$(BuildInParallel)">
<Output TaskParameter="TargetOutputs" ItemName="IntegrationTestAssemblies"/>
</MSBuild>
</Target>
<Target Name="UnitTest" DependsOnTargets="TestBuild">
<xunit Assemblies="@(UnitTestAssemblies)" ExcludeTraits="$(ExcludedTestTraits)" />
</Target>
<Target Name="IntegrationTest" DependsOnTargets="TestBuild">
<xunit Assemblies="@(IntegrationTestAssemblies)" ExcludeTraits="$(ExcludedTestTraits)" />
</Target>
<PropertyGroup Condition=" '$(APPVEYOR_API_URL)' != '' ">
<AppveyorModules>mocha-appveyor-reporter</AppveyorModules>
<AppveyorReporter>--reporter mocha-appveyor-reporter</AppveyorReporter>
</PropertyGroup>
<PropertyGroup>
<BuildConfiguration>Debug</BuildConfiguration>
<BuildConfiguration Condition=" $(Configuration) != '' ">$(Configuration)</BuildConfiguration>
</PropertyGroup>
<Target Name="MochaTest" DependsOnTargets="TestBuild" AfterTargets="UnitTest">
<Exec Command="npm i mocha chai $(AppveyorModules)" />
<Exec Command=".\node_modules\.bin\mocha .\test\WebJobs.Script.Tests.Integration\TestScripts\Node\*.tests.js $(AppveyorReporter) --config=$(BuildConfiguration)" />
</Target>
<Target Name="Clean" DependsOnTargets="GetBinplace">
<MSBuild Projects="@(Binplace)"
Targets="Clean"
BuildInParallel="$(BuildInParallel)"/>
</Target>
<Target Name="Rebuild" DependsOnTargets="Clean;Build"/>
<Target Name="GetOfficialProjects" Returns="@(OfficialProjects)">
<ItemGroup>
<OfficialProjects Include="%(Build.FullPath)">
<PublishType>%(Build.PublishType)</PublishType>
<PublishPath>$([System.IO.Path]::GetFullPath('%(Build.PublishPath)'))</PublishPath>
</OfficialProjects>
</ItemGroup>
</Target>
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
<ParameterGroup>
<OutputFileName ParameterType="System.String" Required="true" />
<MinimumVersion ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System.Diagnostics" />
<Using Namespace="System.Net" />
<Code Type="Fragment" Language="cs">
<![CDATA[
Version minimumRequiredVersion;
if (!Version.TryParse(MinimumVersion, out minimumRequiredVersion))
{
Log.LogError("MinimumVersion '{0}' is not a valid Version.", MinimumVersion);
}
try
{
OutputFileName = Path.GetFullPath(OutputFileName);
if (File.Exists(OutputFileName))
{
// If NuGet.exe exists but is less than the minimum required version, delete it so that the
// latest version will be downloaded.
FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(OutputFileName);
string toParse;
if (versionInfo != null && versionInfo.ProductVersion != null)
{
toParse = versionInfo.ProductVersion;
}
else
{
toParse = null;
}
Version current;
Version parsed;
if (toParse != null && Version.TryParse(toParse, out parsed))
{
current = parsed;
}
else
{
// Treat a missing or invalid version like V0.0 (which will trigger a delete and download).
current = new Version(0, 0);
}
if (current < minimumRequiredVersion)
{
File.Delete(OutputFileName);
}
}
if (!File.Exists(OutputFileName))
{
Log.LogMessage("Downloading latest version of NuGet.exe...");
WebClient webClient = new WebClient();
webClient.DownloadFile("https://dist.nuget.org/win-x86-commandline/latest/nuget.exe", OutputFileName);
}
return true;
}
catch (Exception ex)
{
Log.LogErrorFromException(ex);
return false;
}
]]>
</Code>
</Task>
</UsingTask>
<UsingTask TaskName="Zip" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<InputPath ParameterType="System.String" Required="true" />
<OutputFileName ParameterType="System.String" Required="true" />
<OverwriteExistingFile ParameterType="System.Boolean" Required="false" />
</ParameterGroup>
<Task>
<Reference Include="System.IO.Compression" />
<Using Namespace="System.IO.Compression" />
<Code Type="Fragment" Language="cs">
<![CDATA[
const int BufferSize = 64 * 1024;
var buffer = new byte[BufferSize];
var fileMode = OverwriteExistingFile ? FileMode.Create : FileMode.CreateNew;
string[] InputFileNames = Directory.GetFiles(InputPath, "*.*", SearchOption.AllDirectories);
using (var outputFileStream = new FileStream(OutputFileName, fileMode))
{
using (var archive = new ZipArchive(outputFileStream, ZipArchiveMode.Create))
{
foreach (var inputFileName in InputFileNames)
{
string relativeFileName = inputFileName.Substring(InputPath.Length + 1);
var archiveEntry = archive.CreateEntry(relativeFileName);
using (var fs = new FileStream(inputFileName, FileMode.Open))
{
using (var zipStream = archiveEntry.Open())
{
int bytesRead = -1;
while ((bytesRead = fs.Read(buffer, 0, BufferSize)) > 0)
{
zipStream.Write(buffer, 0, bytesRead);
}
}
}
}
}
}
]]>
</Code>
</Task>
</UsingTask>
<UsingTask TaskName="ReplaceFileText" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<FileName ParameterType="System.String" Required="true" />
<MatchExpression ParameterType="System.String" Required="true" />
<ReplacementText ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Text.RegularExpressions" />
<Code Type="Fragment" Language="cs">
<![CDATA[
File.WriteAllText(FileName, Regex.Replace(File.ReadAllText(FileName), MatchExpression, ReplacementText));
]]>
</Code>
</Task>
</UsingTask>
</Project>