<commit_before>﻿Start-FileDownload "https://raw.githubusercontent.com/bramborman/AppVeyorBuildScripts/master/Scripts/Set-BuildVersion.ps1"
.\Set-BuildVersion.ps1

Start-FileDownload "https://raw.githubusercontent.com/bramborman/AppVeyorBuildScripts/master/Scripts/Set-PureBuildVersion.ps1"
.\Set-PureBuildVersion.ps1

Write-Host "`nVersions patching"
Write-Host   "================="
Install-Module -Name powershell-yaml -Force

if($LastExitCode -ne 0)
{
	$host.SetShouldExit($LastExitCode)
}

$yaml           = Get-Content .\appveyor.yml -Raw
$appveyorConfig = ConvertFrom-Yaml $yaml
$buildVersion   = $appveyorConfig.version.Replace('-', '.').Replace("{branch}", $null).Replace("{build}", $env:APPVEYOR_BUILD_NUMBER)
$projectFiles   = Get-ChildItem -Include "*.csproj" -Recurse

foreach ($projectFile in $projectFiles)
{
    $xml = [xml](Get-Content $projectFile.FullName)

    $propertyGroup = $xml | Select-Xml -XPath "/Project/PropertyGroup[Version='1.0.0']"
    $propertyGroup = $propertyGroup.Node

    $propertyGroup.Version          = $buildVersion
    $propertyGroup.FileVersion      = $buildVersion
	$propertyGroup.AssemblyVersion  = $buildVersion

	if (!($projectFile.Name.Contains("Tests")))
	{
		$propertyGroup.PackageVersion = $env:APPVEYOR_BUILD_VERSION
	}

    $xml.Save($projectFile.FullName)

    if($LastExitCode -ne 0)
    {
        $host.SetShouldExit($LastExitCode)
    }
}

Write-Host "`nLibrary Build"
Write-Host   "============="
dotnet restore
dotnet pack NotifyPropertyChangedBase\NotifyPropertyChangedBase.csproj -c Release -o $(Get-Location)

Write-Host "`nTests Build"
Write-Host   "==========="
dotnet build NotifyPropertyChangedBase.Tests\NotifyPropertyChangedBase.Tests.csproj -c Release

Write-Host "`nArtifacts"
Write-Host   "========="

Push-AppveyorArtifact *.nupkg
$projectFolders = Get-ChildItem -Directory -Filter "NotifyPropertyChangedBase*"

foreach ($projectFolder in $projectFolders)
{
	$releaseFolder = Join-Path $projectFolder.FullName "\bin\Release"

	if (!(Test-Path $releaseFolder))
	{
		throw "Invalid project release folder. `$releaseFolder: '$releaseFolder'"
	}

	$zipFileName = "$projectFolder.$env:APPVEYOR_BUILD_VERSION.zip"
	7z a $zipFileName "$releaseFolder\*"
	
	Push-AppveyorArtifact $zipFileName
}

Start-FileDownload "https://raw.githubusercontent.com/bramborman/AppVeyorBuildScripts/master/Scripts/Deployment-Skipping.ps1"
.\Deployment-Skipping.ps1

Write-Host "`n.NET Core tests"
Write-Host   "==============="
dotnet vstest NotifyPropertyChangedBase.Tests\bin\Release\netcoreapp1.0\NotifyPropertyChangedBase.Tests.NetCore.dll /logger:trx
(New-Object "System.Net.WebClient").UploadFile("https://ci.appveyor.com/api/testresults/mstest/$env:APPVEYOR_JOB_ID", (Resolve-Path "TestResults\*.trx"))

Write-Host "`nCodecov"
Write-Host   "======="
choco install opencover.portable codecov --no-progress

$target = "dotnet.exe"
$targetArgs = "test NotifyPropertyChangedBase.Tests\NotifyPropertyChangedBase.Tests.csproj -c Release -f net45 /p:DebugType=PdbOnly"
$filter = """+[NotifyPropertyChangedBase*]* -[NotifyPropertyChangedBase.Tests*]*"""
$output = "OpenCoverResults.xml"

OpenCover.Console.exe -register:user -target:$target -targetargs:$targetArgs -filter:$filter -output:$output
codecov -f $output<commit_msg>WHY IS .NET CORE SOO F*CKING HARD TO USE THESE DAYS [skip deployment]<commit_after>﻿Start-FileDownload "https://raw.githubusercontent.com/bramborman/AppVeyorBuildScripts/master/Scripts/Set-BuildVersion.ps1"
.\Set-BuildVersion.ps1

Start-FileDownload "https://raw.githubusercontent.com/bramborman/AppVeyorBuildScripts/master/Scripts/Set-PureBuildVersion.ps1"
.\Set-PureBuildVersion.ps1

Write-Host "`nVersions patching"
Write-Host   "================="
Install-Module -Name powershell-yaml -Force

if($LastExitCode -ne 0)
{
	$host.SetShouldExit($LastExitCode)
}

$yaml           = Get-Content .\appveyor.yml -Raw
$appveyorConfig = ConvertFrom-Yaml $yaml
$buildVersion   = $appveyorConfig.version.Replace('-', '.').Replace("{branch}", $null).Replace("{build}", $env:APPVEYOR_BUILD_NUMBER)
$projectFiles   = Get-ChildItem -Include "*.csproj" -Recurse

foreach ($projectFile in $projectFiles)
{
    $xml = [xml](Get-Content $projectFile.FullName)

    $propertyGroup = $xml | Select-Xml -XPath "/Project/PropertyGroup[Version='1.0.0']"
    $propertyGroup = $propertyGroup.Node

    $propertyGroup.Version          = $buildVersion
    $propertyGroup.FileVersion      = $buildVersion
	$propertyGroup.AssemblyVersion  = $buildVersion

	if (!($projectFile.Name.Contains("Tests")))
	{
		$propertyGroup.PackageVersion = $env:APPVEYOR_BUILD_VERSION
	}

    $xml.Save($projectFile.FullName)

    if($LastExitCode -ne 0)
    {
        $host.SetShouldExit($LastExitCode)
    }
}

Write-Host "`nLibrary Build"
Write-Host   "============="
dotnet restore
dotnet pack NotifyPropertyChangedBase\NotifyPropertyChangedBase.csproj -c Release -o $(Get-Location)

Write-Host "`nArtifacts"
Write-Host   "========="

Push-AppveyorArtifact *.nupkg
$projectFolders = Get-ChildItem -Directory -Filter "NotifyPropertyChangedBase*"

foreach ($projectFolder in $projectFolders)
{
	$releaseFolder = Join-Path $projectFolder.FullName "\bin\Release"

	if (!(Test-Path $releaseFolder))
	{
		throw "Invalid project release folder. `$releaseFolder: '$releaseFolder'"
	}

	$zipFileName = "$projectFolder.$env:APPVEYOR_BUILD_VERSION.zip"
	7z a $zipFileName "$releaseFolder\*"
	
	Push-AppveyorArtifact $zipFileName
}

Start-FileDownload "https://raw.githubusercontent.com/bramborman/AppVeyorBuildScripts/master/Scripts/Deployment-Skipping.ps1"
.\Deployment-Skipping.ps1

Write-Host "`n.NET Core tests"
Write-Host   "==============="
dotnet vstest NotifyPropertyChangedBase.Tests\bin\Release\netcoreapp1.0\NotifyPropertyChangedBase.Tests.NetCore.dll /logger:trx
(New-Object "System.Net.WebClient").UploadFile("https://ci.appveyor.com/api/testresults/mstest/$env:APPVEYOR_JOB_ID", (Resolve-Path "TestResults\*.trx"))

Write-Host "`nCodecov"
Write-Host   "======="
choco install opencover.portable codecov --no-progress

$target = "dotnet.exe"
$targetArgs = "test NotifyPropertyChangedBase.Tests\NotifyPropertyChangedBase.Tests.csproj -c Release -f net45 /p:DebugType=PdbOnly"
$filter = """+[NotifyPropertyChangedBase*]* -[NotifyPropertyChangedBase.Tests*]*"""
$output = "OpenCoverResults.xml"

dotnet build NotifyPropertyChangedBase\NotifyPropertyChangedBase.csproj -c Release -f net45 --no-incremental /p:DebugType=PdbOnly
OpenCover.Console.exe -register:user -target:$target -targetargs:$targetArgs -filter:$filter -output:$output
codecov -f $output
{'fraction_non_alphanumeric': 0.15329687025220298, 'fraction_numerical': 0.005165603160133698, 'mean_word_length': 5.434995112414467, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '871434', 'n_tokens_mistral': 2227, 'n_tokens_neox': 2149, 'n_words': 351}