summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2010-12-23 07:36:30 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2010-12-23 07:36:30 -0800
commitdeeca6c5466d22875bf29cfe7c61973cb12f0ddc (patch)
tree93266f22b14041d6c554f878d19da85e1a578bb3 /src
parentc327a9f50924bbc9d88bb6127a9316950345b338 (diff)
downloadDotNetOpenAuth-deeca6c5466d22875bf29cfe7c61973cb12f0ddc.zip
DotNetOpenAuth-deeca6c5466d22875bf29cfe7c61973cb12f0ddc.tar.gz
DotNetOpenAuth-deeca6c5466d22875bf29cfe7c61973cb12f0ddc.tar.bz2
NuGet packages now built nightly. Woot!
Diffstat (limited to 'src')
-rw-r--r--src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj1
-rw-r--r--src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.sln17
-rw-r--r--src/DotNetOpenAuth.BuildTasks/NuGetPack.cs108
3 files changed, 126 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj b/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj
index 3b37787..310ee9d 100644
--- a/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj
+++ b/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj
@@ -118,6 +118,7 @@
<Compile Include="CheckAdminRights.cs" />
<Compile Include="JsPack.cs" />
<Compile Include="NativeMethods.cs" />
+ <Compile Include="NuGetPack.cs" />
<Compile Include="ParseMaster.cs" />
<Compile Include="PathSegment.cs" />
<Compile Include="PrepareOhlohRelease.cs" />
diff --git a/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.sln b/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.sln
index a144f1c..5c2ffbb 100644
--- a/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.sln
+++ b/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.sln
@@ -9,12 +9,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
..\..\tools\DotNetOpenAuth.automated.targets = ..\..\tools\DotNetOpenAuth.automated.targets
..\..\lib\DotNetOpenAuth.BuildTasks.targets = ..\..\lib\DotNetOpenAuth.BuildTasks.targets
..\..\tools\DotNetOpenAuth.Common.Settings.targets = ..\..\tools\DotNetOpenAuth.Common.Settings.targets
+ ..\..\nuget\DotNetOpenAuth.nuspec = ..\..\nuget\DotNetOpenAuth.nuspec
..\..\tools\DotNetOpenAuth.props = ..\..\tools\DotNetOpenAuth.props
..\..\tools\DotNetOpenAuth.targets = ..\..\tools\DotNetOpenAuth.targets
..\..\tools\DotNetOpenAuth.Versioning.targets = ..\..\tools\DotNetOpenAuth.Versioning.targets
..\..\tools\drop.proj = ..\..\tools\drop.proj
..\..\EnlistmentInfo.props = ..\..\EnlistmentInfo.props
..\..\EnlistmentInfo.targets = ..\..\EnlistmentInfo.targets
+ ..\..\nuget\nuget.proj = ..\..\nuget\nuget.proj
..\..\tools\ohloh.proj = ..\..\tools\ohloh.proj
..\..\projecttemplates\projecttemplates.proj = ..\..\projecttemplates\projecttemplates.proj
..\..\samples\Samples.proj = ..\..\samples\Samples.proj
@@ -25,6 +27,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetOpenAuth.BuildTasks", "DotNetOpenAuth.BuildTasks.csproj", "{AC231A51-EF60-437C-A33F-AF8ADEB8EB74}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", "NuGet", "{D49E2011-0E1C-4AB5-9887-BD1D42266503}"
+ ProjectSection(SolutionItems) = preProject
+ ..\..\nuget\DotNetOpenAuth.nuspec = ..\..\nuget\DotNetOpenAuth.nuspec
+ ..\..\nuget\nuget.proj = ..\..\nuget\nuget.proj
+ EndProjectSection
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "content", "content", "{BF3868D6-3BBA-4E40-B180-213370C15494}"
+ ProjectSection(SolutionItems) = preProject
+ ..\..\nuget\content\web.config.transform = ..\..\nuget\content\web.config.transform
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -39,4 +52,8 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {D49E2011-0E1C-4AB5-9887-BD1D42266503} = {ABBE14A3-0404-4123-9093-E598C3DD3E9B}
+ {BF3868D6-3BBA-4E40-B180-213370C15494} = {D49E2011-0E1C-4AB5-9887-BD1D42266503}
+ EndGlobalSection
EndGlobal
diff --git a/src/DotNetOpenAuth.BuildTasks/NuGetPack.cs b/src/DotNetOpenAuth.BuildTasks/NuGetPack.cs
new file mode 100644
index 0000000..356c51f
--- /dev/null
+++ b/src/DotNetOpenAuth.BuildTasks/NuGetPack.cs
@@ -0,0 +1,108 @@
+//-----------------------------------------------------------------------
+// <copyright file="NuGetPack.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.BuildTasks {
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
+ using System.Linq;
+ using System.Text;
+ using System.Xml.Linq;
+ using Microsoft.Build.Framework;
+ using Microsoft.Build.Utilities;
+
+ /// <summary>
+ /// Creates a .nupkg archive from a .nuspec file and content files.
+ /// </summary>
+ public class NuGetPack : ToolTask {
+ /// <summary>
+ /// Gets or sets the path to the .nuspec file.
+ /// </summary>
+ [Required]
+ public ITaskItem NuSpec { get; set; }
+
+ /// <summary>
+ /// Gets or sets the base directory, the contents of which gets included in the .nupkg archive.
+ /// </summary>
+ public ITaskItem BaseDirectory { get; set; }
+
+ /// <summary>
+ /// Gets or sets the path to the directory that will contain the generated .nupkg archive.
+ /// </summary>
+ public ITaskItem OutputPackageDirectory { get; set; }
+
+ /// <summary>
+ /// Returns the fully qualified path to the executable file.
+ /// </summary>
+ /// <returns>
+ /// The fully qualified path to the executable file.
+ /// </returns>
+ protected override string GenerateFullPathToTool() {
+ return this.ToolPath;
+ }
+
+ /// <summary>
+ /// Gets the name of the executable file to run.
+ /// </summary>
+ /// <returns>The name of the executable file to run.</returns>
+ protected override string ToolName {
+ get { return "NuGet.exe"; }
+ }
+
+ /// <summary>
+ /// Runs the exectuable file with the specified task parameters.
+ /// </summary>
+ /// <returns>
+ /// true if the task runs successfully; otherwise, false.
+ /// </returns>
+ public override bool Execute() {
+ if (this.OutputPackageDirectory != null && Path.GetDirectoryName(this.OutputPackageDirectory.ItemSpec).Length > 0) {
+ Directory.CreateDirectory(Path.GetDirectoryName(this.OutputPackageDirectory.ItemSpec));
+ }
+
+ string fullPackagePath = this.DeriveFullPackagePath();
+ this.Log.LogMessage("Creating NuGet package '{0}'.", fullPackagePath);
+
+ bool result = base.Execute();
+
+ if (result) {
+ this.Log.LogMessage(MessageImportance.High, "Successfully created package '{0}'.", fullPackagePath);
+ }
+
+ return result;
+ }
+
+ /// <summary>
+ /// Returns a string value containing the command line arguments to pass directly to the executable file.
+ /// </summary>
+ /// <returns>
+ /// A string value containing the command line arguments to pass directly to the executable file.
+ /// </returns>
+ protected override string GenerateCommandLineCommands() {
+ var args = new CommandLineBuilder();
+
+ args.AppendSwitch("pack");
+ args.AppendFileNameIfNotNull(this.NuSpec);
+ args.AppendSwitchIfNotNull("-b ", this.BaseDirectory);
+ args.AppendSwitchIfNotNull("-o ", this.OutputPackageDirectory);
+
+ return args.ToString();
+ }
+
+ /// <summary>
+ /// Derives the path to the generated .nupkg file.
+ /// </summary>
+ /// <returns>A relative path.</returns>
+ private string DeriveFullPackagePath() {
+ var spec = XDocument.Load(this.NuSpec.ItemSpec);
+ var metadata = spec.Element("package").Element("metadata");
+ string id = metadata.Element("id").Value;
+ string version = metadata.Element("version").Value;
+ string baseDirectory = this.OutputPackageDirectory != null ? this.OutputPackageDirectory.ItemSpec : String.Empty;
+ return Path.Combine(baseDirectory, String.Format("{0}.{1}.nupkg", id, version));
+ }
+ }
+}