LEFT | RIGHT |
1 /* | 1 /* |
2 Copyright 2013 Google Inc | 2 Copyright 2013 Google Inc |
3 | 3 |
4 Licensed under the Apache License, Version 2.0 (the "License"); | 4 Licensed under the Apache License, Version 2.0 (the "License"); |
5 you may not use this file except in compliance with the License. | 5 you may not use this file except in compliance with the License. |
6 You may obtain a copy of the License at | 6 You may obtain a copy of the License at |
7 | 7 |
8 http://www.apache.org/licenses/LICENSE-2.0 | 8 http://www.apache.org/licenses/LICENSE-2.0 |
9 | 9 |
10 Unless required by applicable law or agreed to in writing, software | 10 Unless required by applicable law or agreed to in writing, software |
(...skipping 14 matching lines...) Expand all Loading... |
25 using Microsoft.Build.Evaluation; | 25 using Microsoft.Build.Evaluation; |
26 using Microsoft.Build.Framework; | 26 using Microsoft.Build.Framework; |
27 using Microsoft.Build.Logging; | 27 using Microsoft.Build.Logging; |
28 using NuGet; | 28 using NuGet; |
29 | 29 |
30 using Google.Apis.NuGet.Publisher.Discovery; | 30 using Google.Apis.NuGet.Publisher.Discovery; |
31 using Google.Apis.Utils; | 31 using Google.Apis.Utils; |
32 | 32 |
33 namespace Google.Apis.NuGet.Publisher | 33 namespace Google.Apis.NuGet.Publisher |
34 { | 34 { |
35 /// <summary>A NuGet publisher which publishes individual Google API package
to NuGet main repository.</summary> | 35 /// <summary>This publisher publishes Google API packages to NuGet main repo
sitory.</summary> |
36 public class NuGetApiPublisher | 36 public class NuGetApiPublisher |
37 { | 37 { |
38 private TraceSource TraceSource = new TraceSource("Google.Apis"); | 38 private static TraceSource TraceSource = new TraceSource("Google.Apis"); |
39 | 39 |
40 private readonly DiscoveryItem item; | 40 private readonly DiscoveryItem item; |
41 | 41 |
42 /// <summary>Gets or sets the working directory which the source will be
downloaded to.</summary> | 42 /// <summary>Gets or sets the working directory which the source will be
downloaded to.</summary> |
43 public string BundleDirectory { get; set; } | 43 public string BundleDirectory { get; set; } |
44 | 44 |
45 /// <summary>Gets or sets the bundle URI. The API's bundle is going to b
e downloaded from this URI.</summary> | 45 /// <summary>Gets or sets the bundle URI. The API's bundle is going to b
e downloaded from this URI.</summary> |
46 public Uri BundleUri { get; set; } | 46 public Uri BundleUri { get; set; } |
47 | 47 |
48 /// <summary>Gets or sets the NuGet API key.</summary> | 48 /// <summary>Gets or sets the NuGet API key.</summary> |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 Directory.Delete(buildDirectory, true); | 117 Directory.Delete(buildDirectory, true); |
118 } | 118 } |
119 } | 119 } |
120 | 120 |
121 #region Download Sources | 121 #region Download Sources |
122 | 122 |
123 /// <summary>Downloads the API's bundle.</summary> | 123 /// <summary>Downloads the API's bundle.</summary> |
124 /// <returns>The path to the bundle file</returns> | 124 /// <returns>The path to the bundle file</returns> |
125 private async Task<string> DownloadBundle() | 125 private async Task<string> DownloadBundle() |
126 { | 126 { |
127 var outputFile = string.Format(@"{0}{1}.zip", BundleDirectory, item)
; | 127 var outputFile = string.Format(Path.Combine(BundleDirectory, item +
".zip")); |
128 | 128 |
129 // Downloading the bundle | 129 // Downloading the bundle |
130 using (var client = new WebClient()) | 130 using (var client = new WebClient()) |
131 { | 131 { |
132 TraceSource.TraceEvent(TraceEventType.Verbose, "{0}\t Downloadin
g \"{1}\"", item, BundleUri); | 132 TraceSource.TraceEvent(TraceEventType.Verbose, "{0}\t Downloadin
g \"{1}\"", item, BundleUri); |
133 await client.DownloadFileTaskAsync(BundleUri, outputFile); | 133 await client.DownloadFileTaskAsync(BundleUri, outputFile); |
134 TraceSource.TraceEvent(TraceEventType.Information, "{0}\t \"{1}\
" was downloaded successfully", item, | 134 TraceSource.TraceEvent(TraceEventType.Information, "{0}\t \"{1}\
" was downloaded successfully", item, |
135 BundleUri); | 135 BundleUri); |
136 | 136 |
137 return outputFile; | 137 return outputFile; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 private string CreateLocalNupkgFile(string buildDirectoryPath) | 232 private string CreateLocalNupkgFile(string buildDirectoryPath) |
233 { | 233 { |
234 TraceSource.TraceEvent(TraceEventType.Verbose, "{0}\t Start creating
.nupkg file", item); | 234 TraceSource.TraceEvent(TraceEventType.Verbose, "{0}\t Start creating
.nupkg file", item); |
235 var nuspec = Directory.GetFiles(buildDirectoryPath, "*.nuspec").Sing
le(); | 235 var nuspec = Directory.GetFiles(buildDirectoryPath, "*.nuspec").Sing
le(); |
236 return NuGetUtilities.CreateLocalNupkgFile(nuspec, buildDirectoryPat
h); | 236 return NuGetUtilities.CreateLocalNupkgFile(nuspec, buildDirectoryPat
h); |
237 } | 237 } |
238 | 238 |
239 #endregion | 239 #endregion |
240 } | 240 } |
241 } | 241 } |
LEFT | RIGHT |