<commit_before>use 4.0 MSBuild

task Clean {
    del * -Include artifacts, bin, obj -Recurse -Force
}

task BackupProjects Clean, {
    dir * -Include project.json, project.lock.json -Recurse |% {
        copy $_.FullName ($_.FullName + ".bak") -Force
    }
}

task UpdateVersions BackupProjects, {
    $version = if($env:APPVEYOR) { $env:APPVEYOR_BUILD_VERSION } else { "1.0.0" }

    dir * -Include project.json, project.lock.json -Recurse |% {
        (gc $_.FullName) |% { $_ -replace "1.0.0-ci", $version } | sc $_.FullName
    }
}

task RestoreDependencies UpdateVersions, {
   exec { dotnet restore }
}

task PackProjects RestoreDependencies, {
    dir src -Include project.json -Recurse |% {
        $project = $_.FullName
        exec { dotnet pack $project -c Release }
    }
}

task CopyArtifacts PackProjects, {
    ni "artifacts" -ItemType Directory -Force

    dir src -Include *.nupkg -Recurse |% {
        copy $_.FullName ("artifacts") -Force
    }
}

task RunTests CopyArtifacts, {
    dir test -Include project.json -Recurse |% {
        $project = $_.FullName
        exec { dotnet test $project -c Release }
    }
}

task RestoreProjects RunTests, {
    dir * -Include project.json.bak, project.lock.json.bak -Recurse |% {
        move $_.FullName $_.FullName.Replace(".bak", "") -Force
    }
}

task . RestoreProjects<commit_msg>Updates build script to not run tests when there are none.<commit_after>use 4.0 MSBuild

task Clean {
    del * -Include artifacts, bin, obj -Recurse -Force
}

task BackupProjects Clean, {
    dir * -Include project.json, project.lock.json -Recurse |% {
        copy $_.FullName ($_.FullName + ".bak") -Force
    }
}

task UpdateVersions BackupProjects, {
    $version = if($env:APPVEYOR) { $env:APPVEYOR_BUILD_VERSION } else { "1.0.0" }

    dir * -Include project.json, project.lock.json -Recurse |% {
        (gc $_.FullName) |% { $_ -replace "1.0.0-ci", $version } | sc $_.FullName
    }
}

task RestoreDependencies UpdateVersions, {
   exec { dotnet restore }
}

task PackProjects RestoreDependencies, {
    if(Test-Path src) {
        dir src -Include project.json -Recurse |% {
            $project = $_.FullName
            exec { dotnet pack $project -c Release }
        }
    }
}

task CopyArtifacts PackProjects, {
    ni "artifacts" -ItemType Directory -Force
    
    if(Test-Path src) {
        dir src -Include *.nupkg -Recurse |% {
            copy $_.FullName ("artifacts") -Force
        }
    }
}

task RunTests CopyArtifacts, {
    if(Test-Path test) {
        dir test -Include project.json -Recurse |% {
            $project = $_.FullName
            exec { dotnet test $project -c Release }
        }
    }
}

task RestoreProjects RunTests, {
    dir * -Include project.json.bak, project.lock.json.bak -Recurse |% {
        move $_.FullName $_.FullName.Replace(".bak", "") -Force
    }
}

task . RestoreProjects
{'fraction_non_alphanumeric': 0.13097713097713098, 'fraction_numerical': 0.005544005544005544, 'mean_word_length': 2.474127557160048, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '2694139', 'n_tokens_mistral': 990, 'n_tokens_neox': 964, 'n_words': 243}