Skip to content

Commit

Permalink
fix(builder): get stdout/stderr async
Browse files Browse the repository at this point in the history
  • Loading branch information
lippertmarkus committed May 19, 2022
1 parent 41741f8 commit c05eafa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
12 changes: 7 additions & 5 deletions Package/Builder/DotNet.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics;
using System.Text;

namespace konet.Package.Builder;

Expand Down Expand Up @@ -29,17 +30,18 @@ public static async Task Build(string targetDirectory, string project, string ru
RedirectStandardError = true
}
};
var stdOut = new StringBuilder();
var stdErr = new StringBuilder();
p.ErrorDataReceived += (_, dataArgs) => { stdErr.AppendLine(dataArgs.Data ?? string.Empty); };
p.OutputDataReceived += (_, dataArgs) => { stdOut.AppendLine(dataArgs.Data ?? string.Empty); };

p.Start();
p.BeginErrorReadLine();
p.BeginOutputReadLine();
await p.WaitForExitAsync();

if (p.ExitCode != 0)
{
var stdOut = await p.StandardOutput.ReadToEndAsync();
var stdErr = await p.StandardError.ReadToEndAsync();

throw new DotNetException($"DotNet build failed: \n{stdOut}\n\n{stdErr}");
}
}

public static string DetermineBinaryName(string project)
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ dotnet tool update --global konet
Example:

```bash
dotnet new webapi -n mywebapi
cd mywebapi/
konet build -t lippertmarkus/test-webapi:1.0
dotnet new console -n myconsoleapp
cd myconsoleapp/
konet build -t lippertmarkus/test-console:1.0
# ...
# Successfully pushed to lippertmarkus/test-webapi:1.0
# Successfully pushed to lippertmarkus/test-console:1.0
```

The result is a manifest list at the tag specified in `-t`, referencing images for different architectures with the compiled binary as the entrypoint.
Expand All @@ -54,7 +54,7 @@ The result is a manifest list at the tag specified in `-t`, referencing images f

#### Target Platforms

Per default `konet` creates images for all platforms .NET supports and for which there is an official base image available. Those include `windows/amd64:1809, windows/amd64:1903, windows/amd64:1909, windows/amd64:2004, windows/amd64:20H2, windows/amd64:ltsc2022, linux/amd64, linux/arm/v7, linux/arm64/v8`.
Per default `konet` creates images for all platforms .NET supports and for which there is an official base image available. Those include `linux/amd64,linux/arm/v7,linux/arm64/v8,windows/amd64:1809,windows/amd64:1903,windows/amd64:1909,windows/amd64:2004,windows/amd64:20H2,windows/amd64:ltsc2022`.

You can limit the platforms by adding `-p windows/amd64:ltsc2022,linux/amd64` to `konet build`.

Expand Down
2 changes: 1 addition & 1 deletion konet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ToolCommandName>konet</ToolCommandName>
<PackageOutputPath>./nupkg</PackageOutputPath>
<PackageId>konet</PackageId>
<Version>0.0.4</Version>
<Version>0.0.5</Version>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageIcon>images/logo.png</PackageIcon>
<PackageReadmeFile>docs/README.md</PackageReadmeFile>
Expand Down

0 comments on commit c05eafa

Please sign in to comment.