forked from Azure/azure-functions-host
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WebJobs.Script.proj
288 lines (246 loc) · 12.3 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
<?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>0.2.$(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>
</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="Build" DependsOnTargets="RestorePackages;GetBinplace">
<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*"/>
<EdgeJsFiles Include="$(ScriptHostOutput)\edge\**\*.*"/>
</ItemGroup>
<Copy SourceFiles="@(ScriptHostBinaries)" DestinationFolder="$(PublishPath)\Binaries\WebJobs.Script.Host" />
<Copy SourceFiles="@(EdgeJsFiles)" DestinationFiles="@(EdgeJsFiles->'$(PublishPath)\Binaries\WebJobs.Script.Host\edge\%(RecursiveDir)%(Filename)%(Extension)')" />
<Zip
InputPath="$(PublishPath)\Binaries\WebJobs.Script.Host"
OutputFileName="$(PublishPath)\Packages\WebJobs.Script.Host.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.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="UnitTest" DependsOnTargets="CheckSkipStrongNames;Build">
<ItemGroup>
<UnitTestProjects Include="test\WebJobs.Script.Tests\WebJobs.Script.Tests.csproj"/>
</ItemGroup>
<MSBuild Projects="@(UnitTestProjects)"
Properties="$(SetConfiguration); $(SetPlatform)"
BuildInParallel="$(BuildInParallel)">
<Output TaskParameter="TargetOutputs" ItemName="UnitTestAssemblies"/>
</MSBuild>
<xunit Assemblies="@(UnitTestAssemblies)" ExcludeTraits="$(ExcludedTestTraits)"/>
</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>
</Project>