forked from ThomasLebrun/XForms-Toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.proj
101 lines (87 loc) · 5.57 KB
/
build.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
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">true</DownloadNuGetExe>
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">NuGet.exe</NuGetExePath>
<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand>
<PackagesDirectory Condition=" '$(PackagesDirectory)' == '' ">$([System.IO.Path]::Combine($(MSBuildProjectDirectory), "src", "XForms.Toolkit", "packages"))</PackagesDirectory>
<PackagesConfigPath Condition=" '$(PackagesConfigPath)' == '' ">$([System.IO.Path]::Combine($(MSBuildProjectDirectory), "src", "XForms.Toolkit", "XForms.Toolkit", "packages.config"))</PackagesConfigPath>
<RestoreCommand>$(NuGetCommand) restore "$(PackagesConfigPath)" -NonInteractive -PackagesDirectory $(PackagesDirectory)" </RestoreCommand>
<SolutionFile>$([System.IO.Path]::Combine($(MSBuildProjectDirectory), "src", "XForms.Toolkit", "XForms.Toolkit.sln"))</SolutionFile>
<Configuration>Release</Configuration>
</PropertyGroup>
<ItemGroup>
<SolutionToBuild Include="$(SolutionFile)">
<Properties>Configuration=$(Configuration)</Properties>
</SolutionToBuild>
<ProjectsToPack Include='$(MSBuildProjectDirectory)\src\**\*.csproj' />
</ItemGroup>
<Target Name="Build">
<CallTarget Targets="RestorePackages" />
<CallTarget Targets="BuildSolution" />
<CallTarget Targets="PackNuGetPackages" />
</Target>
<Target Name="BuildSolution">
<Message Text="Building Solutions" />
<MSBuild Projects="@(SolutionToBuild)"/>
</Target>
<Target Name="PackNuGetPackages">
<Message Text="Packing Nuget Packages" />
<Exec Command="$(NuGetCommand) pack @(ProjectsToPack) -prop Configuration=$(Configuration)"
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfigPath)') and Exists(@(ProjectsToPack->'%(RootDir)%(Directory)%(FileName).nuspec')) and '%(Identity)' != ''" />
<Exec Command="$(NuGetCommand) pack @(ProjectsToPack) -prop Configuration=$(Configuration)"
LogStandardErrorAsError="true"
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfigPath)') and Exists(@(ProjectsToPack->'%(RootDir)%(Directory)%(FileName).nuspec')) and '%(Identity)' != ''" />
</Target>
<!-- ********************************************************************************************************** -->
<!-- The code below this section is re-used from the nuget.targets file in the nuget.codeplex.org project. -->
<!-- This code is released under Apache License 2.0 (http://nuget.codeplex.com/license). -->
<!-- ********************************************************************************************************** -->
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(RestoreCommand)" Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfigPath)')" />
<Exec Command="$(RestoreCommand)" LogStandardErrorAsError="true" Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfigPath)')" />
</Target>
<Target Name="CheckPrerequisites">
<!-- Raise an error if we're unable to locate nuget.exe -->
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
<!--
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
This effectively acts as a lock that makes sure that the download operation will only happen once and all
parallel builds will have to wait for it to complete.
-->
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
</Target>
<Target Name="_DownloadNuGet">
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
</Target>
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<OutputFilename ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Net" />
<Using Namespace="Microsoft.Build.Framework" />
<Using Namespace="Microsoft.Build.Utilities" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try {
OutputFilename = Path.GetFullPath(OutputFilename);
Log.LogMessage("Downloading latest version of NuGet.exe...");
WebClient webClient = new WebClient();
webClient.DownloadFile("https://nuget.org/nuget.exe", OutputFilename);
return true;
}
catch (Exception ex) {
Log.LogErrorFromException(ex);
return false;
}
]]>
</Code>
</Task>
</UsingTask>
</Project>