forked from DotNetOpenAuth/DotNetOpenAuth
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSetEnvironmentVariable.cs
More file actions
33 lines (30 loc) · 892 Bytes
/
SetEnvironmentVariable.cs
File metadata and controls
33 lines (30 loc) · 892 Bytes
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;
}
}
}