change to properties, artifact names
This commit is contained in:
parent
0d37da4d0d
commit
fa97921a4d
23 changed files with 698 additions and 87 deletions
95
build_projects/dotnet-cli-build/ArchiveDirectory.cs
Normal file
95
build_projects/dotnet-cli-build/ArchiveDirectory.cs
Normal file
|
@ -0,0 +1,95 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Build.Utilities;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.DotNet.InternalAbstractions;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class ArchiveDirectory : Task
|
||||
{
|
||||
[Required]
|
||||
public string FileName { get; set; }
|
||||
|
||||
[Required]
|
||||
public string OutputDirectory { get; set; }
|
||||
|
||||
[Required]
|
||||
public string InputDirectory { get; set; }
|
||||
|
||||
[Output]
|
||||
public string OutputArchive { get; set; }
|
||||
|
||||
public override bool Execute()
|
||||
{
|
||||
if (!Directory.Exists(InputDirectory))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.Windows))
|
||||
{
|
||||
OutputArchive = GenerateZip();
|
||||
}
|
||||
else
|
||||
{
|
||||
OutputArchive = GenerateTarGz();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public string GenerateZip()
|
||||
{
|
||||
var extension = ".zip";
|
||||
var outFile = Path.Combine(OutputDirectory, FileName + extension);
|
||||
|
||||
CreateZipFromDirectory(InputDirectory, outFile);
|
||||
|
||||
return outFile;
|
||||
}
|
||||
|
||||
public string GenerateTarGz()
|
||||
{
|
||||
var extension = ".tar.gz";
|
||||
var outFile = Path.Combine(OutputDirectory, FileName + extension);
|
||||
|
||||
CreateTarGzFromDirectory(InputDirectory, outFile);
|
||||
|
||||
return outFile;
|
||||
}
|
||||
|
||||
private static void CreateZipFromDirectory(string directory, string outputArchivePath)
|
||||
{
|
||||
FS.Mkdirp(Path.GetDirectoryName(outputArchivePath));
|
||||
|
||||
if (File.Exists(outputArchivePath))
|
||||
{
|
||||
File.Delete(outputArchivePath);
|
||||
}
|
||||
|
||||
ZipFile.CreateFromDirectory(directory, outputArchivePath, CompressionLevel.Optimal, false);
|
||||
}
|
||||
|
||||
private static void CreateTarGzFromDirectory(string directory, string outputArchivePath)
|
||||
{
|
||||
FS.Mkdirp(Path.GetDirectoryName(outputArchivePath));
|
||||
|
||||
if (File.Exists(outputArchivePath))
|
||||
{
|
||||
File.Delete(outputArchivePath);
|
||||
}
|
||||
|
||||
Cmd("tar", "-czf", outputArchivePath, "-C", directory, ".")
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,15 +7,25 @@ using Microsoft.DotNet.Cli.Build.Framework;
|
|||
using Microsoft.DotNet.InternalAbstractions;
|
||||
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class DebTargets
|
||||
public class DebTargets : Task
|
||||
{
|
||||
public override bool Execute()
|
||||
{
|
||||
BuildContext context = new BuildSetup("MSBuild").UseAllTargetsFromAssembly<DebTargets>().CreateBuildContext();
|
||||
BuildTargetContext c = new BuildTargetContext(context, null, null);
|
||||
|
||||
return GenerateDebs(c).Success;
|
||||
}
|
||||
|
||||
public static BuildTargetResult GenerateDebs(BuildTargetContext c)
|
||||
{
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.Ubuntu))
|
||||
{
|
||||
PrepareTargets.Init(c);
|
||||
GenerateSdkDeb(c);
|
||||
}
|
||||
|
||||
|
|
34
build_projects/dotnet-cli-build/DecompressZip.cs
Normal file
34
build_projects/dotnet-cli-build/DecompressZip.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Net.Http;
|
||||
using Microsoft.Build.Utilities;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.DotNet.InternalAbstractions;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class DecompressZip : Task
|
||||
{
|
||||
[Required]
|
||||
public string InputZip { get; set; }
|
||||
|
||||
[Required]
|
||||
public string DestinationDirectory { get; set; }
|
||||
|
||||
public override bool Execute()
|
||||
{
|
||||
FS.Mkdirp(DestinationDirectory);
|
||||
|
||||
ZipFile.ExtractToDirectory(InputZip, DestinationDirectory);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
49
build_projects/dotnet-cli-build/DownloadFile.cs
Normal file
49
build_projects/dotnet-cli-build/DownloadFile.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Net.Http;
|
||||
using Microsoft.Build.Utilities;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.DotNet.InternalAbstractions;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class DownloadFile : Task
|
||||
{
|
||||
[Required]
|
||||
public string Uri { get; set; }
|
||||
|
||||
[Required]
|
||||
public string DestinationPath { get; set; }
|
||||
|
||||
public bool Overwrite { get; set; }
|
||||
|
||||
public override bool Execute()
|
||||
{
|
||||
FS.Mkdirp(Path.GetDirectoryName(DestinationPath));
|
||||
|
||||
if (File.Exists(DestinationPath) && !Overwrite)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
using (var httpClient = new HttpClient())
|
||||
{
|
||||
var getTask = httpClient.GetStreamAsync(Uri);
|
||||
|
||||
using (var outStream = File.Create(DestinationPath))
|
||||
{
|
||||
getTask.Result.CopyTo(outStream);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
82
build_projects/dotnet-cli-build/GenerateGuidFromName.cs
Normal file
82
build_projects/dotnet-cli-build/GenerateGuidFromName.cs
Normal file
|
@ -0,0 +1,82 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Net.Http;
|
||||
using Microsoft.Build.Utilities;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.DotNet.InternalAbstractions;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class GenerateGuidFromName : Task
|
||||
{
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Output]
|
||||
public string OutputGuid { get; set; }
|
||||
|
||||
public override bool Execute()
|
||||
{
|
||||
OutputGuid = GenerateGuid(Name).ToString();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Guid GenerateGuid(string name)
|
||||
{
|
||||
// Any fixed GUID will do for a namespace.
|
||||
Guid namespaceId = new Guid("28F1468D-672B-489A-8E0C-7C5B3030630C");
|
||||
|
||||
using (SHA1 hasher = SHA1.Create())
|
||||
{
|
||||
var nameBytes = System.Text.Encoding.UTF8.GetBytes(name ?? string.Empty);
|
||||
var namespaceBytes = namespaceId.ToByteArray();
|
||||
|
||||
SwapGuidByteOrder(namespaceBytes);
|
||||
|
||||
var streamToHash = new byte[namespaceBytes.Length + nameBytes.Length];
|
||||
|
||||
Array.Copy(namespaceBytes, streamToHash, namespaceBytes.Length);
|
||||
Array.Copy(nameBytes, 0, streamToHash, namespaceBytes.Length, nameBytes.Length);
|
||||
|
||||
var hashResult = hasher.ComputeHash(streamToHash);
|
||||
|
||||
var res = new byte[16];
|
||||
|
||||
Array.Copy(hashResult, res, res.Length);
|
||||
|
||||
unchecked { res[6] = (byte)(0x50 | (res[6] & 0x0F)); }
|
||||
unchecked { res[8] = (byte)(0x40 | (res[8] & 0x3F)); }
|
||||
|
||||
SwapGuidByteOrder(res);
|
||||
|
||||
return new Guid(res);
|
||||
}
|
||||
}
|
||||
|
||||
// Do a byte order swap, .NET GUIDs store multi byte components in little
|
||||
// endian.
|
||||
private static void SwapGuidByteOrder(byte[] b)
|
||||
{
|
||||
Swap(b, 0, 3);
|
||||
Swap(b, 1, 2);
|
||||
Swap(b, 5, 6);
|
||||
Swap(b, 7, 8);
|
||||
}
|
||||
|
||||
private static void Swap(byte[] b, int x, int y)
|
||||
{
|
||||
byte t = b[x];
|
||||
b[x] = b[y];
|
||||
b[y] = t;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -114,7 +114,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
if (CurrentPlatform.IsPlatform(BuildPlatform.Windows))
|
||||
{
|
||||
var cliSdkRoot = c.BuildContext.Get<string>("CLISDKRoot");
|
||||
var upgradeCode = Utils.GenerateGuidFromName(SdkMsi).ToString().ToUpper();
|
||||
var upgradeCode = GenerateGuidFromName.GenerateGuid(SdkMsi).ToString().ToUpper();
|
||||
var cliSdkBrandName = $"'{Monikers.CLISdkBrandName}'";
|
||||
|
||||
Cmd("powershell", "-NoProfile", "-NoLogo",
|
||||
|
@ -131,7 +131,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
{
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.Windows))
|
||||
{
|
||||
var upgradeCode = Utils.GenerateGuidFromName(SdkBundle).ToString().ToUpper();
|
||||
var upgradeCode = GenerateGuidFromName.GenerateGuid(SdkBundle).ToString().ToUpper();
|
||||
var cliSdkBrandName = $"'{Monikers.CLISdkBrandName}'";
|
||||
|
||||
Cmd("powershell", "-NoProfile", "-NoLogo",
|
||||
|
|
|
@ -7,10 +7,11 @@ using Microsoft.DotNet.Cli.Build.Framework;
|
|||
using Microsoft.DotNet.InternalAbstractions;
|
||||
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class PkgTargets
|
||||
public class PkgTargets : Task
|
||||
{
|
||||
public static string PkgsIntermediateDir { get; set; }
|
||||
public static string SharedHostComponentId { get; set; }
|
||||
|
@ -45,10 +46,19 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
public override bool Execute()
|
||||
{
|
||||
BuildContext context = new BuildSetup("MSBuild").UseAllTargetsFromAssembly<DebTargets>().CreateBuildContext();
|
||||
BuildTargetContext c = new BuildTargetContext(context, null, null);
|
||||
|
||||
return GeneratePkgs(c).Success;
|
||||
}
|
||||
|
||||
public static BuildTargetResult GeneratePkgs(BuildTargetContext c)
|
||||
{
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.OSX))
|
||||
{
|
||||
PrepareTargets.Init(c);
|
||||
InitPkg(c);
|
||||
GenerateCLISdkProductArchive(c);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
// "dotnet-compile-fsc.Tests",
|
||||
"dotnet-new.Tests",
|
||||
"dotnet-pack.Tests",
|
||||
"dotnet-projectmodel-server.Tests",
|
||||
//"dotnet-projectmodel-server.Tests",
|
||||
"dotnet-publish.Tests",
|
||||
"dotnet-resgen.Tests",
|
||||
"dotnet-run.Tests",
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
"System.Xml.XmlSerializer": "4.0.11",
|
||||
"WindowsAzure.Storage": "6.2.2-preview",
|
||||
"NuGet.CommandLine.XPlat": "3.5.0-beta2-1484",
|
||||
"Microsoft.Build.Framework": "0.1.0-preview-00024-160610",
|
||||
"Microsoft.Build.Utilities.Core": "0.1.0-preview-00024-160610"
|
||||
"Microsoft.Build.Framework": "0.1.0-preview-00028-160627",
|
||||
"Microsoft.Build.Utilities.Core": "0.1.0-preview-00028-160627"
|
||||
},
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue