blob: af50d0612f98477f954452d260c452a8e0d2b3d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
//-----------------------------------------------------------------------
// <copyright file="Publicize.cs" company="Outercurve Foundation">
// Copyright (c) Outercurve Foundation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.BuildTasks {
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.Build.BuildEngine;
using Microsoft.Build.Utilities;
using Microsoft.Build.Framework;
public class Publicize : ToolTask {
[Required]
public string MSBuildExtensionsPath { get; set; }
[Required]
public ITaskItem Assembly { get; set; }
public bool DelaySign { get; set; }
public string KeyFile { get; set; }
public bool SkipUnchangedFiles { get; set; }
[Output]
public ITaskItem AccessorAssembly { get; set; }
/// <summary>
/// Generates the full path to tool.
/// </summary>
/// <returns>An absolute path.</returns>
protected override string GenerateFullPathToTool() {
string toolPath = Path.Combine(this.MSBuildExtensionsPath, @"Microsoft\VisualStudio\v9.0\TeamTest\Publicize.exe");
return toolPath;
}
/// <summary>
/// Gets the name of the tool.
/// </summary>
/// <value>The name of the tool.</value>
protected override string ToolName {
get { return "Publicize.exe"; }
}
/// <summary>
/// Validates the parameters.
/// </summary>
protected override bool ValidateParameters() {
if (!base.ValidateParameters()) {
return false;
}
if (this.DelaySign && string.IsNullOrEmpty(this.KeyFile)) {
this.Log.LogError("DelaySign=true, but no KeyFile given.");
return false;
}
return true;
}
/// <summary>
/// Generates the command line commands.
/// </summary>
protected override string GenerateCommandLineCommands() {
CommandLineBuilder builder = new CommandLineBuilder();
if (this.DelaySign) {
builder.AppendSwitch("/delaysign");
}
builder.AppendSwitchIfNotNull("/keyfile:", this.KeyFile);
builder.AppendFileNameIfNotNull(this.Assembly);
return builder.ToString();
}
public override bool Execute() {
this.AccessorAssembly = new TaskItem(this.Assembly);
this.AccessorAssembly.ItemSpec = Path.Combine(
Path.GetDirectoryName(this.AccessorAssembly.ItemSpec),
Path.GetFileNameWithoutExtension(this.AccessorAssembly.ItemSpec) + "_Accessor") + Path.GetExtension(this.AccessorAssembly.ItemSpec);
if (this.SkipUnchangedFiles && File.GetLastWriteTimeUtc(this.Assembly.ItemSpec) < File.GetLastWriteTimeUtc(this.AccessorAssembly.ItemSpec)) {
Log.LogMessage(MessageImportance.Low, "Skipping public accessor generation for {0} because {1} is up to date.", this.Assembly.ItemSpec, this.AccessorAssembly.ItemSpec);
return true;
}
return base.Execute();
}
}
}
|