summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.BuildTasks/SetEnvironmentVariable.cs
blob: 2de5976c14ebb4d6df96c9b8f1a2ca74e9687d2e (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
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Build.Utilities;
using Microsoft.Build.Framework;

namespace DotNetOpenAuth.BuildTasks {
	public class SetEnvironmentVariable : Task {
		public SetEnvironmentVariable() {
			Scope = EnvironmentVariableTarget.Process;
		}

		/// <summary>
		/// The name of the environment variable to set or clear.
		/// </summary>
		[Required]
		public string Name { get; set; }
		/// <summary>
		/// The value of the environment variable, or the empty string to clear it.
		/// </summary>
		[Required]
		public string Value { get; set; }
		/// <summary>
		/// The target environment for the variable.  Machine, User, or Process.
		/// </summary>
		public EnvironmentVariableTarget Scope { get; set; }

		public override bool Execute() {
			Environment.SetEnvironmentVariable(Name, Value, Scope);
			return true;
		}
	}
}