-
Notifications
You must be signed in to change notification settings - Fork 75
/
ServerSdk.proj
174 lines (149 loc) · 8.78 KB
/
ServerSdk.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
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build;UnitTests;NugetPack" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition="'$(Configuration)' == ''">Release</Configuration>
<Platform Condition="'$(Platform)' == ''">Any CPU</Platform>
<OutputPath Condition="'$(OutputPath)' == ''">$(MSBuildProjectDirectory)\build_output\</OutputPath>
<OutputPathBin>$(OutputPath)\Bin\</OutputPathBin>
<OutputPathPackages>$(OutputPath)\Packages\</OutputPathPackages>
<OutputPathTests>$(OutputPath)\TestResults\</OutputPathTests>
<NuGetExe>tools\NuGet.exe</NuGetExe>
<Prerelease>-alpha</Prerelease>
<BuildNumber Condition="'$(BUILD_NUMBER)' != ''">-$(BUILD_NUMBER)</BuildNumber>
</PropertyGroup>
<ItemGroup>
<Package Include="src/Microsoft.Azure.Mobile.Server/Microsoft.Azure.Mobile.Server.csproj"/>
<Package Include="src/Microsoft.Azure.Mobile.Server.Authentication/Microsoft.Azure.Mobile.Server.Authentication.csproj"/>
<Package Include="src/Microsoft.Azure.Mobile.Server.CrossDomain/Microsoft.Azure.Mobile.Server.CrossDomain.csproj"/>
<Package Include="src/Microsoft.Azure.Mobile.Server.Entity/Microsoft.Azure.Mobile.Server.Entity.csproj"/>
<Package Include="src/Microsoft.Azure.Mobile.Server.Home/Microsoft.Azure.Mobile.Server.Home.csproj"/>
<Package Include="src/Microsoft.Azure.Mobile.Server.Login/Microsoft.Azure.Mobile.Server.Login.csproj"/>
<Package Include="src/Microsoft.Azure.Mobile.Server.Notifications/Microsoft.Azure.Mobile.Server.Notifications.csproj"/>
<Package Include="src/Microsoft.Azure.Mobile.Server.QuickStart/Microsoft.Azure.Mobile.Server.QuickStart.csproj"/>
<Package Include="src/Microsoft.Azure.Mobile.Server.Storage/Microsoft.Azure.Mobile.Server.Storage.csproj"/>
<Package Include="src/Microsoft.Azure.Mobile.Server.Swagger/Microsoft.Azure.Mobile.Server.Swagger.csproj"/>
<Package Include="src/Microsoft.Azure.Mobile.Server.Tables/Microsoft.Azure.Mobile.Server.Tables.csproj"/>
</ItemGroup>
<ItemGroup>
<Build Include="ServerSDK.sln" />
<Build Include="Templates.sln" />
</ItemGroup>
<Target Name="DownloadNuGet">
<DownloadNuGet OutputFileName="$(NuGetExe)" MinimumVersion="2.7.0" />
</Target>
<Target Name="RestorePackages" DependsOnTargets="DownloadNuGet">
<Message Text="Restoring NuGet packages..." Importance="High" />
<Exec Command='"$(NuGetExe)" restore ServerSDK.sln -PackagesDirectory packages -NonInteractive -Config .nuget\nuget.config' />
</Target>
<Target Name="Build" DependsOnTargets="RestorePackages">
<!-- Read the (eventual) nuget version from AssemblyInfo.cs. This is used for template generation -->
<ParseNugetVersion AssemblyInfoFile="src\Common\CommonAssemblyInfo.cs">
<Output TaskParameter="NugetVersion" PropertyName="NugetVersion" />
</ParseNugetVersion>
<MSBuild Projects="@(Build)"
BuildInParallel="True"
Properties="OutputPath=$(OutputPathBin);Configuration=$(Configuration);Platform=$(Platform);RunXunitTests=false;NugetVersion=$(NugetVersion)" />
</Target>
<UsingTask TaskName="Xunit.Runner.MSBuild.xunit"
AssemblyFile="packages\xunit.runner.msbuild.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.runner.msbuild.dll" />
<Target Name="UnitTests">
<ItemGroup>
<TestAssemblies Include="$(OutputPathBin)Microsoft.Azure.Mobile.Server*.Test.dll"/>
</ItemGroup>
<MakeDir Directories="$(OutputPathTests)" />
<xunit Assemblies="@(TestAssemblies)" ParallelizeAssemblies="true" ParallelizeTestCollections="false" Xml="$(OutputPathTests)results.xml" Html="$(OutputPathTests)results.html" />
</Target>
<Target Name="NugetPack" DependsOnTargets="DownloadNuGet">
<MakeDir Directories="$(OutputPathPackages)\Prerelease" />
<MakeDir Directories="$(OutputPathPackages)\Release" />
<!-- Build two sets of packages so we can be prepared to release without needing to re-build -->
<Message Text="Building release and prerelease NuGet packages for %(Package.Identity)" Importance="High" />
<Exec Command='"$(NuGetExe)" pack %(Package.Identity) -BasePath $(OutputPathBin) -Symbols -OutputDirectory $(OutputPathPackages)\Release -Prop OutputPath=$(OutputPathBin) -IncludeReferencedProjects -Properties prerelease=' />
<Exec Command='"$(NuGetExe)" pack %(Package.Identity) -BasePath $(OutputPathBin) -OutputDirectory $(OutputPathPackages)\Prerelease -Prop OutputPath=$(OutputPathBin) -IncludeReferencedProjects -Properties prerelease=$(Prerelease)$(BuildNumber)' />
</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...");
Directory.CreateDirectory(Path.GetDirectoryName(OutputFileName));
WebClient webClient = new WebClient();
// Get the latest nuget client. Some build machines were having issues with the version from nuget.org/nuget.exe
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="ParseNugetVersion" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
<ParameterGroup>
<AssemblyInfoFile ParameterType="System.String" Required="true" />
<NugetVersion ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>
<Code Type="Fragment" Language="cs">
<![CDATA[
AssemblyInfoFile = Path.GetFullPath(AssemblyInfoFile);
var lines = File.ReadAllLines(AssemblyInfoFile);
var assemblyInfo = lines.Single (l => l.Contains("AssemblyInformational"));
var firstIndex = assemblyInfo.IndexOf("\"") + 1;
var lastIndex = assemblyInfo.LastIndexOf("\"");
NugetVersion = assemblyInfo.Substring(firstIndex, lastIndex-firstIndex);
]]>
</Code>
</Task>
</UsingTask>
</Project>