Skip to content

Commit

Permalink
Enable xml doc file
Browse files Browse the repository at this point in the history
  • Loading branch information
zanaptak committed Sep 29, 2019
1 parent c76796c commit 1fb1e40
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 17 deletions.
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
8 changes: 3 additions & 5 deletions benchmark/BinaryToTextEncoding.Benchmark.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="Program.fs" />
<Compile Include="Benchmark.fs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.11.5" />
</ItemGroup>

<ItemGroup>
<Reference Include="Zanaptak.BinaryToTextEncoding">
<HintPath>..\src\bin\Release\netstandard2.0\Zanaptak.BinaryToTextEncoding.dll</HintPath>
</Reference>
<ProjectReference Include="..\src\BinaryToTextEncoding.fsproj" />
</ItemGroup>

</Project>
8 changes: 7 additions & 1 deletion benchmark/BinaryToTextEncoding.Benchmark.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
111 changes: 104 additions & 7 deletions invoke.build.ps1
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 }
}
Expand All @@ -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 }
}
Expand All @@ -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" }
}
9 changes: 7 additions & 2 deletions src/BinaryToTextEncoding.fsproj
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
<DisableImplicitSystemValueTupleReference>true</DisableImplicitSystemValueTupleReference>
<Version>0.1.0</Version>
<Version>0.1.1</Version>
<Authors>zanaptak</Authors>
<AssemblyName>Zanaptak.BinaryToTextEncoding</AssemblyName>
<Product>Zanaptak.BinaryToTextEncoding</Product>
<PackageId>Zanaptak.BinaryToTextEncoding</PackageId>
<RepositoryUrl>https://github.com/zanaptak/BinaryToTextEncoding.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageProjectUrl>https://github.com/zanaptak/BinaryToTextEncoding</PackageProjectUrl>
<PackageReleaseNotes>https://github.com/zanaptak/BinaryToTextEncoding/releases</PackageReleaseNotes>
<PackageTags>base16;base32;base46;base64;base91;.net;fable</PackageTags>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<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>
</PropertyGroup>

<PropertyGroup>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
</PropertyGroup>

<ItemGroup>
<Compile Include="Utils.fs" />
<Compile Include="Base16.fs" />
Expand Down
8 changes: 7 additions & 1 deletion src/BinaryToTextEncoding.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1fb1e40

Please sign in to comment.