Skip to content

Commit 1fb1e40

Browse files
committed
Enable xml doc file
1 parent c76796c commit 1fb1e40

File tree

7 files changed

+132
-17
lines changed

7 files changed

+132
-17
lines changed

.editorconfig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
root = true
22

33
[*]
4+
charset = utf-8
45
indent_style = space
56
indent_size = 2
6-
charset = utf-8
77
trim_trailing_whitespace = true
88
insert_final_newline = true
9+
10+
[*.{sln,fsproj,csproj,vbproj}]
11+
charset = utf-8-bom

benchmark/BinaryToTextEncoding.Benchmark.fsproj

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,19 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.2</TargetFramework>
5+
<TargetFramework>netcoreapp3.0</TargetFramework>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<Compile Include="Program.fs" />
9+
<Compile Include="Benchmark.fs" />
1010
</ItemGroup>
1111

1212
<ItemGroup>
1313
<PackageReference Include="BenchmarkDotNet" Version="0.11.5" />
1414
</ItemGroup>
1515

1616
<ItemGroup>
17-
<Reference Include="Zanaptak.BinaryToTextEncoding">
18-
<HintPath>..\src\bin\Release\netstandard2.0\Zanaptak.BinaryToTextEncoding.dll</HintPath>
19-
</Reference>
17+
<ProjectReference Include="..\src\BinaryToTextEncoding.fsproj" />
2018
</ItemGroup>
2119

2220
</Project>

