<commit_before># PASTE THIS INTO APPVEYOUR - Build

#######################################################################
###     Setup variables from Appveyor                               ###
#######################################################################
$repoPath = Resolve-Path .
$buildVersion = $env:appveyor_build_version
$branchName = $env:appveyor_repo_branch
$repoName = $env:appveyor_repo_name
$nugetUrl = $env:nuget_gallery_url
$nugetKey = $env:nuget_api_key
$mygetUrl = $env:myget_gallery_url
$mygetKey = $env:myget_api_key

#######################################################################
###     Download NuGet tools & Setup NuGet/Artifact scriptblocks    ###
#######################################################################
NuGet sources add -Name OBeautifulCodeMyGet -Source https://www.myget.org/F/obeautifulcode-nuget/api/v3/index.json
NuGet sources add -Name NaosMyGet -Source https://www.myget.org/F/naos-nuget/api/v3/index.json
$TempBuildPackagesDir = "../TempTools/packages"
if (-not (Test-Path $TempBuildPackagesDir)) { md $TempBuildPackagesDir | Out-Null }
$TempBuildPackagesDir = Resolve-Path $TempBuildPackagesDir
NuGet install 'Naos.Powershell.Build' -OutputDirectory $TempBuildPackagesDir
$nugetFunctionsScriptPath = $(ls $TempBuildPackagesDir -Recurse | ?{$_.Name -eq 'NuGet-Functions.ps1'}).FullName
. $nugetFunctionsScriptPath

$nugetScriptblock = { param([string] $fileName) 
   Write-Host "Pushing $fileName to Build Artifacts"
   Push-AppveyorArtifact $fileName

   Write-Host "Pushing $fileName to NuGet Gallery"
   Nuget-PublishPackage -packagePath $fileName -apiUrl $nugetUrl -apiKey $nugetKey

   Write-Host "Pushing $fileName to MyGet Gallery"
   Nuget-PublishPackage -packagePath $fileName -apiUrl $mygetUrl -apiKey $mygetKey
}

$artifactScriptBlock = { param([string] $fileName) 
   Write-Host "Pushing $fileName to Build Artifacts"
   Push-AppveyorArtifact $fileName
}

#######################################################################
###     Pack and push build                                         ###
#######################################################################
$createdPackagePaths = New-Object 'System.Collections.Generic.List[String]'
$informationalVersion = Nuget-CreatePreReleaseSupportedVersion -version $buildVersion -branchName $branchName

$nuspecs = New-Object 'System.Collections.Generic.List[String]'
$nuSpecFileAnalyzer = Resolve-Path ./Analyzers/OBeautifulCode.Build.Analyzers.nuspec
$nuspecs.Add($nuSpecFileAnalyzer)
$nuSpecFilePackaging = Resolve-Path ./Packaging/OBeautifulCode.Build.Packaging.nuspec
$nuspecs.Add($nuSpecFilePackaging)
$nuSpecFileConventionsRepoConfig = Resolve-Path ./Conventions/OBeautifulCode.Build.Conventions.RepoConfig.nuspec
$nuspecs.Add($nuSpecFileConventionsRepoConfig)
$nuSpecFileConventionsReSharper = Resolve-Path ./Conventions/OBeautifulCode.Build.Conventions.ReSharper.nuspec
$nuspecs.Add($nuSpecFileConventionsReSharper)

$nuSpecTemplateFilePath = $(ls . -Recurse | ?{$_.Name -eq 'OBeautifulCodeVisualStudioProjectTemplate.template-nuspec'}).FullName

