dotnet-installer/scripts/Microsoft.DotNet.Cli.Build.Framework/TargetConditions/EnvironmentAttribute.cs
Sridhar Periyasamy d4a3190bfc Refactor the build scripts
- Bifurcate Package and Publish targets to enable signing.
- Move publish from bash/ps into c#.
- Create multiple targets to create MSIs and Bundles.
2016-03-07 12:20:50 -08:00

37 lines
1.1 KiB
C#

using System;
using System.Collections.Generic;
namespace Microsoft.DotNet.Cli.Build.Framework
{
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]
public class EnvironmentAttribute : TargetConditionAttribute
{
private string _envVar;
private string _expectedVal;
public EnvironmentAttribute(string envVar, string expectedVal)
{
if (string.IsNullOrEmpty(envVar))
{
throw new ArgumentNullException("envVar");
}
_envVar = envVar;
_expectedVal = expectedVal;
}
public override bool EvaluateCondition()
{
var actualVal = Environment.GetEnvironmentVariable(_envVar);
if (string.IsNullOrEmpty(_expectedVal))
{
return string.IsNullOrEmpty(actualVal) ||
actualVal.Equals("0") ||
actualVal.ToLower().Equals("false");
}
return _expectedVal.Equals(actualVal, StringComparison.Ordinal);
}
}
}