<commit_before>using System;
using System.IO;
using System.Linq;
using System.Xml;
using Nuke.Common;
using Nuke.Common.Execution;
using Nuke.Common.Git;
using Nuke.Common.ProjectModel;
using Nuke.Common.Tooling;
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Tools.MSBuild;
using Nuke.Common.Utilities.Collections;
using static Nuke.Common.EnvironmentInfo;
using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.IO.PathConstruction;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
using SDKOptions = Microsoft.Build.Definition.ProjectOptions;
using SDKProject = Microsoft.Build.Evaluation.Project;

[CheckBuildProjectConfigurations]
[UnsetVisualStudioEnvironmentVariables]
class Build : NukeBuild
{
    /// Support plugins are available for:
    ///   - JetBrains ReSharper        https://nuke.build/resharper
    ///   - JetBrains Rider            https://nuke.build/rider
    ///   - Microsoft VisualStudio     https://nuke.build/visualstudio
    ///   - Microsoft VSCode           https://nuke.build/vscode

    public static int Main () => Execute<Build>(x => x.Compile);

    [Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
    readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;

    [Solution] readonly Solution Solution;
    [GitRepository] readonly GitRepository GitRepository;

    AbsolutePath SourceDirectory => RootDirectory / "src";
    AbsolutePath OutputDirectory => RootDirectory / "out";
    AbsolutePath Tooling => SourceDirectory / "Snowflake.Tooling.Taskrunner";
    AbsolutePath Tests => SourceDirectory / "Snowflake.Framework.Tests";

    AbsolutePath BuildDirectory => RootDirectory / "build";

    AbsolutePath ToolingDirectory =>  BuildDirectory / "snowflake-cli";

    Target Clean => _ => _
        .Before(Restore)
        .Executes(() =>
        {
            SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory);
            EnsureCleanDirectory(OutputDirectory);
        });

    Target Restore => _ => _
        .Executes(() =>
        {
            DotNetRestore(s => s
                .SetProjectFile(Solution));
        });

    Target Compile => _ => _
        .DependsOn(Restore)
        .Executes(() =>
        {

            DotNetBuild(s => s
                .SetProjectFile(Solution)
                .SetConfiguration(Configuration)
                .EnableNoRestore());
        });
    Target BuildTooling => _ => _
       .DependsOn(Restore)
       .Executes(() =>
       {
           DotNetBuild(s => s
               .SetProjectFile(Tooling)
               .SetOutputDirectory(ToolingDirectory));
       });

    Target Test => _ => _
        .DependsOn(Compile)
        .Executes(() =>
        {
            DotNetTest(s => s
                .SetProjectFile(Tests));
        });

    Target PackModules => _ => _
        .DependsOn(Compile)
        .Executes(() =>
        {
            EnsureExistingDirectory(OutputDirectory);

            foreach (Project p in Solution.GetProjects("Snowflake.*"))
            {
                if (!GetSdkVersion(p).StartsWith("Snowflake.Framework.Sdk/")) continue;
                if (!File.Exists((p.Directory / "module.json"))) continue;

                DotNet("snowflake build", p.Directory);
                DotNet($"snowflake pack \"./bin/module/{p.Name}\" -o \"{OutputDirectory}\"", p.Directory);
            }
        });

    static string GetSdkVersion(Project p)
    {
        using (XmlReader reader = XmlReader.Create(p.Path))
        {
            if (reader.MoveToContent() == XmlNodeType.Element && reader.HasAttributes)
            {
                if (reader.MoveToAttribute("Sdk"))
                {
                    return reader.ReadContentAsString();
                }
            }
        }
        return String.Empty;
    }
}
<commit_msg>Bootstrap<commit_after>using System;
using System.IO;
using System.Linq;
using System.Xml;
using Nuke.Common;
using Nuke.Common.Execution;
using Nuke.Common.Git;
using Nuke.Common.ProjectModel;
using Nuke.Common.Tooling;
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Tools.MSBuild;
using Nuke.Common.Utilities.Collections;
using static Nuke.Common.EnvironmentInfo;
using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.IO.PathConstruction;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
using SDKOptions = Microsoft.Build.Definition.ProjectOptions;
using SDKProject = Microsoft.Build.Evaluation.Project;