$visualStudioProjectTemplateDirectories = ls ./Conventions/VisualStudioProjectTemplates | ?{$_.PSIsContainer} | %{$_.FullName}
$visualStudioProjectTemplateDirectories | %{
    $projectTemplateDirectory = $_
    $projectTemplateDirectoryName = Split-Path $projectTemplateDirectory -Leaf
    $packageId = "OBeautifulCode.Build.Conventions.VisualStudioProjectTemplates.$projectTemplateDirectoryName"
    $nuSpecFilePath = "./VisualStudioProjectTemplate_$projectTemplateDirectoryName.nuspec"
	$contents = Nuget-GetMinimumNuSpec -id $packageId -version '$version$' -authors $authors -description $description -isDevelopmentDependency $true
	$contents | Out-File $nuSpecFilePath -Force
	[xml] $nuSpecFileXml = Get-Content $nuSpecFilePath    
	[xml] $nuSpecTemplateFileXml = Get-Content $nuSpecTemplateFilePath
	Nuget-OverrideNuSpec -nuSpecFileXml $nuSpecFileXml -overrideNuSpecFileXml $nuSpecTemplateFileXml -autoPackageId $packageId
    $filesNode = $nuSpecFileXml.CreateElement('files')
	
	$files = ls $projectTemplateDirectory -Recurse | ?{-not $_.PSIsContainer}

	$files | %{
		$fileName = $_.Name
		$filePath = $_.FullName
		$relativeFilePathToTemplateDirectory = $filePath.Replace($projectTemplateDirectory, '')
		if ($relativeFilePathToTemplateDirectory.StartsWith('/') -or $relativeFilePathToTemplateDirectory.StartsWith('\'))
		{
			# strip off the leading / or \ because it will mess things up...
			$relativeFilePathToTemplateDirectory = $relativeFilePathToTemplateDirectory.Substring(1, $relativeFilePathToTemplateDirectory.Length - 1)
		}<commit_msg>Minor fix for correctness in AppVeyor Build Repo build script.<commit_after># PASTE THIS INTO APPVEYOUR - Build

#######################################################################
###     Setup variables from Appveyor                               ###
#######################################################################
$repoPath = Resolve-Path .
$buildVersion = $env:appveyor_build_version
$branchName = $env:appveyor_repo_branch
$repoName = $env:appveyor_repo_name
$nugetUrl = $env:nuget_gallery_url
$nugetKey = $env:nuget_api_key
$mygetUrl = $env:myget_gallery_url
$mygetKey = $env:myget_api_key

#######################################################################
###     Download NuGet tools & Setup NuGet/Artifact scriptblocks    ###
#######################################################################
NuGet sources add -Name OBeautifulCodeMyGet -Source https://www.myget.org/F/obeautifulcode-nuget/api/v3/index.json
NuGet sources add -Name NaosMyGet -Source https://www.myget.org/F/naos-nuget/api/v3/index.json
$TempBuildPackagesDir = "../TempTools/packages"
if (-not (Test-Path $TempBuildPackagesDir)) { md $TempBuildPackagesDir | Out-Null }
$TempBuildPackagesDir = Resolve-Path $TempBuildPackagesDir
NuGet install 'Naos.Powershell.Build' -OutputDirectory $TempBuildPackagesDir
$nugetFunctionsScriptPath = $(ls $TempBuildPackagesDir -Recurse | ?{$_.Name -eq 'NuGet-Functions.ps1'}).FullName
. $nugetFunctionsScriptPath

$nugetScriptblock = { param([string] $fileName) 
   Write-Host "Pushing $fileName to Build Artifacts"
   Push-AppveyorArtifact $fileName

   Write-Host "Pushing $fileName to NuGet Gallery"
   Nuget-PublishPackage -packagePath $fileName -apiUrl $nugetUrl -apiKey $nugetKey

   Write-Host "Pushing $fileName to MyGet Gallery"
   Nuget-PublishPackage -packagePath $fileName -apiUrl $mygetUrl -apiKey $mygetKey
}

$artifactScriptBlock = { param([string] $fileName) 
   Write-Host "Pushing $fileName to Build Artifacts"
   Push-AppveyorArtifact $fileName
}

#######################################################################
###     Pack and push build                                         ###
#######################################################################
$createdPackagePaths = New-Object 'System.Collections.Generic.List[String]'
$informationalVersion = Nuget-CreatePreReleaseSupportedVersion -version $buildVersion -branchName $branchName

$nuspecs = New-Object 'System.Collections.Generic.List[String]'
$nuSpecFileAnalyzer = Resolve-Path ./Analyzers/OBeautifulCode.Build.Analyzers.nuspec
$nuspecs.Add($nuSpecFileAnalyzer)
$nuSpecFilePackaging = Resolve-Path ./Packaging/OBeautifulCode.Build.Packaging.nuspec
$nuspecs.Add($nuSpecFilePackaging)
$nuSpecFileConventionsRepoConfig = Resolve-Path ./Conventions/OBeautifulCode.Build.Conventions.RepoConfig.nuspec
$nuspecs.Add($nuSpecFileConventionsRepoConfig)
$nuSpecFileConventionsReSharper = Resolve-Path ./Conventions/OBeautifulCode.Build.Conventions.ReSharper.nuspec
$nuspecs.Add($nuSpecFileConventionsReSharper)

$nuSpecTemplateFilePath = $(ls . -Recurse | ?{$_.Name -eq 'OBeautifulCodeVisualStudioProjectTemplate.template-nuspec'}).FullName

$visualStudioProjectTemplateDirectories = ls ./Conventions/VisualStudioProjectTemplates | ?{$_.PSIsContainer} | %{$_.FullName}
$visualStudioProjectTemplateDirectories | %{
    $projectTemplateDirectory = $_
    $projectTemplateDirectoryName = Split-Path $projectTemplateDirectory -Leaf
    $packageId = "OBeautifulCode.Build.Conventions.VisualStudioProjectTemplates.$projectTemplateDirectoryName"
    $nuSpecFilePath = "./VisualStudioProjectTemplate_$projectTemplateDirectoryName.nuspec"
	$contents = Nuget-GetMinimumNuSpec -id $packageId -version '$version$' -authors $authors -description 'Visual Studio Project Template - Description changed below' -isDevelopmentDependency $true
	$contents | Out-File $nuSpecFilePath -Force
	[xml] $nuSpecFileXml = Get-Content $nuSpecFilePath    
	[xml] $nuSpecTemplateFileXml = Get-Content $nuSpecTemplateFilePath
	Nuget-OverrideNuSpec -nuSpecFileXml $nuSpecFileXml -overrideNuSpecFileXml $nuSpecTemplateFileXml -autoPackageId $packageId
    $filesNode = $nuSpecFileXml.CreateElement('files')
	
	$files = ls $projectTemplateDirectory -Recurse | ?{-not $_.PSIsContainer}

	$files | %{
		$fileName = $_.Name
		$filePath = $_.FullName
		$relativeFilePathToTemplateDirectory = $filePath.Replace($projectTemplateDirectory, '')
		if ($relativeFilePathToTemplateDirectory.StartsWith('/') -or $relativeFilePathToTemplateDirectory.StartsWith('\'))
		{
			# strip off the leading / or \ because it will mess things up...
			$relativeFilePathToTemplateDirectory = $relativeFilePathToTemplateDirectory.Substring(1, $relativeFilePathToTemplateDirectory.Length - 1)
		}
{'fraction_non_alphanumeric': 0.1876530069185737, 'fraction_numerical': 0.0010643959552953698, 'mean_word_length': 6.1452471482889734, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4326505', 'n_tokens_mistral': 2786, 'n_tokens_neox': 2667, 'n_words': 489}