diff --git a/.run/Build and push.run.xml b/.run/Build and push.run.xml new file mode 100644 index 0000000..31f026c --- /dev/null +++ b/.run/Build and push.run.xml @@ -0,0 +1,20 @@ + + + + \ No newline at end of file diff --git a/.run/Dockerfile.run.xml b/.run/Dockerfile.run.xml new file mode 100644 index 0000000..1bea4d9 --- /dev/null +++ b/.run/Dockerfile.run.xml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/build/Program.cs b/build/Program.cs index 763426e..2d10552 100644 --- a/build/Program.cs +++ b/build/Program.cs @@ -1,8 +1,7 @@ const string image = "dotnetsdk:latest"; const string repoImage = "nikolayp/dotnetsdk:latest"; -Tools.SetupEnvironment(); -new DockerCustom("build", "-t", image, ".").Run("building"); -new DockerCustom("login").Run("login"); -new DockerCustom("tag", image, repoImage).Run("tagging"); -new DockerCustom("image", "push", repoImage).Run("pushing"); \ No newline at end of file +new DockerCustom("build", "-t", image, ".").TryRun(); +new DockerCustom("login").TryRun(); +new DockerCustom("tag", image, repoImage).TryRun(); +new DockerCustom("image", "push", repoImage).TryRun(); \ No newline at end of file diff --git a/build/Tools.cs b/build/Tools.cs index 7f4d0de..09234c7 100644 --- a/build/Tools.cs +++ b/build/Tools.cs @@ -3,20 +3,10 @@ internal static class Tools { private const string SolutionFile = "dotnetsdk.sln"; - - public static void SetupEnvironment() - { - if (Path.GetDirectoryName(Environment.CurrentDirectory.TryFindFile(SolutionFile)) is { } solutionDir) - { - Environment.CurrentDirectory = solutionDir; - return; - } - - Error($"Solution file {SolutionFile} could not be found."); - } - public static void Run(this ICommandLine command, string shortName) + public static void TryRun(this ICommandLine command) { + SetupEnvironment(); if (command.Run(i => WriteLine($"{command}> {i.Line}", Color.Trace)) == 0) { return; @@ -26,6 +16,17 @@ public static void Run(this ICommandLine command, string shortName) Environment.Exit(1); } + private static void SetupEnvironment() + { + if (Path.GetDirectoryName(Environment.CurrentDirectory.TryFindFile(SolutionFile)) is { } solutionDir) + { + Environment.CurrentDirectory = solutionDir; + return; + } + + Error($"Solution file {SolutionFile} could not be found."); + } + private static string? TryFindFile(this string? path, string searchPattern) { string? target = default;