diff --git a/Source/MSBuild.Community.Tasks/Git/GitCommit.cs b/Source/MSBuild.Community.Tasks/Git/GitCommit.cs new file mode 100644 index 00000000..ec7cc6d3 --- /dev/null +++ b/Source/MSBuild.Community.Tasks/Git/GitCommit.cs @@ -0,0 +1,46 @@ +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +namespace MSBuild.Community.Tasks.Git +{ + /// + /// A task for git commit. + /// + public class GitCommit : GitClient + { + /// + /// Initializes a new instance of the class. + /// + public GitCommit() + { + Command = "commit"; + } + + /// + /// Gets or sets the commit message. + /// + [Required] + public string Message { get; set; } + + /// + /// Whether or not to add modified and deleted files to the commit + /// + public bool AddModifiedFiles { get; set; } + + /// + /// Generates the arguments. + /// + /// The builder. + protected override void GenerateArguments(CommandLineBuilder builder) + { + base.GenerateArguments(builder); + + if (AddModifiedFiles) + { + builder.AppendSwitch("-a"); + } + + builder.AppendSwitchIfNotNull("-m", Message); + } + } +} \ No newline at end of file diff --git a/Source/MSBuild.Community.Tasks/Git/GitTag.cs b/Source/MSBuild.Community.Tasks/Git/GitTag.cs new file mode 100644 index 00000000..cd681784 --- /dev/null +++ b/Source/MSBuild.Community.Tasks/Git/GitTag.cs @@ -0,0 +1,69 @@ +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +namespace MSBuild.Community.Tasks.Git +{ + /// + /// A task for git commit. + /// + public class GitTag : GitClient + { + /// + /// Initializes a new instance of the class. + /// + public GitTag() + { + Command = "tag"; + } + + /// + /// Gets or sets the tag label. + /// + [Required] + public string Label { get; set; } + + /// + /// Commit hash to add the tag to. If empty, tag HEAD. + /// + public string CommitHash { get; set; } + + /// + /// For annotated tags, gets or sets the tag message. + /// + public string Message { get; set; } + + /// + /// Whether or not to add modified files to the commit + /// + public bool Annotated { get; set; } + + /// + /// Generates the arguments. + /// + /// The builder. + protected override void GenerateArguments(CommandLineBuilder builder) + { + base.GenerateArguments(builder); + + if (Annotated) + { + builder.AppendSwitch("-a"); + builder.AppendSwitch(Label); + + if (!string.IsNullOrWhiteSpace(Message)) + { + builder.AppendSwitchIfNotNull("-m", Message); + } + } + else + { + builder.AppendSwitch(Label); + } + + if (!string.IsNullOrWhiteSpace(CommitHash)) + { + builder.AppendTextUnquoted("\"" + CommitHash + "\""); + } + } + } +} \ No newline at end of file diff --git a/Source/MSBuild.Community.Tasks/MSBuild.Community.Tasks.Targets b/Source/MSBuild.Community.Tasks/MSBuild.Community.Tasks.Targets index 8d24076c..b1461d5c 100644 --- a/Source/MSBuild.Community.Tasks/MSBuild.Community.Tasks.Targets +++ b/Source/MSBuild.Community.Tasks/MSBuild.Community.Tasks.Targets @@ -136,8 +136,10 @@ + + @@ -147,6 +149,8 @@ + + diff --git a/Source/MSBuild.Community.Tasks/MSBuild.Community.Tasks.csproj b/Source/MSBuild.Community.Tasks/MSBuild.Community.Tasks.csproj index 80644a2a..76da1b77 100644 --- a/Source/MSBuild.Community.Tasks/MSBuild.Community.Tasks.csproj +++ b/Source/MSBuild.Community.Tasks/MSBuild.Community.Tasks.csproj @@ -117,7 +117,9 @@ + + @@ -135,6 +137,7 @@ + diff --git a/Source/MSBuild.Community.Tasks/NuGet/NuGetAdd.cs b/Source/MSBuild.Community.Tasks/NuGet/NuGetAdd.cs new file mode 100644 index 00000000..b4f6eb42 --- /dev/null +++ b/Source/MSBuild.Community.Tasks/NuGet/NuGetAdd.cs @@ -0,0 +1,107 @@ +#region Copyright © 2011 Paul Welter. All rights reserved. +/* +Copyright © 2005 Paul Welter. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + + + +namespace MSBuild.Community.Tasks.NuGet +{ + /// + /// Adds a package to the server and optionally publishes it. + /// + public class NuGetAdd : NuGetBase + { + /// + /// The path to the package to push the package to the server. + /// + [Required] + public ITaskItem File { get; set; } + + /// + /// The API key to use for push to the server. + /// + public string APIKey { get; set; } + + /// + /// The NuGet configuation file. If not specified, file %AppData%\NuGet\NuGet.config is used as configuration file. + /// + public string ConfigFile { get; set; } + + /// + /// Specifies the server folder or UNC path. + /// + public string Source { get; set; } + + /// + /// Specifies if the package should be created and uploaded to the server but not published to the server. False by default. + /// + /// + /// true if create only; otherwise, false. + /// + public bool CreateOnly { get; set; } + + /// + /// Display this amount of details in the output: normal, quiet, detailed. + /// + public string Verbosity { get; set; } + + /// + /// (v3.5) Forces NuGet to run using an invariant, English-based culture. + /// + /// + /// Only available starting in version 3.5. + /// + public bool ForceEnglishOutput { get; set; } + + /// + /// Returns a string value containing the command line arguments to pass directly to the executable file. + /// + /// + /// A string value containing the command line arguments to pass directly to the executable file. + /// + protected override string GenerateCommandLineCommands() + { + var builder = new CommandLineBuilder(); + builder.AppendSwitch("add"); + builder.AppendFileNameIfNotNull(File); + builder.AppendFileNameIfNotNull(APIKey); + builder.AppendSwitchIfNotNull("-Source ", Source); + builder.AppendSwitchIfNotNull("-Verbosity ", Verbosity); + builder.AppendSwitchIfNotNull("-ConfigFile ", ConfigFile); + if (CreateOnly) + builder.AppendSwitch("-CreateOnly"); + if (ForceEnglishOutput) + builder.AppendSwitch("-ForceEnglishOutput"); + + return builder.ToString(); + } + } +} \ No newline at end of file