This repository has been archived by the owner on Mar 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build.tasks
71 lines (64 loc) · 2.48 KB
/
Build.tasks
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
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--Inline Task: FindNuGet-->
<UsingTask TaskName="FindNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<Result ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try {
// Look for NuGet on the path
String pathVariable = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.Machine);
Log.LogMessage("Looking for NuGet.exe in the local environment...");
if (pathVariable != null) {
foreach (String path in pathVariable.Split(';')) {
if (File.Exists(Path.Combine(path, "nuget.exe"))) {
Result = path.EndsWith("\\") ? path : path + "\\";
Log.LogMessage("Found NuGet.exe in {0}", path);
return true;
}
}
}
Log.LogMessage("No success.");
return false;
} catch (Exception e) {
Log.LogErrorFromException(e);
return false;
}
]]>
</Code>
</Task>
</UsingTask>
<!--Inline Task: DownloadNuGet-->
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<OutputFile 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 {
OutputFile = Path.GetFullPath(OutputFile);
Log.LogMessage("Downloading NuGet.exe from NuGet.org...");
WebClient webClient = new WebClient();
webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFile);
Log.LogMessage("Download complete.");
return true;
} catch (Exception e) {
Log.LogErrorFromException(e);
return false;
}
]]>
</Code>
</Task>
</UsingTask>
</Project>