1
+ <?xml version =" 1.0" encoding =" utf-8" ?>
2
+ <Project ToolsVersion =" 12.0" DefaultTargets =" UnitTest" xmlns =" http://schemas.microsoft.com/developer/msbuild/2003" >
3
+ <PropertyGroup >
4
+ <BuildInParallel Condition =" '$(BuildInParallel)' == ''" >true</BuildInParallel >
5
+ <NuGetExe >tools\NuGet.exe</NuGetExe >
6
+ <SkipStrongNamesExe >packages\Microsoft.Web.SkipStrongNames.1.0.0\tools\SkipStrongNames.exe</SkipStrongNamesExe >
7
+ <SkipStrongNamesXml >tools\SkipStrongNames.xml</SkipStrongNamesXml >
8
+ <PublishPath Condition =" '$(PublishPath)' == '' " >bin</PublishPath >
9
+ <SetConfiguration Condition =" '$(Configuration)' != '' " >Configuration=$(Configuration)</SetConfiguration >
10
+ <SetPlatform Condition =" '$(Platform)' != '' " >Platform=$(Platform)</SetPlatform >
11
+ </PropertyGroup >
12
+
13
+ <ItemGroup >
14
+ <!-- The Assembly items below MUST be kept in dependency order. -->
15
+ <Build Include =" src\WebJobs.Script\WebJobs.Script.csproj" >
16
+ <PublishType >Assembly</PublishType >
17
+ <PublishPath >$(PublishPath)\Binaries</PublishPath >
18
+ </Build >
19
+ <Build Include =" src\WebJobs.Script.Host\WebJobs.Script.Host.csproj" >
20
+ <PublishType >Assembly</PublishType >
21
+ <PublishPath >$(PublishPath)\Binaries</PublishPath >
22
+ </Build >
23
+ <Build Include =" src\WebJobs.Script.NuGet\WebJobs.Script.nuproj" >
24
+ <PublishType >File</PublishType >
25
+ <PublishPath >$(PublishPath)\Packages</PublishPath >
26
+ </Build >
27
+ </ItemGroup >
28
+
29
+ <UsingTask TaskName =" SkipStrongNames.CheckSkipStrongNamesStatus" AssemblyFile =" $(SkipStrongNamesExe)" />
30
+
31
+ <Target Name =" DownloadNuGet" >
32
+ <DownloadNuGet OutputFileName =" $(NuGetExe)" MinimumVersion =" 2.7.0" />
33
+ </Target >
34
+
35
+ <Target Name =" RestoreSkipStrongNames" DependsOnTargets =" DownloadNuGet" >
36
+ <Exec Command =' "$(NuGetExe)" restore .nuget\packages.config -PackagesDirectory packages -NonInteractive -Verbosity quiet -ConfigFile .nuget\NuGet.Config' />
37
+ </Target >
38
+
39
+ <Target Name =" CheckSkipStrongNames" DependsOnTargets =" RestoreSkipStrongNames" >
40
+ <CheckSkipStrongNamesStatus AssembliesFile =" $(SkipStrongNamesXml)" >
41
+ <Output TaskParameter =" Status" PropertyName =" Status" />
42
+ </CheckSkipStrongNamesStatus >
43
+ <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'" />
44
+ </Target >
45
+
46
+ <Target Name =" EnableSkipStrongNames" DependsOnTargets =" RestoreSkipStrongNames" >
47
+ <Exec Command =' "$(SkipStrongNamesExe)" -e "$(SkipStrongNamesXml)"' />
48
+ <CheckSkipStrongNamesStatus AssembliesFile =" $(SkipStrongNamesXml)" >
49
+ <Output TaskParameter =" Status" PropertyName =" Status" />
50
+ </CheckSkipStrongNamesStatus >
51
+ <Message Text =" SkipStrongNames: $(Status)" Importance =" High" />
52
+ </Target >
53
+
54
+ <Target Name =" DisableSkipStrongNames" DependsOnTargets =" RestoreSkipStrongNames" >
55
+ <Exec Command =' "$(SkipStrongNamesExe)" -d "$(SkipStrongNamesXml)"' />
56
+ <CheckSkipStrongNamesStatus AssembliesFile =" $(SkipStrongNamesXml)" >
57
+ <Output TaskParameter =" Status" PropertyName =" Status" />
58
+ </CheckSkipStrongNamesStatus >
59
+ <Message Text =" SkipStrongNames: $(Status)" Importance =" High" />
60
+ </Target >
61
+
62
+ <Target Name =" RestorePackages" DependsOnTargets =" DownloadNuGet" >
63
+ <Message Text =" Restoring NuGet packages..." Importance =" High" />
64
+ <Exec Command =' "$(NuGetExe)" restore WebJobs.Script.sln -PackagesDirectory packages -NonInteractive -Verbosity quiet -ConfigFile .nuget\NuGet.Config' />
65
+ </Target >
66
+
67
+ <Target Name =" GetBinplace" >
68
+ <PropertyGroup >
69
+ <NestedBuildProperties Condition =" '$(SetConfiguration)' != '' or '$(SetPlatform)' != ''" >$(SetConfiguration); $(SetPlatform)</NestedBuildProperties >
70
+ </PropertyGroup >
71
+
72
+ <ItemGroup >
73
+ <Binplace Include =" tools\Binplace\%(Build.PublishType).proj" >
74
+ <Properties >ProjectFile=%(FullPath); BinplaceOutputPath=$([System.IO.Path]::GetFullPath('%(PublishPath)')); Properties=$(NestedBuildProperties)</Properties >
75
+ </Binplace >
76
+ </ItemGroup >
77
+ </Target >
78
+
79
+ <Target Name =" Build" DependsOnTargets =" RestorePackages;GetBinplace" >
80
+ <MSBuild Projects =" @(Binplace)"
81
+ BuildInParallel =" $(BuildInParallel)" />
82
+ </Target >
83
+
84
+ <UsingTask TaskName =" Xunit.Runner.MSBuild.xunit" AssemblyFile =" packages\xunit.MSBuild.2.0.0.0\tools\xunit.runner.msbuild.dll" />
85
+
86
+ <Target Name =" UnitTest" DependsOnTargets =" CheckSkipStrongNames;Build" >
87
+ <ItemGroup >
88
+ <UnitTestProjects Include =" test\WebJobs.Script.Tests\WebJobs.Script.Tests.csproj" />
89
+ </ItemGroup >
90
+
91
+ <MSBuild Projects =" @(UnitTestProjects)"
92
+ Properties =" $(SetConfiguration); $(SetPlatform)"
93
+ BuildInParallel =" $(BuildInParallel)" >
94
+ <Output TaskParameter =" TargetOutputs" ItemName =" UnitTestAssemblies" />
95
+ </MSBuild >
96
+
97
+ <xunit Assemblies =" @(UnitTestAssemblies)" />
98
+ </Target >
99
+
100
+ <Target Name =" Clean" DependsOnTargets =" GetBinplace" >
101
+ <MSBuild Projects =" @(Binplace)"
102
+ Targets =" Clean"
103
+ BuildInParallel =" $(BuildInParallel)" />
104
+ </Target >
105
+
106
+ <Target Name =" Rebuild" DependsOnTargets =" Clean;Build" />
107
+
108
+ <Target Name =" GetOfficialProjects" Returns =" @(OfficialProjects)" >
109
+ <ItemGroup >
110
+ <OfficialProjects Include =" %(Build.FullPath)" >
111
+ <PublishType >%(Build.PublishType)</PublishType >
112
+ <PublishPath >$([System.IO.Path]::GetFullPath('%(Build.PublishPath)'))</PublishPath >
113
+ </OfficialProjects >
114
+ </ItemGroup >
115
+ </Target >
116
+
117
+ <UsingTask TaskName =" DownloadNuGet" TaskFactory =" CodeTaskFactory" AssemblyFile =" $(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll" >
118
+ <ParameterGroup >
119
+ <OutputFileName ParameterType =" System.String" Required =" true" />
120
+ <MinimumVersion ParameterType =" System.String" Required =" true" />
121
+ </ParameterGroup >
122
+ <Task >
123
+ <Using Namespace =" System.Diagnostics" />
124
+ <Using Namespace =" System.Net" />
125
+ <Code Type =" Fragment" Language =" cs" >
126
+ <![CDATA[
127
+ Version minimumRequiredVersion;
128
+
129
+ if (!Version.TryParse(MinimumVersion, out minimumRequiredVersion))
130
+ {
131
+ Log.LogError("MinimumVersion '{0}' is not a valid Version.", MinimumVersion);
132
+ }
133
+
134
+ try
135
+ {
136
+ OutputFileName = Path.GetFullPath(OutputFileName);
137
+
138
+ if (File.Exists(OutputFileName))
139
+ {
140
+ // If NuGet.exe exists but is less than the minimum required version, delete it so that the
141
+ // latest version will be downloaded.
142
+ FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(OutputFileName);
143
+
144
+ string toParse;
145
+
146
+ if (versionInfo != null && versionInfo.ProductVersion != null)
147
+ {
148
+ toParse = versionInfo.ProductVersion;
149
+ }
150
+ else
151
+ {
152
+ toParse = null;
153
+ }
154
+
155
+ Version current;
156
+ Version parsed;
157
+
158
+ if (toParse != null && Version.TryParse(toParse, out parsed))
159
+ {
160
+ current = parsed;
161
+ }
162
+ else
163
+ {
164
+ // Treat a missing or invalid version like V0.0 (which will trigger a delete and download).
165
+ current = new Version(0, 0);
166
+ }
167
+
168
+ if (current < minimumRequiredVersion)
169
+ {
170
+ File.Delete(OutputFileName);
171
+ }
172
+ }
173
+
174
+ if (!File.Exists(OutputFileName))
175
+ {
176
+ Log.LogMessage("Downloading latest version of NuGet.exe...");
177
+ WebClient webClient = new WebClient();
178
+ webClient.DownloadFile("https://nuget.org/nuget.exe", OutputFileName);
179
+ }
180
+
181
+ return true;
182
+ }
183
+ catch (Exception ex)
184
+ {
185
+ Log.LogErrorFromException(ex);
186
+ return false;
187
+ }
188
+ ]]>
189
+ </Code >
190
+ </Task >
191
+ </UsingTask >
192
+ </Project >
0 commit comments