[CheckBuildProjectConfigurations]
[UnsetVisualStudioEnvironmentVariables]
class Build : NukeBuild
{
    /// Support plugins are available for:
    ///   - JetBrains ReSharper        https://nuke.build/resharper
    ///   - JetBrains Rider            https://nuke.build/rider
    ///   - Microsoft VisualStudio     https://nuke.build/visualstudio
    ///   - Microsoft VSCode           https://nuke.build/vscode

    public static int Main () => Execute<Build>(x => x.Compile);

    [Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
    readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;

    [Solution] readonly Solution Solution;
    [GitRepository] readonly GitRepository GitRepository;

    AbsolutePath SourceDirectory => RootDirectory / "src";
    AbsolutePath OutputDirectory => RootDirectory / "out";
    AbsolutePath Tooling => SourceDirectory / "Snowflake.Tooling.Taskrunner";
    AbsolutePath Tests => SourceDirectory / "Snowflake.Framework.Tests";

    AbsolutePath BuildDirectory => RootDirectory / "build";

    AbsolutePath ToolingDirectory =>  BuildDirectory / "snowflake-cli";

    Target Clean => _ => _
        .Before(Restore)
        .Executes(() =>
        {
            SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory);
            EnsureCleanDirectory(OutputDirectory);
        });

    Target Restore => _ => _
        .Executes(() =>
        {
            DotNetRestore(s => s
                .SetProjectFile(Solution));
        });

    Target Compile => _ => _
        .DependsOn(Restore)
        .Executes(() =>
        {

            DotNetBuild(s => s
                .SetProjectFile(Solution)
                .SetConfiguration(Configuration)
                .EnableNoRestore());
        });
    Target BuildTooling => _ => _
       .DependsOn(Restore)
       .Executes(() =>
       {
           DotNetBuild(s => s
               .SetProjectFile(Tooling)
               .SetOutputDirectory(ToolingDirectory));
       });

    Target Test => _ => _
        .DependsOn(Compile)
        .Executes(() =>
        {
            DotNetTest(s => s
                .SetProjectFile(Tests));
        });

    Target PackModules => _ => _
        .DependsOn(Compile)
        .Executes(() =>
        {
            EnsureExistingDirectory(OutputDirectory);

            foreach (Project p in Solution.GetProjects("Snowflake.*"))
            {
                if (!GetSdkVersion(p).StartsWith("Snowflake.Framework.Sdk/")) continue;
                if (!File.Exists((p.Directory / "module.json"))) continue;

                DotNet("snowflake build", p.Directory);
                DotNet($"snowflake pack \"./bin/module/{p.Name}\" -o \"{OutputDirectory}\"", p.Directory);
            }
        });

    Target Bootstrap => _ => _
        .DependsOn(PackModules)
        .DependsOn(BuildTooling)
        .Executes(() =>
        {
            DotNet($"{ToolingDirectory / "dotnet-snowflake.dll"} install-all -d {OutputDirectory}");
        });

    static string GetSdkVersion(Project p)
    {
        using (XmlReader reader = XmlReader.Create(p.Path))
        {
            if (reader.MoveToContent() == XmlNodeType.Element && reader.HasAttributes)
            {
                if (reader.MoveToAttribute("Sdk"))
                {
                    return reader.ReadContentAsString();
                }
            }
        }
        return String.Empty;
    }
}

{'fraction_non_alphanumeric': 0.1209435846230654, 'fraction_numerical': 0.0, 'mean_word_length': 2.2284448025785655, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 68, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1917936', 'n_tokens_mistral': 2280, 'n_tokens_neox': 2174, 'n_words': 408}