Skip to content

Commit

Permalink
Improved build, add configs to repo
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolayPianikov committed Jun 6, 2024
1 parent 99c71cd commit c528a7c
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 17 deletions.
20 changes: 20 additions & 0 deletions .run/Build and push.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Build and push" type="DotNetProject" factoryName=".NET Project">
<option name="EXE_PATH" value="$PROJECT_DIR$/build/bin/Debug/net8.0/build.exe" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/build/bin/Debug/net8.0" />
<option name="PASS_PARENT_ENVS" value="1" />
<option name="USE_EXTERNAL_CONSOLE" value="0" />
<option name="USE_MONO" value="0" />
<option name="RUNTIME_ARGUMENTS" value="" />
<option name="PROJECT_PATH" value="$PROJECT_DIR$/build/build.csproj" />
<option name="PROJECT_EXE_PATH_TRACKING" value="1" />
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
<option name="PROJECT_KIND" value="DotNetCore" />
<option name="PROJECT_TFM" value="net8.0" />
<method v="2">
<option name="Build" />
</method>
</configuration>
</component>
12 changes: 12 additions & 0 deletions .run/Dockerfile.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Dockerfile" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
<deployment type="dockerfile">
<settings>
<option name="containerName" value="" />
<option name="sourceFilePath" value="Dockerfile" />
</settings>
</deployment>
<EXTENSION ID="com.jetbrains.rider.docker.debug" isFastModeEnabled="true" isSslEnabled="false" />
<method v="2" />
</configuration>
</component>
9 changes: 4 additions & 5 deletions build/Program.cs
Original file line number Diff line number Diff line change
@@ -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");
new DockerCustom("build", "-t", image, ".").TryRun();
new DockerCustom("login").TryRun();
new DockerCustom("tag", image, repoImage).TryRun();
new DockerCustom("image", "push", repoImage).TryRun();
25 changes: 13 additions & 12 deletions build/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit c528a7c

Please sign in to comment.