|
48 | 48 | <DownloadNuGet OutputFilename="$(NuGetExePath)" Condition="!Exists('$(NuGetExePath)')" /> |
49 | 49 | </Target> |
50 | 50 |
|
51 | | - <UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll"> |
| 51 | + <UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll"> |
52 | 52 | <ParameterGroup> |
53 | 53 | <OutputFilename ParameterType="System.String" Required="true" /> |
54 | 54 | </ParameterGroup> |
|
76 | 76 | var info = new FileInfo(OutputFilename); |
77 | 77 | if(!info.Directory.Exists) |
78 | 78 | info.Directory.Create(); |
79 | | - Log.LogMessage("Determining latest version of NuGet.CommandLine..."); |
80 | 79 | WebClient webClient = new WebClient(); |
81 | | - XmlDocument xml = new XmlDocument(); |
82 | | - xml.LoadXml(webClient.DownloadString("http://nuget.org/v1/FeedService.svc/Packages()?$filter=tolower(Id)%20eq%20'nuget.commandline'&$top=1&$orderby=Version%20desc")); |
83 | | - XmlNamespaceManager xns = new XmlNamespaceManager(xml.NameTable); |
84 | | - xns.AddNamespace("atom", "http://www.w3.org/2005/Atom"); |
85 | | - xns.AddNamespace("d", "http://schemas.microsoft.com/ado/2007/08/dataservices"); |
86 | | - xns.AddNamespace("m", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"); |
87 | | - string version = xml.SelectSingleNode("//atom:entry/m:properties/d:Version", xns).InnerText; |
88 | | - string zipUrl = xml.SelectSingleNode("//atom:entry/atom:content", xns).Attributes["src"].Value; |
89 | | - Log.LogMessage("Downloading NuGet.CommandLine v{0}...", version); |
90 | | - zipTempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); |
91 | | - webClient.DownloadFile(zipUrl, zipTempPath); |
92 | | - Log.LogMessage("Copying to {0}...", OutputFilename); |
93 | | - using (Package package = Package.Open(zipTempPath)) { |
94 | | - PackagePart exePart = package.GetParts().Where(p => p.Uri.ToString().ToLowerInvariant() == "/tools/nuget.exe").Single(); |
95 | | - using (Stream inputStream = exePart.GetStream(FileMode.Open, FileAccess.Read)) |
96 | | - using (Stream outputStream = File.Create(OutputFilename)) { |
97 | | - byte[] buffer = new byte[16384]; |
98 | | - while (true) { |
99 | | - int read = inputStream.Read(buffer, 0, buffer.Length); |
100 | | - if (read == 0) { |
101 | | - break; |
102 | | - } |
103 | | - outputStream.Write(buffer, 0, read); |
104 | | - } |
105 | | - } |
106 | | - } |
| 80 | + Log.LogMessage("Downloading NuGet.CommandLine"); |
| 81 | + webClient.DownloadFile("https://dist.nuget.org/win-x86-commandline/v5.7.0/nuget.exe", OutputFilename); |
107 | 82 | return true; |
108 | 83 | } |
109 | 84 | catch (Exception ex) { |
110 | 85 | Log.LogErrorFromException(ex); |
111 | 86 | return false; |
112 | 87 | } |
113 | | - finally { |
114 | | - if (zipTempPath != null) File.Delete(zipTempPath); |
115 | | - } |
116 | 88 | ]]> |
117 | 89 | </Code> |
118 | 90 | </Task> |
|
0 commit comments