in TeamCity.CSharpInteractive/Host.cs [96:146]
public static int? Run(this ICommandLine commandLine, Action<Output>? handler = default, TimeSpan timeout = default) =>
HostComponents.CommandLineRunner.Run(commandLine, handler, timeout);
public static Task<int?> RunAsync(this ICommandLine commandLine, Action<Output>? handler = default, CancellationToken cancellationToken = default) =>
HostComponents.CommandLineRunner.RunAsync(commandLine, handler, cancellationToken);
public static IBuildResult Build(this ICommandLine commandLine, Action<BuildMessage>? handler = default, TimeSpan timeout = default) =>
HostComponents.BuildRunner.Run(commandLine, handler, timeout);
public static Task<IBuildResult> BuildAsync(this ICommandLine commandLine, Action<BuildMessage>? handler = default, CancellationToken cancellationToken = default) =>
HostComponents.BuildRunner.RunAsync(commandLine, handler, cancellationToken);
[Obsolete]
public static IEnumerable<NuGetPackage> Restore(this INuGet nuGet, string packageId, string? versionRange = default, string? targetFrameworkMoniker = default, string? packagesPath = default) =>
nuGet.Restore(
new NuGetRestoreSettings(packageId)
.WithVersionRange(versionRange != default ? VersionRange.Parse(versionRange) : default)
.WithTargetFrameworkMoniker(targetFrameworkMoniker)
.WithPackagesPath(packagesPath));
public static bool TryGetValue<T>(this IProperties properties, string key, [MaybeNullWhen(false)] out T value)
{
if (properties.TryGetValue(key, out var valStr))
{
if (typeof(T) == typeof(string))
{
value = (T)(object)valStr;
return true;
}
var converter = TypeDescriptor.GetConverter(typeof(T));
if (converter.CanConvertFrom(typeof(string)))
{
var nullableValue = converter.ConvertFrom(valStr);
if (!Equals(nullableValue, null))
{
try
{
value = (T)nullableValue;
return true;
}
catch (InvalidCastException)
{
}
}
}
}
value = default;
return false;
}