diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2009-10-10 14:33:18 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2009-10-10 14:33:18 -0700 |
commit | 8ee4140ede197371e727874fea2579aac42df713 (patch) | |
tree | 387127cccb1232fbbf1c435698d4e0fc5d6709fa /src | |
parent | 525c175898c8b98381b217f8d6ef49594da41dcc (diff) | |
download | DotNetOpenAuth-8ee4140ede197371e727874fea2579aac42df713.zip DotNetOpenAuth-8ee4140ede197371e727874fea2579aac42df713.tar.gz DotNetOpenAuth-8ee4140ede197371e727874fea2579aac42df713.tar.bz2 |
Fine tuned the project template generation.
Diffstat (limited to 'src')
3 files changed, 49 insertions, 7 deletions
diff --git a/src/DotNetOpenAuth.BuildTasks/ChangeProjectReferenceToAssemblyReference.cs b/src/DotNetOpenAuth.BuildTasks/ChangeProjectReferenceToAssemblyReference.cs index 72415d9..973d8d6 100644 --- a/src/DotNetOpenAuth.BuildTasks/ChangeProjectReferenceToAssemblyReference.cs +++ b/src/DotNetOpenAuth.BuildTasks/ChangeProjectReferenceToAssemblyReference.cs @@ -31,6 +31,8 @@ namespace DotNetOpenAuth.BuildTasks { const string msbuildNamespace = "http://schemas.microsoft.com/developer/msbuild/2003"; public override bool Execute() { foreach (var project in Projects) { + Log.LogMessage(MessageImportance.Normal, "Changing P2P references to assembly references in \"{0}\".", project.ItemSpec); + Project doc = new Project(); doc.Load(project.ItemSpec); diff --git a/src/DotNetOpenAuth.BuildTasks/CopyWithTokenSubstitution.cs b/src/DotNetOpenAuth.BuildTasks/CopyWithTokenSubstitution.cs index 0d50254..3b81978 100644 --- a/src/DotNetOpenAuth.BuildTasks/CopyWithTokenSubstitution.cs +++ b/src/DotNetOpenAuth.BuildTasks/CopyWithTokenSubstitution.cs @@ -41,6 +41,16 @@ namespace DotNetOpenAuth.BuildTasks { public ITaskItem[] DestinationFiles { get; set; } /// <summary> + /// Gets or sets the destination files actually copied to. + /// </summary> + /// <remarks> + /// In the case of error partway through, or files not copied due to already being up to date, + /// this can be a subset of the <see cref="DestinationFiles"/> array. + /// </remarks> + [Output] + public ITaskItem[] CopiedFiles { get; set; } + + /// <summary> /// Executes this instance. /// </summary> /// <returns><c>true</c> if the operation was successful.</returns> @@ -50,6 +60,8 @@ namespace DotNetOpenAuth.BuildTasks { return false; } + var copiedFiles = new List<ITaskItem>(this.DestinationFiles.Length); + for (int i = 0; i < this.SourceFiles.Length; i++) { string sourcePath = this.SourceFiles[i].ItemSpec; string destPath = this.DestinationFiles[i].ItemSpec; @@ -69,22 +81,27 @@ namespace DotNetOpenAuth.BuildTasks { } using (StreamReader sr = File.OpenText(sourcePath)) { + if (!Directory.Exists(Path.GetDirectoryName(destPath))) { + Directory.CreateDirectory(Path.GetDirectoryName(destPath)); + } using (StreamWriter sw = File.CreateText(destPath)) { StringBuilder line = new StringBuilder(); - while (line.Append(sr.ReadLine()) != null) { + while (!sr.EndOfStream) { + line.Length = 0; + line.Append(sr.ReadLine()); for (int j = 0; j < beforeTokens.Length; j++) { line.Replace(beforeTokens[j], afterTokens[j]); } sw.WriteLine(line); - - // Clear out the line buffer for the next input. - line.Length = 0; } } } + + copiedFiles.Add(this.DestinationFiles[i]); } + this.CopiedFiles = copiedFiles.ToArray(); return true; } } diff --git a/src/DotNetOpenAuth.BuildTasks/Trim.cs b/src/DotNetOpenAuth.BuildTasks/Trim.cs index 1cc943e..972b87d 100644 --- a/src/DotNetOpenAuth.BuildTasks/Trim.cs +++ b/src/DotNetOpenAuth.BuildTasks/Trim.cs @@ -9,10 +9,16 @@ namespace DotNetOpenAuth.BuildTasks { using Microsoft.Build.Utilities; /// <summary> - /// Trims item identities. + /// Trims item identities or metadata. /// </summary> public class Trim : Task { /// <summary> + /// Gets or sets the name of the metadata to trim. Leave empty or null to operate on itemspec. + /// </summary> + /// <value>The name of the metadata.</value> + public string MetadataName { get; set; } + + /// <summary> /// Gets or sets the characters that should be trimmed off if found at the start of items' ItemSpecs. /// </summary> public string StartCharacters { get; set; } @@ -23,6 +29,11 @@ namespace DotNetOpenAuth.BuildTasks { public string EndCharacters { get; set; } /// <summary> + /// Gets or sets the substring that should be trimmed along with everything that appears after it. + /// </summary> + public string AllAfter { get; set; } + + /// <summary> /// Gets or sets the items with ItemSpec's to be trimmed. /// </summary> [Required] @@ -42,11 +53,23 @@ namespace DotNetOpenAuth.BuildTasks { this.Outputs = new ITaskItem[this.Inputs.Length]; for (int i = 0; i < this.Inputs.Length; i++) { this.Outputs[i] = new TaskItem(this.Inputs[i]); + string value = string.IsNullOrEmpty(this.MetadataName) ? this.Outputs[i].ItemSpec : this.Outputs[i].GetMetadata(this.MetadataName); if (!string.IsNullOrEmpty(this.StartCharacters)) { - this.Outputs[i].ItemSpec = this.Outputs[i].ItemSpec.TrimStart(this.StartCharacters.ToCharArray()); + value = value.TrimStart(this.StartCharacters.ToCharArray()); } if (!string.IsNullOrEmpty(this.EndCharacters)) { - this.Outputs[i].ItemSpec = this.Outputs[i].ItemSpec.TrimEnd(this.EndCharacters.ToCharArray()); + value = value.TrimEnd(this.EndCharacters.ToCharArray()); + } + if (!string.IsNullOrEmpty(this.AllAfter)) { + int index = value.IndexOf(this.AllAfter); + if (index >= 0) { + value = value.Substring(0, index); + } + } + if (string.IsNullOrEmpty(this.MetadataName)) { + this.Outputs[i].ItemSpec = value; + } else { + this.Outputs[i].SetMetadata(this.MetadataName, value); } } |