summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.BuildTasks
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.BuildTasks')
-rw-r--r--src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj1
-rw-r--r--src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.sln1
-rw-r--r--src/DotNetOpenAuth.BuildTasks/GetBuildVersion.cs17
-rw-r--r--src/DotNetOpenAuth.BuildTasks/PrepareOhlohRelease.cs138
4 files changed, 155 insertions, 2 deletions
diff --git a/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj b/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj
index 615f652..7993ed5 100644
--- a/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj
+++ b/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj
@@ -121,6 +121,7 @@
<Compile Include="NativeMethods.cs" />
<Compile Include="ParseMaster.cs" />
<Compile Include="PathSegment.cs" />
+ <Compile Include="PrepareOhlohRelease.cs" />
<Compile Include="Publicize.cs" />
<Compile Include="Purge.cs" />
<Compile Include="ReSignDelaySignedAssemblies.cs" />
diff --git a/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.sln b/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.sln
index f3e3982..dbc8e60 100644
--- a/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.sln
+++ b/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.sln
@@ -13,6 +13,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
..\..\tools\DotNetOpenAuth.targets = ..\..\tools\DotNetOpenAuth.targets
..\..\tools\DotNetOpenAuth.Versioning.targets = ..\..\tools\DotNetOpenAuth.Versioning.targets
..\..\tools\drop.proj = ..\..\tools\drop.proj
+ ..\..\tools\ohloh.proj = ..\..\tools\ohloh.proj
..\..\projecttemplates\projecttemplates.proj = ..\..\projecttemplates\projecttemplates.proj
..\..\samples\Samples.proj = ..\..\samples\Samples.proj
..\..\samples\tools.proj = ..\..\samples\tools.proj
diff --git a/src/DotNetOpenAuth.BuildTasks/GetBuildVersion.cs b/src/DotNetOpenAuth.BuildTasks/GetBuildVersion.cs
index 1d60ca4..dfb3468 100644
--- a/src/DotNetOpenAuth.BuildTasks/GetBuildVersion.cs
+++ b/src/DotNetOpenAuth.BuildTasks/GetBuildVersion.cs
@@ -10,6 +10,11 @@ using Microsoft.Build.Utilities;
namespace DotNetOpenAuth.BuildTasks {
public class GetBuildVersion : Task {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="GetBuildVersion"/> class.
+ /// </summary>
+ public GetBuildVersion() {
+ }
/// <summary>
/// Gets the version string to use in the compiled assemblies.
@@ -18,6 +23,12 @@ namespace DotNetOpenAuth.BuildTasks {
public string Version { get; private set; }
/// <summary>
+ /// Gets the version string to use in the official release name (lacks revision number).
+ /// </summary>
+ [Output]
+ public string SimpleVersion { get; private set; }
+
+ /// <summary>
/// Gets the Git revision control commit id for HEAD (the current source code version).
/// </summary>
[Output]
@@ -37,9 +48,11 @@ namespace DotNetOpenAuth.BuildTasks {
public override bool Execute() {
try {
Version typedVersion = ReadVersionFromFile();
- typedVersion = new Version(typedVersion.Major, typedVersion.Minor, typedVersion.Build, CalculateJDate(DateTime.Now));
- Version = typedVersion.ToString();
+ SimpleVersion = typedVersion.ToString();
+ var fullVersion = new Version(typedVersion.Major, typedVersion.Minor, typedVersion.Build, CalculateJDate(DateTime.Now));
+ Version = fullVersion.ToString();
+
this.GitCommitId = GetGitHeadCommitId();
} catch (ArgumentOutOfRangeException ex) {
Log.LogErrorFromException(ex);
diff --git a/src/DotNetOpenAuth.BuildTasks/PrepareOhlohRelease.cs b/src/DotNetOpenAuth.BuildTasks/PrepareOhlohRelease.cs
new file mode 100644
index 0000000..fe13824
--- /dev/null
+++ b/src/DotNetOpenAuth.BuildTasks/PrepareOhlohRelease.cs
@@ -0,0 +1,138 @@
+//-----------------------------------------------------------------------
+// <copyright file="PrepareOhlohRelease.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.BuildTasks {
+ using System;
+ using System.Collections.Generic;
+ using System.Globalization;
+ using System.IO;
+ using System.Linq;
+ using System.Text;
+ using System.Text.RegularExpressions;
+ using System.Xml;
+ using System.Xml.Linq;
+ using Microsoft.Build.Framework;
+ using Microsoft.Build.Utilities;
+
+ /// <summary>
+ /// Creates an Ohloh.net upload instruct XLM file and bash script that uses it.
+ /// </summary>
+ public class PrepareOhlohRelease : Task {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="PrepareOhlohUpload"/> class.
+ /// </summary>
+ public PrepareOhlohRelease() {
+ }
+
+ [Required]
+ public string Release { get; set; }
+
+ public string ReleaseNotes { get; set; }
+
+ [Required]
+ public string InstructFile { get; set; }
+
+ [Required]
+ public string UploadScript { get; set; }
+
+ [Required]
+ public string OhlohUser { get; set; }
+
+ [Required]
+ public string OhlohProject { get; set; }
+
+ [Required]
+ public ITaskItem[] RedistributableFiles { get; set; }
+
+ public override bool Execute() {
+ this.WriteInstructFile();
+ this.WriteUploadScript();
+
+ return !this.Log.HasLoggedErrors;
+ }
+
+ private void WriteInstructFile() {
+ var packages = from redist in this.RedistributableFiles
+ let file = new { Path = redist.ItemSpec, Package = redist.GetMetadata("Package"), Platform = redist.GetMetadata("Platform"), Icon = redist.GetMetadata("Icon") }
+ group file by file.Package into package
+ select new XElement(
+ "package",
+ new XAttribute("name", package.Key),
+ new XElement(
+ "releases",
+ new XElement(
+ "release",
+ new XAttribute("name", this.Release),
+ new XAttribute("date", XmlConvert.ToString(DateTime.Now)),
+ new XElement("notes", this.ReleaseNotes),
+ new XElement(
+ "files",
+ package.Select(
+ f => new XElement(
+ "file",
+ new XAttribute("name", Path.GetFileName(f.Path)),
+ new XAttribute("date", XmlConvert.ToString(DateTime.Now)),
+ new XAttribute("platform", f.Platform),
+ new XAttribute("icon", f.Icon)
+ )
+ )
+ )
+ )
+ )
+ );
+
+ var instructXml = new XElement("packages", packages);
+
+ var writerSettings = new XmlWriterSettings {
+ OmitXmlDeclaration = true,
+ Indent = true,
+ IndentChars = "\t",
+ };
+ using (var writer = XmlWriter.Create(this.InstructFile, writerSettings)) {
+ instructXml.Save(writer);
+ }
+
+ this.Log.LogMessage("Ohloh instruct file written to: \"{0}\"", this.InstructFile);
+
+ }
+
+ private void WriteUploadScript() {
+ int longestPath = Math.Max(
+ GetLinuxPath(Path.GetFullPath(this.InstructFile)).Length,
+ this.RedistributableFiles.Max(f => GetLinuxPath(f.GetMetadata("FullPath")).Length));
+
+ using (StreamWriter writer = new StreamWriter(this.UploadScript)) {
+ writer.WriteLine("#!/bin/bash");
+ writer.WriteLine();
+ foreach (var file in this.RedistributableFiles) {
+ writer.WriteLine("scp {0,-" + longestPath + "} {1}@upload.ohloh.net:{2}/files", GetLinuxPath(file.GetMetadata("FullPath")), this.OhlohUser, this.OhlohProject);
+ }
+
+ writer.WriteLine();
+ writer.WriteLine("scp {0,-" + longestPath + "} {1}@upload.ohloh.net:{2}/instructs", GetLinuxPath(Path.GetFullPath(this.InstructFile)), this.OhlohUser, this.OhlohProject);
+ writer.WriteLine();
+ writer.WriteLine("# Download the instruct log by executing this command:");
+ writer.WriteLine("# scp {0}@upload.ohloh.net:{1}/logs/upload.log .", this.OhlohUser, this.OhlohProject);
+ }
+
+ this.Log.LogMessage("Ohloh upload script written to: \"{0}\".", this.UploadScript);
+ }
+
+ private static string GetLinuxPath(string windowsPath) {
+ if (String.IsNullOrEmpty(windowsPath)) {
+ throw new ArgumentNullException("windowsPath");
+ }
+
+ string linuxPath = Regex.Replace(
+ windowsPath,
+ @"^([A-Za-z])\:",
+ m => "/" + m.Groups[1].Value)
+ .Replace('\\', '/')
+ .Replace(" ", "\\ ");
+ return linuxPath;
+ }
+ }
+}