Skip to content

Commit a65a288

Browse files
committed
Adding build scripts for command line / CI build
1 parent f3b836c commit a65a288

File tree

10 files changed

+315
-2
lines changed

10 files changed

+315
-2
lines changed

.nuget/NuGet.Config

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
5+
<add key="azure_app_service" value="https://www.myget.org/F/azure-appservice/api/v2" />
6+
<add key="buildTools" value="https://www.myget.org/F/30de4ee06dd54956a82013fa17a3accb/" />
7+
</packageSources>
8+
</configuration>

.nuget/packages.config

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Microsoft.Web.SkipStrongNames" version="1.0.0" />
4+
<package id="xunit.MSBuild" version="2.0.0" />
5+
</packages>

WebJobs.Script.proj

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
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>

WebJobs.Script.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Resizer", "Resizer", "{5C45
9393
sample\ResizeImage\Resizer\Resizer.exe = sample\ResizeImage\Resizer\Resizer.exe
9494
EndProjectSection
9595
EndProject
96+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{446135EF-3B07-417B-80FF-06099AA81DFF}"
97+
ProjectSection(SolutionItems) = preProject
98+
.nuget\NuGet.Config = .nuget\NuGet.Config
99+
.nuget\packages.config = .nuget\packages.config
100+
EndProjectSection
101+
EndProject
96102
Global
97103
GlobalSection(SolutionConfigurationPlatforms) = preSolution
98104
Debug|Any CPU = Debug|Any CPU

sample/QueueTrigger-Python/queueTrigger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import json
33

44
# read the queue message and write to stdout
5-
input = raw_input();
5+
input = input();
66
message = "Python script processed queue message '{0}'".format(input)
77
print(message)
88

test/WebJobs.Script.Tests/TestScripts/Python/QueueTriggerToBlob/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22

33
# read the queue message and write to stdout
4-
input = raw_input();
4+
input = input();
55
message = "Python script processed queue message '{0}'".format(input)
66
print(message)
77

tools/Binplace/Assembly.proj

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="Common.targets"/>
4+
5+
<Target Name="CoreGetBinplace">
6+
<!-- For Targets, see AllProjectOutputGroups in Microsoft.Common.CurrentVersion.targets. -->
7+
<MSBuild Projects="$(ProjectFile)"
8+
Targets="BuiltProjectOutputGroup;
9+
DebugSymbolsProjectOutputGroup;
10+
DocumentationProjectOutputGroup"
11+
Properties="$(SetConfiguration); $(SetPlatform)"
12+
BuildInParallel="$(BuildInParallel)">
13+
<Output TaskParameter="TargetOutputs" ItemName="BinplaceInputs"/>
14+
</MSBuild>
15+
16+
<ItemGroup>
17+
<Binplace Include="@(BinplaceInputs)">
18+
<OutputPath>$(BinplaceOutputPath)\%(Filename)%(Extension)</OutputPath>
19+
</Binplace>
20+
</ItemGroup>
21+
</Target>
22+
</Project>

tools/Binplace/Common.targets

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<BuildInParallel Condition=" '$(BuildInParallel)' == ''">true</BuildInParallel>
5+
<SetConfiguration Condition=" '$(Configuration)' != '' ">Configuration=$(Configuration)</SetConfiguration>
6+
<SetPlatform Condition=" '$(Platform)' != '' ">Platform=$(Platform)</SetPlatform>
7+
</PropertyGroup>
8+
9+
<Target Name="ValidateBinplaceOutputPath">
10+
<Error Condition=" '$(BinplaceOutputPath)' == '' " Text="BinplaceOutputPath is not set."/>
11+
</Target>
12+
13+
<Target Name="GetBinplace" DependsOnTargets="ValidateBinplaceOutputPath;CoreGetBinplace"/>
14+
15+
<Target Name="BuildProjectFile">
16+
<MSBuild Projects="$(ProjectFile)"
17+
Properties="$(SetConfiguration); $(SetPlatform)"
18+
RemoveProperties="ProjectFile;BinplaceOutputPath"
19+
BuildInParallel="$(BuildInParallel)"/>
20+
</Target>
21+
22+
<Target Name="Build"
23+
DependsOnTargets="BuildProjectFile;GetBinplace"
24+
Inputs="@(Binplace)"
25+
Outputs="@(Binplace->'%(OutputPath)')">
26+
<Copy SourceFiles="@(Binplace)" DestinationFiles="%(Binplace.OutputPath)" SkipUnchangedFiles="true"/>
27+
</Target>
28+
29+
<Target Name="CleanProjectFile">
30+
<MSBuild Projects="$(ProjectFile)"
31+
Targets="Clean"
32+
Properties="$(SetConfiguration); $(SetPlatform)"
33+
BuildInParallel="$(BuildInParallel)"/>
34+
</Target>
35+
36+
<Target Name="Clean" DependsOnTargets="CleanProjectFile;GetBinplace">
37+
<Delete Files="%(Binplace.OutputPath)" Condition="Exists('%(Binplace.OutputPath)')"/>
38+
</Target>
39+
40+
<Target Name="Rebuild" DependsOnTargets="Clean;Build"/>
41+
</Project>

tools/Binplace/Directory.proj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="Common.targets"/>
4+
5+
<Target Name="CoreGetBinplace">
6+
<MSBuild Projects="$(ProjectFile)"
7+
Targets="GetOutputPath"
8+
Properties="$(SetConfiguration); $(SetPlatform)"
9+
BuildInParallel="$(BuildInParallel)">
10+
<Output TaskParameter="TargetOutputs" PropertyName="BinplaceInputsFolder"/>
11+
</MSBuild>
12+
13+
<ItemGroup>
14+
<BinplaceInputs Include="$(BinplaceInputsFolder)\**"/>
15+
<Binplace Include="@(BinplaceInputs)">
16+
<OutputPath>$(BinplaceOutputPath)\%(RecursiveDir)\%(Filename)%(Extension)</OutputPath>
17+
</Binplace>
18+
</ItemGroup>
19+
</Target>
20+
</Project>

tools/Binplace/File.proj

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="Common.targets"/>
4+
5+
<Target Name="CoreGetBinplace">
6+
<MSBuild Projects="$(ProjectFile)"
7+
Targets="GetTargetPath"
8+
Properties="$(SetConfiguration); $(SetPlatform)"
9+
BuildInParallel="$(BuildInParallel)">
10+
<Output TaskParameter="TargetOutputs" ItemName="BinplaceInputs"/>
11+
</MSBuild>
12+
13+
<ItemGroup>
14+
<Binplace Include="@(BinplaceInputs)">
15+
<OutputPath>$(BinplaceOutputPath)\%(Filename)%(Extension)</OutputPath>
16+
</Binplace>
17+
</ItemGroup>
18+
</Target>
19+
</Project>

0 commit comments

Comments
 (0)