From 1fb1e400397bb0b06b0d7c5c0127e9ecef3e2c7c Mon Sep 17 00:00:00 2001
From: zanaptak <53196138+zanaptak@users.noreply.github.com>
Date: Sat, 28 Sep 2019 22:08:05 -0500
Subject: [PATCH] Enable xml doc file
---
.editorconfig | 5 +-
benchmark/{Program.fs => Benchmark.fs} | 0
.../BinaryToTextEncoding.Benchmark.fsproj | 8 +-
benchmark/BinaryToTextEncoding.Benchmark.sln | 8 +-
invoke.build.ps1 | 111 ++++++++++++++++--
src/BinaryToTextEncoding.fsproj | 9 +-
src/BinaryToTextEncoding.sln | 8 +-
7 files changed, 132 insertions(+), 17 deletions(-)
rename benchmark/{Program.fs => Benchmark.fs} (100%)
diff --git a/.editorconfig b/.editorconfig
index 1923d41..751256f 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,8 +1,11 @@
root = true
[*]
+charset = utf-8
indent_style = space
indent_size = 2
-charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
+
+[*.{sln,fsproj,csproj,vbproj}]
+charset = utf-8-bom
diff --git a/benchmark/Program.fs b/benchmark/Benchmark.fs
similarity index 100%
rename from benchmark/Program.fs
rename to benchmark/Benchmark.fs
diff --git a/benchmark/BinaryToTextEncoding.Benchmark.fsproj b/benchmark/BinaryToTextEncoding.Benchmark.fsproj
index a7f7146..206c7a0 100644
--- a/benchmark/BinaryToTextEncoding.Benchmark.fsproj
+++ b/benchmark/BinaryToTextEncoding.Benchmark.fsproj
@@ -2,11 +2,11 @@
Exe
- netcoreapp2.2
+ netcoreapp3.0
-
+
@@ -14,9 +14,7 @@
-
- ..\src\bin\Release\netstandard2.0\Zanaptak.BinaryToTextEncoding.dll
-
+
diff --git a/benchmark/BinaryToTextEncoding.Benchmark.sln b/benchmark/BinaryToTextEncoding.Benchmark.sln
index b737aa8..3630f80 100644
--- a/benchmark/BinaryToTextEncoding.Benchmark.sln
+++ b/benchmark/BinaryToTextEncoding.Benchmark.sln
@@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29230.47
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "BinaryToTextEncoding.Benchmark", "BinaryToTextEncoding.Benchmark.fsproj", "{240BE72A-D56C-4172-9CCD-BFE133670546}"
+Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "BinaryToTextEncoding.Benchmark", "BinaryToTextEncoding.Benchmark.fsproj", "{240BE72A-D56C-4172-9CCD-BFE133670546}"
+EndProject
+Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "BinaryToTextEncoding", "..\src\BinaryToTextEncoding.fsproj", "{532B2F15-163D-486B-908B-3ABB360C45FA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,6 +17,10 @@ Global
{240BE72A-D56C-4172-9CCD-BFE133670546}.Debug|Any CPU.Build.0 = Debug|Any CPU
{240BE72A-D56C-4172-9CCD-BFE133670546}.Release|Any CPU.ActiveCfg = Release|Any CPU
{240BE72A-D56C-4172-9CCD-BFE133670546}.Release|Any CPU.Build.0 = Release|Any CPU
+ {532B2F15-163D-486B-908B-3ABB360C45FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {532B2F15-163D-486B-908B-3ABB360C45FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {532B2F15-163D-486B-908B-3ABB360C45FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {532B2F15-163D-486B-908B-3ABB360C45FA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/invoke.build.ps1 b/invoke.build.ps1
index 98deb56..5fe072e 100644
--- a/invoke.build.ps1
+++ b/invoke.build.ps1
@@ -1,4 +1,4 @@
-# Install PowerShell for your platform:
+# Install PowerShell Core:
# https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell
# Install Invoke-Build:
# https://github.com/nightroman/Invoke-Build
@@ -7,6 +7,16 @@
# Invoke-Build build
# Invoke-Build ? # this lists available tasks
+param (
+ $NuGetApiPushKey = ( property NuGetApiPushKey 'MISSING' ),
+ $LocalPackageDir = ( property LocalPackageDir 'C:\code\LocalPackages' )
+)
+
+$baseProjectName = "BinaryToTextEncoding"
+$basePackageName = "Zanaptak.$baseProjectName"
+
+task . Build
+
task Clean {
exec { dotnet clean .\src -c Release }
}
@@ -15,12 +25,9 @@ task Build {
exec { dotnet build .\src -c Release }
}
-task Pack Clean, Build, {
- exec { dotnet pack .\src -c Release }
-}
-
task TestJs {
Set-Location .\test
+ if ( -not ( Test-Path node_modules ) ) { exec { npm install } }
remove bld
exec { npm test }
}
@@ -34,7 +41,97 @@ task Test TestJs, TestNet
task Benchmark Clean, Build, {
Set-Location .\benchmark
- exec { dotnet run -p BinaryToTextEncoding.Benchmark.fsproj -c Release }
+ exec { dotnet run -c Release }
}
-task . Build
+task Pack Clean, Build, {
+ exec { dotnet pack .\src -c Release }
+}
+
+task PackInternal Clean, Build, GetVersion, {
+ $yearStart = Get-Date -Year ( ( Get-Date ).Year ) -Month 1 -Day 1 -Hour 0 -Minute 0 -Second 0 -Millisecond 0
+ $now = Get-Date
+ $buildSuffix = [ int ] ( ( $now - $yearStart ).TotalSeconds )
+ $internalVersion = "$Version.$buildSuffix"
+ exec { dotnet pack .\src -c Release -p:PackageVersion=$internalVersion }
+ $filename = "$basePackageName.$internalVersion.nupkg"
+ Copy-Item .\src\bin\Release\$filename $LocalPackageDir
+ Write-Build Green "Copied $filename to $LocalPackageDir"
+}
+
+function UpdateProjectFile(
+ [ string ] $Filename ,
+ [ string ] $XPath ,
+ [ string ] $Value
+) {
+
+ $xml = New-Object System.Xml.XmlDocument
+ $xml.PreserveWhitespace = $true
+ $xml.Load( $Filename )
+
+ $node = $xml.SelectSingleNode( $XPath )
+ if ( -not ( $node ) ) { throw "xpath not found" }
+ $node.InnerText = $Value
+
+ $settings = New-Object System.Xml.XmlWriterSettings
+ $settings.OmitXmlDeclaration = $true
+ $settings.Encoding = New-Object System.Text.UTF8Encoding( $true )
+
+ $writer = [ System.Xml.XmlWriter ]::Create( $Filename , $settings )
+ try {
+ $xml.Save( $writer )
+ } finally {
+ $writer.Dispose()
+ }
+}
+
+task IncrementMinor GetVersion, {
+ if ( $Version -match "^(\d+)\.(\d+)\.(\d+)$" ) {
+ $projectFile = "$BuildRoot\src\$baseProjectName.fsproj"
+ $major = $Matches[ 1 ]
+ $minor = $Matches[ 2 ]
+ $patch = $Matches[ 3 ]
+ $newMinor = ( [ int ] $minor ) + 1
+ $newVersion = "$major.$newMinor.0"
+ UpdateProjectFile $projectFile '/Project/PropertyGroup/Version' $newVersion
+ Write-Build Green "Updated version to $newVersion"
+ }
+ else {
+ throw "invalid version: $Version"
+ }
+}
+
+task IncrementPatch GetVersion, {
+ if ( $Version -match "^(\d+)\.(\d+)\.(\d+)$" ) {
+ $projectFile = "$BuildRoot\src\$baseProjectName.fsproj"
+ $major = $Matches[ 1 ]
+ $minor = $Matches[ 2 ]
+ $patch = $Matches[ 3 ]
+ $newPatch = ( [ int ] $patch ) + 1
+ $newVersion = "$major.$minor.$newPatch"
+ UpdateProjectFile $projectFile '/Project/PropertyGroup/Version' $newVersion
+ Write-Build Green "Updated version to $newVersion"
+ }
+ else {
+ throw "invalid version: $Version"
+ }
+}
+
+task GetVersion {
+ $script:Version = Select-Xml -Path ".\src\$baseProjectName.fsproj" -XPath /Project/PropertyGroup/Version | % { $_.Node.InnerXml.Trim() }
+}
+
+task UploadNuGet EnsureCommitted, GetVersion, {
+ if ( $NuGetApiPushKey -eq "MISSING" ) { throw "NuGet key not provided" }
+ Set-Location ./src/bin/Release
+ $filename = "$basePackageName.$Version.nupkg"
+ if ( -not ( Test-Path $filename ) ) { throw "nupkg file not found" }
+ $lastHour = ( Get-Date ).AddHours( -1 )
+ if ( ( Get-ChildItem $filename ).LastWriteTime -lt $lastHour ) { throw "nupkg file too old" }
+ exec { dotnet nuget push $filename -k $NuGetApiPushKey -s https://api.nuget.org/v3/index.json }
+}
+
+task EnsureCommitted {
+ $gitoutput = exec { git status -s -uall }
+ if ( $gitoutput ) { throw "uncommitted changes exist in working directory" }
+}
diff --git a/src/BinaryToTextEncoding.fsproj b/src/BinaryToTextEncoding.fsproj
index 22ea1b3..ad1d9f1 100644
--- a/src/BinaryToTextEncoding.fsproj
+++ b/src/BinaryToTextEncoding.fsproj
@@ -1,14 +1,15 @@
-
+
netstandard2.0;net452
true
- 0.1.0
+ 0.1.1
zanaptak
Zanaptak.BinaryToTextEncoding
Zanaptak.BinaryToTextEncoding
Zanaptak.BinaryToTextEncoding
https://github.com/zanaptak/BinaryToTextEncoding.git
+ git
https://github.com/zanaptak/BinaryToTextEncoding
https://github.com/zanaptak/BinaryToTextEncoding/releases
base16;base32;base46;base64;base91;.net;fable
@@ -16,6 +17,10 @@
A binary-to-text encoder/decoder library for .NET and Fable. Provides base 16, base 32, base 46, base 64, and base 91 codecs. Supports custom character sets.
+
+ bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml
+
+
diff --git a/src/BinaryToTextEncoding.sln b/src/BinaryToTextEncoding.sln
index 39c6e08..bebd1dd 100644
--- a/src/BinaryToTextEncoding.sln
+++ b/src/BinaryToTextEncoding.sln
@@ -3,7 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29215.179
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "BinaryToTextEncoding", "BinaryToTextEncoding.fsproj", "{B01382CA-436B-40B7-B347-337D93EC988E}"
+Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "BinaryToTextEncoding", "BinaryToTextEncoding.fsproj", "{B01382CA-436B-40B7-B347-337D93EC988E}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1B4C18F3-6372-43F6-B3E0-2BED8FCAC0C7}"
+ ProjectSection(SolutionItems) = preProject
+ ..\invoke.build.ps1 = ..\invoke.build.ps1
+ ..\README.md = ..\README.md
+ EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution