1
0
Форкнуть 0
azure-mobile-services-quick.../tools/Microsoft.WindowsAzure.Mobi...

83 строки
3.3 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="GetNugetVersion" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<PackageDirectory ParameterType="System.String" Required="true" />
<NugetId ParameterType="System.String" Required="true" />
<NugetVersion ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Net" />
<Using Namespace="System.Text.RegularExpressions" />
<Using Namespace="Microsoft.Build.Framework" />
<Using Namespace="Microsoft.Build.Utilities" />
<Code Type="Fragment" Language="cs">
<![CDATA[
var directoryInfo = new DirectoryInfo(PackageDirectory);
DirectoryInfo nugetPackageInfo = (DirectoryInfo)directoryInfo.GetDirectories(NugetId).GetValue(0);
var regex = new Regex(NugetId);
var split = regex.Split(nugetPackageInfo.Name);
NugetVersion = split[1].Substring(1);
]]>
</Code>
</Task>
</UsingTask>
<UsingTask TaskName="HttpDownload" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<PackageDirectory ParameterType="System.String" Required="true" />
<DownloadUrl ParameterType="System.String" Required="true" />
<SDKPackage ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Net.Http" />
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.IO.Compression" />
<Using Namespace="System.Threading.Tasks"/>
<Using Namespace="System.Net.Http" />
<Using Namespace="Microsoft.Build.Framework" />
<Using Namespace="Microsoft.Build.Utilities" />
<Code Type="Fragment" Language="cs">
<![CDATA[
string tempZipLocation = Path.Combine(PackageDirectory, "temp.zip");
string sdkFolder = Path.Combine(PackageDirectory, SDKPackage);
if (File.Exists(tempZipLocation))
{
File.Delete(tempZipLocation);
}
if (Directory.Exists(sdkFolder))
{
Directory.Delete(sdkFolder, true);
}
var client = new HttpClient();
Task<HttpResponseMessage> response = client.GetAsync(DownloadUrl);
response.Wait();
HttpResponseMessage message = response.Result;
var fileStream = new FileStream(tempZipLocation, FileMode.CreateNew);
message.Content.CopyToAsync(fileStream).Wait();
fileStream.Flush();
fileStream.Close();
using (ZipArchive archive = ZipFile.OpenRead(tempZipLocation))
{
archive.ExtractToDirectory(sdkFolder);
}
File.Delete(tempZipLocation);
]]>
</Code>
</Task>
</UsingTask>
</Project>