summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.BuildTasks/SnToolTask.cs
blob: 76fa5627d5ec328f12a5b8bd96d3652a24d9a329 (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
//-----------------------------------------------------------------------
// <copyright file="SnToolTask.cs" company="Outercurve Foundation">
//     Copyright (c) Outercurve Foundation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace DotNetOpenAuth.BuildTasks {
	using System;
	using System.IO;
	using Microsoft.Build.Utilities;

	public abstract class SnToolTask : ToolTask {
		/// <summary>
		/// Gets the name of the tool.
		/// </summary>
		/// <value>The name of the tool.</value>
		protected override string ToolName {
			get { return "sn.exe"; }
		}

		/// <summary>
		/// Generates the full path to tool.
		/// </summary>
		protected override string GenerateFullPathToTool() {
			string[] versions = new[] { "v6.0A", "v6.1", "v7.0a" };
			string fullPath = null;
			foreach (string version in versions) {
				fullPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"Microsoft SDKs\Windows\" + version + @"\bin\" + this.ToolName);
				if (File.Exists(fullPath)) {
					return fullPath;
				}
			}

			throw new FileNotFoundException("Unable to find sn.exe tool.", fullPath);
		}
	}
}