File: src\GetEnvProxy.cs
Web Access
Project: src\src\Microsoft.DotNet.Build.Tasks.Feed\Microsoft.DotNet.Build.Tasks.Feed.csproj (Microsoft.DotNet.Build.Tasks.Feed)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
 
using System;
 
namespace Microsoft.DotNet.Build.Tasks.Feed
{
    public interface IGetEnvProxy
    {
        public string GetEnv(string key);
    }
 
    internal class GetEnvProxy : IGetEnvProxy
    {
        public string GetEnv(string key)
        {
            var value = Environment.GetEnvironmentVariable(key);
 
            if (string.IsNullOrEmpty(value))
            {
                throw new InvalidOperationException($"Required Environment variable {key} not found.");
            }
 
            return value;
        }
    }
}