benchmark/BinaryToTextEncoding.Benchmark.sln

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 16
44
VisualStudioVersion = 16.0.29230.47
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "BinaryToTextEncoding.Benchmark", "BinaryToTextEncoding.Benchmark.fsproj", "{240BE72A-D56C-4172-9CCD-BFE133670546}"
6+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "BinaryToTextEncoding.Benchmark", "BinaryToTextEncoding.Benchmark.fsproj", "{240BE72A-D56C-4172-9CCD-BFE133670546}"
7+
EndProject
8+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "BinaryToTextEncoding", "..\src\BinaryToTextEncoding.fsproj", "{532B2F15-163D-486B-908B-3ABB360C45FA}"
79
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,6 +17,10 @@ Global
1517
{240BE72A-D56C-4172-9CCD-BFE133670546}.Debug|Any CPU.Build.0 = Debug|Any CPU
1618
{240BE72A-D56C-4172-9CCD-BFE133670546}.Release|Any CPU.ActiveCfg = Release|Any CPU
1719
{240BE72A-D56C-4172-9CCD-BFE133670546}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{532B2F15-163D-486B-908B-3ABB360C45FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{532B2F15-163D-486B-908B-3ABB360C45FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{532B2F15-163D-486B-908B-3ABB360C45FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{532B2F15-163D-486B-908B-3ABB360C45FA}.Release|Any CPU.Build.0 = Release|Any CPU
1824
EndGlobalSection
1925
GlobalSection(SolutionProperties) = preSolution
2026
HideSolutionNode = FALSE

invoke.build.ps1

Lines changed: 104 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Install PowerShell for your platform:
1+
# Install PowerShell Core:
22
# https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell
33
# Install Invoke-Build:
44
# https://github.com/nightroman/Invoke-Build
@@ -7,6 +7,16 @@
77
# Invoke-Build build
88
# Invoke-Build ? # this lists available tasks
99

10+
param (
11+
$NuGetApiPushKey = ( property NuGetApiPushKey 'MISSING' ),
12+
$LocalPackageDir = ( property LocalPackageDir 'C:\code\LocalPackages' )
13+
)
14+
15+
$baseProjectName = "BinaryToTextEncoding"
16+
$basePackageName = "Zanaptak.$baseProjectName"
17+
18+
task . Build
19+
1020
task Clean {
1121
exec { dotnet clean .\src -c Release }
1222
}
@@ -15,12 +25,9 @@ task Build {
1525
exec { dotnet build .\src -c Release }
1626
}
1727

18-
task Pack Clean, Build, {
19-
exec { dotnet pack .\src -c Release }
20-
}
21-
2228
task TestJs {
2329
Set-Location .\test
30+
if ( -not ( Test-Path node_modules ) ) { exec { npm install } }
2431
remove bld
2532
exec { npm test }
2633
}
@@ -34,7 +41,97 @@ task Test TestJs, TestNet
3441

3542
task Benchmark Clean, Build, {
3643
Set-Location .\benchmark
37-
exec { dotnet run -p BinaryToTextEncoding.Benchmark.fsproj -c Release }
44+
exec { dotnet run -c Release }
3845
}
3946

40-
task . Build
47+
task Pack Clean, Build, {
48+
exec { dotnet pack .\src -c Release }
49+
}
50+
51+
task PackInternal Clean, Build, GetVersion, {
52+
$yearStart = Get-Date -Year ( ( Get-Date ).Year ) -Month 1 -Day 1 -Hour 0 -Minute 0 -Second 0 -Millisecond 0
53+
$now = Get-Date
54+
$buildSuffix = [ int ] ( ( $now - $yearStart ).TotalSeconds )
55+
$internalVersion = "$Version.$buildSuffix"
56+
exec { dotnet pack .\src -c Release -p:PackageVersion=$internalVersion }
57+
$filename = "$basePackageName.$internalVersion.nupkg"
58+
Copy-Item .\src\bin\Release\$filename $LocalPackageDir
59+
Write-Build Green "Copied $filename to $LocalPackageDir"
60+
}
61+
62+
function UpdateProjectFile(
63+
[ string ] $Filename ,
64+
[ string ] $XPath ,
65+
[ string ] $Value
66+
) {
67+
68+
$xml = New-Object System.Xml.XmlDocument
69+
$xml.PreserveWhitespace = $true
70+
$xml.Load( $Filename )
71+
72+
$node = $xml.SelectSingleNode( $XPath )
73+
if ( -not ( $node ) ) { throw "xpath not found" }
74+
$node.InnerText = $Value
75+
76+
$settings = New-Object System.Xml.XmlWriterSettings
77+
$settings.OmitXmlDeclaration = $true
78+
$settings.Encoding = New-Object System.Text.UTF8Encoding( $true )
79+
80+
$writer = [ System.Xml.XmlWriter ]::Create( $Filename , $settings )
81+
try {
82+
$xml.Save( $writer )
83+
} finally {
84+
$writer.Dispose()
85+
}
86+
}
87+
88+
task IncrementMinor GetVersion, {
89+
if ( $Version -match "^(\d+)\.(\d+)\.(\d+)$" ) {
90+
$projectFile = "$BuildRoot\src\$baseProjectName.fsproj"
91+
$major = $Matches[ 1 ]
92+
$minor = $Matches[ 2 ]
93+
$patch = $Matches[ 3 ]
94+
$newMinor = ( [ int ] $minor ) + 1
95+
$newVersion = "$major.$newMinor.0"
96+
UpdateProjectFile $projectFile '/Project/PropertyGroup/Version' $newVersion
97+
Write-Build Green "Updated version to $newVersion"
98+
}
99+
else {
100+
throw "invalid version: $Version"
101+
}
102+
}
103+
104+
task IncrementPatch GetVersion, {
105+
if ( $Version -match "^(\d+)\.(\d+)\.(\d+)$" ) {
106+
$projectFile = "$BuildRoot\src\$baseProjectName.fsproj"
107+
$major = $Matches[ 1 ]
108+
$minor = $Matches[ 2 ]
109+
$patch = $Matches[ 3 ]
110+
$newPatch = ( [ int ] $patch ) + 1
111+
$newVersion = "$major.$minor.$newPatch"
112+
UpdateProjectFile $projectFile '/Project/PropertyGroup/Version' $newVersion
113+
Write-Build Green "Updated version to $newVersion"
114+
}
115+
else {
116+
throw "invalid version: $Version"
117+
}
118+
}
119+
120+
task GetVersion {
121+
$script:Version = Select-Xml -Path ".\src\$baseProjectName.fsproj" -XPath /Project/PropertyGroup/Version | % { $_.Node.InnerXml.Trim() }
122+
}
123+
124+
task UploadNuGet EnsureCommitted, GetVersion, {
125+
if ( $NuGetApiPushKey -eq "MISSING" ) { throw "NuGet key not provided" }
126+
Set-Location ./src/bin/Release
127+
$filename = "$basePackageName.$Version.nupkg"
128+
if ( -not ( Test-Path $filename ) ) { throw "nupkg file not found" }
129+
$lastHour = ( Get-Date ).AddHours( -1 )
130+
if ( ( Get-ChildItem $filename ).LastWriteTime -lt $lastHour ) { throw "nupkg file too old" }
131+
exec { dotnet nuget push $filename -k $NuGetApiPushKey -s https://api.nuget.org/v3/index.json }
132+
}
133+
134+
task EnsureCommitted {
135+
$gitoutput = exec { git status -s -uall }
136+
if ( $gitoutput ) { throw "uncommitted changes exist in working directory" }
137+
}

src/BinaryToTextEncoding.fsproj

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
55
<DisableImplicitSystemValueTupleReference>true</DisableImplicitSystemValueTupleReference>
6-
<Version>0.1.0</Version>
6+
<Version>0.1.1</Version>
77
<Authors>zanaptak</Authors>
88
<AssemblyName>Zanaptak.BinaryToTextEncoding</AssemblyName>
99
<Product>Zanaptak.BinaryToTextEncoding</Product>
1010
<PackageId>Zanaptak.BinaryToTextEncoding</PackageId>
1111
<RepositoryUrl>https://github.com/zanaptak/BinaryToTextEncoding.git</RepositoryUrl>
12+
<RepositoryType>git</RepositoryType>
1213
<PackageProjectUrl>https://github.com/zanaptak/BinaryToTextEncoding</PackageProjectUrl>
1314
<PackageReleaseNotes>https://github.com/zanaptak/BinaryToTextEncoding/releases</PackageReleaseNotes>
1415
<PackageTags>base16;base32;base46;base64;base91;.net;fable</PackageTags>
1516
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1617
<Description>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.</Description>
1718
</PropertyGroup>
1819

20+
<PropertyGroup>
21+
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
22+
</PropertyGroup>
23+
1924
<ItemGroup>
2025
<Compile Include="Utils.fs" />
2126
<Compile Include="Base16.fs" />

src/BinaryToTextEncoding.sln

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 16
44
VisualStudioVersion = 16.0.29215.179
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "BinaryToTextEncoding", "BinaryToTextEncoding.fsproj", "{B01382CA-436B-40B7-B347-337D93EC988E}"
6+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "BinaryToTextEncoding", "BinaryToTextEncoding.fsproj", "{B01382CA-436B-40B7-B347-337D93EC988E}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1B4C18F3-6372-43F6-B3E0-2BED8FCAC0C7}"
9+
ProjectSection(SolutionItems) = preProject
10+
..\invoke.build.ps1 = ..\invoke.build.ps1
11+
..\README.md = ..\README.md
12+
EndProjectSection
713
EndProject
814
Global
915
GlobalSection(SolutionConfigurationPlatforms) = preSolution

0 commit comments

Comments
 (0)