Is it possible to get a native .net Nuget?
mikeblakeuk opened this issue · 0 comments
mikeblakeuk commented
Using dotnet6 on windows.
We want to use SOPS and wrap the tool in a dotnet command line tool.
a) Why can't we pass text to SOPS instead of a file
b) Could someone write a NuGet to interact with SOPS?
Thanks
Not idea:
var tempFile = Path.Combine(_workingFolder, Guid.NewGuid().ToString());
try
{
// Write data to temp file
await File.WriteAllTextAsync(tempFile, data);
using var myProcess = new System.Diagnostics.Process();
try
{
myProcess.StartInfo.FileName = "sops";
myProcess.StartInfo.Arguments = $"-e {tempFile} --input-type {inputType}";
myProcess.StartInfo.WorkingDirectory = _workingFolder;
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.RedirectStandardInput = false;
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.RedirectStandardError = true;
myProcess.Start();
await myProcess.WaitForExitAsync();
var stdOut = await myProcess.StandardOutput.ReadToEndAsync();
var stdErr = await myProcess.StandardError.ReadToEndAsync();
if (myProcess.ExitCode < 0 || !string.IsNullOrEmpty(stdErr))
{
throw new Exception(stdErr);
}
return stdOut;
}
finally
{
myProcess.Kill();
myProcess.Close();
}
}
finally
{
// Delete temp file
File.Delete(tempFile);
}```