Bring Host build into separate project
This commit is contained in:
parent
07b785c183
commit
7bf08c5bd5
76 changed files with 1065 additions and 320 deletions
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build.Framework
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]
|
||||
public class EnvironmentAttribute : TargetConditionAttribute
|
||||
{
|
||||
private string _envVar;
|
||||
private string[] _expectedVals;
|
||||
|
||||
public EnvironmentAttribute(string envVar, params string[] expectedVals)
|
||||
{
|
||||
if (string.IsNullOrEmpty(envVar))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(envVar));
|
||||
}
|
||||
if (expectedVals == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(expectedVals));
|
||||
}
|
||||
|
||||
_envVar = envVar;
|
||||
_expectedVals = expectedVals;
|
||||
}
|
||||
|
||||
public override bool EvaluateCondition()
|
||||
{
|
||||
var actualVal = Environment.GetEnvironmentVariable(_envVar);
|
||||
|
||||
if (_expectedVals.Any())
|
||||
{
|
||||
return _expectedVals.Any(ev => string.Equals(actualVal, ev, StringComparison.Ordinal));
|
||||
}
|
||||
else
|
||||
{
|
||||
return !string.IsNullOrEmpty(actualVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue