From 5ee108549801f0eb02f9695a639c12f4dd2fcafe Mon Sep 17 00:00:00 2001
From: Julian Verdurmen <304NotModified@users.noreply.github.com>
Date: Thu, 19 Oct 2017 09:11:38 +0200
Subject: [PATCH] Auto patch file version on AppVeyor
---
appveyor.yml | 2 +
patchFileVersion.ps1 | 42 +++++++++++++++++++
.../NLog.Extensions.Logging.csproj | 5 +++
3 files changed, 49 insertions(+)
create mode 100644 patchFileVersion.ps1
diff --git a/appveyor.yml b/appveyor.yml
index 46169519..0e082644 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -4,6 +4,8 @@ build_script:
- ps: >-
dotnet restore src\NLog.Extensions.Logging
+ .\patchFileVersion.ps1 "NLog.Extensions.Logging.csproj" "$env:appveyor_build_version"
+
dotnet pack src\NLog.Extensions.Logging --configuration Release
artifacts:
- path: 'src\NLog.Extensions.Logging\bin\release\*.nupkg'
diff --git a/patchFileVersion.ps1 b/patchFileVersion.ps1
new file mode 100644
index 00000000..2392f74a
--- /dev/null
+++ b/patchFileVersion.ps1
@@ -0,0 +1,42 @@
+param([string]$filewildCard, [string]$version)
+
+#returns FileInfo
+function findFile([string]$filewildCard) {
+
+ $files = @(Get-ChildItem $filewildCard -Recurse);
+ if ($files.Length -gt 1) {
+ throw "Found $($files.length) files. Stop, we need an unique pattern"
+ }
+ if ($files.Length -eq 0) {
+ throw "Find not found with pattern $filewildCard. Stop"
+ }
+ return $files[0];
+}
+
+function patchAssemblyFileVersion([System.IO.FileInfo]$file , [string]$version) {
+
+ $xmlPath = $file.FullName;
+
+ $xml = [xml](get-content $xmlPath)
+
+ $propertyGroup = $xml.Project.PropertyGroup
+
+ Write-Host "patch $xmlPath to $version"
+
+ # FileVersion = AssemblyFileVersionAttribute
+ $propertyGroup[0].FileVersion = $version
+
+ $xml.Save($xmlPath)
+}
+
+$file = findFile $filewildCard -ErrorAction Stop
+
+patchAssemblyFileVersion $file $version -ErrorAction Stop
+
+
+
+trap
+{
+ write-output $_
+ exit 1
+}
\ No newline at end of file
diff --git a/src/NLog.Extensions.Logging/NLog.Extensions.Logging.csproj b/src/NLog.Extensions.Logging/NLog.Extensions.Logging.csproj
index 0519e1af..bfe6d86e 100644
--- a/src/NLog.Extensions.Logging/NLog.Extensions.Logging.csproj
+++ b/src/NLog.Extensions.Logging/NLog.Extensions.Logging.csproj
@@ -28,6 +28,11 @@ rc2 (see https://github.com/NLog/NLog.Extensions.Logging/milestone/9?closed=1)
git
git://github.com/NLog/NLog.Extensions.Logging
1.0.0-rtm-rc2
+
+ 1.0.0.0
+
+ 1.0.0.0
+