The sign library adds a PowerShell module for handling various tasks
Is an Extension Module to the Meriworks.PowerShell.BuildEvents .
The following commands are defined in this module.
- Invoke-Robocopy
- Invoke-XmlTransform
- Import-MarkdownSamples
- Convert-MarkdownToHtml
- Set-AssemblyInfoVersion
- Set-NuspecVersion
- Get-ProjectVersion
- Get-ProjectSemanticVersion
- Get-VersionData
- Get-BuildVersion
- Format-Version
When running a robocopy command from a powershell script it can cause havoc when it comes to the exit code set by the robocopy command. Normally an exit code of 0 indicates that a command went well and 1 indicates that an error occurred. Robocopy has redefined this list http://ss64.com/nt/robocopy-exit.html and to avoid a successful robocopy command indicating the PowerShell exit code incorrect as a failure, we can use the invoke-robocopy
powershell command instead.
It has the same parameters as the Robocopy command and only handles the exit code. If any error occur, it will throw an error.
invoke-robocopy "bin\$configuration\help" "bin\$configuration\html_old\reference" /s
Xml transformation is used to apply an xdt template on to an xml file.
The function takes the following parameters
- xml - path to the Xml document that should be merged
- xdt - path to the Xtd document contaning the data to be merged
- replaceVariables - (optional) If true, replaces some variables in the xdt file before merge with their respective values
Currently supports:
- $(ProjectDir)
- $(SolutionDir)
- $(ConfigBuilderHost)
invoke-XmlTransform "$projectDir\web.config" "$projectDir\myweb.config.xdt"
This cmdlet will expand code samples and api references in the supplied markdown file. The cmdlet takes the following parameters
-
Filename - the path to the markdown file to expand samples in
-
RootPath - the path to the folder who acts as root for the markdown structure
-
HtmlHelpPath - the relative path (from RootPath) to where the API reference resides
Import-MarkdownSamples -Filename $file.FullName -RootPath $targetDir -HtmlHelpPath "reference/html"
This cmdlet will convert a markdown file to Html. The cmdlet takes the following parameters.
-
InputFile - the path to the markdown file to convert
-
OutputFile - the path to the output html file
-
TemplateFile - the name of the template file to use. The closest template found will be used (seaching from the current dir and up).
Convert-MarkdownToHtml -InputFile $file.FullName -OutputFile $outFile -TemplateFile $templateFile
Sets the versions on the AssemblyInfo.cs file according to the supplied $version object. Looks in the Properties folder of the project for the AssemblyInfo.cs file
-
version - object with three properties:
- assemblyInfoVersion - string to set as assemblyVersion. ie. 1.1.4.0
- fileVersion - string to set as fileVersion. ie. 1.1.4.252
- informationalVersion - string to set as informationalVersion. ie 1.1.4-beta
If no version is suppled, the Get-ProjectVersion method is invoked
Example
$version = @{ assemblyVersion = "1.1.0.0", fileVersion = "1.1.0.131", informationalVersion = "1.1.0-beta" }
Set-AssemblyInfoVersion -version $version
Sets the version element of the nuspec file to the supplied version string
- path - Path to the nuspec file to modify
- nuspecversion - the version string to set. If omitted, the version is calculated using the Get-ProjectSemanticVersion
Example
Set-NuspecVersion -path (join-path $projectDir "myproj.nuspec") -nuspecversion "1.0.1"
Gets the version object for the current project. See Get-VersionData for more information.
Gets the Semantic version for the project (major.minor.patch). Based on the assemblyVersion from the Get-ProjectVersion
Gets the version object for the supplied directory. First calls Get-BuildVersion to get the current version for the build. Then looks for the nearest version.json file that expects a json object with three properties assemblyVersion, fileVersion, informationalVersion. Each of these properties are patterns on how to format the specific version string.
Get-VersionData "c:\myFolder\mySubfolder"
Example of a version.json file
{
"assemblyInfo" : "9.*.*.0",
"fileVersion" : "9.*.*.*",
"informationalVersion" : "9.*.*"
}
Pattern in version.json file matches the ver entity in the Format-Version BNF.
Looks in the supplied directory for a buildVersion.txt file. If none is found, it continues to search upwards in the supplied path. The buildversion.txt file is expected to contain a version string on the format major.minor.patch.build If no buildVersion.txt is found, an exception is thrown.
Get-BuildVersion "c:\myFolder\mySubfolder"
Combines the supplied baseVersion with a ver format that controls the resulting format.
- baseVersion - version string on the format major.minor.patch.build,
- ver - version pattern string on the format pattern.pattern.pattern[.pattern]
Example usage:
ps> Format-Version -baseVersion "1.4.244.2331" -ver "6.*.*"
6.4.244
<baseVersion> ::= <number>.<number>.<number>.<number>
<ver> ::= <patternNumber>.<patternNumber>.<patternNumber>[.<patternNumber>]
<number> ::= 1*<digit>
<patternNumber> ::= <number>|<wildcard>
<digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
<wildcard> ::= "*"
Licensed using the MIT License.
Developed by Dan Händevik, Meriworks.
Includes a modified version of MarkdownSharp
Markdown is a text-to-HTML conversion tool for web writers
Copyright (c) 2004 John Gruber http://daringfireball.net/projects/markdown/
Copyright (c) 2004-2009 Milan Negovan http://www.aspnetresources.com http://aspnetresources.com/blog/markdown_announced.aspx
Copyright (c) 2009-2010 Jeff Atwood http://stackoverflow.com http://www.codinghorror.com/blog/ http://code.google.com/p/markdownsharp/
History: Milan ported the Markdown processor to C#. He granted license to Jeff so he can open source it and let the community contribute to and improve MarkdownSharp.
- Removed lib from Meriworks.PowerShell nuget package
- Fix issue with some specific backtick blocks
- Migrated to Azure Pipelines
- Upgraded tests to nunit 3
- Removed support for sandcastle links in favour for docfx links in markdown files. #5
- Add html for heading links #4
-
Added support for heading id:s #3 A heading will now include a id attribute which value represents the hierarchial heading structure.
Example:
# Main heading ## Sub heading
Will produce the following HTML.
<h1 id="main-heading">Main heading</h1> <h2 id="main-heading/sub-heading">Sub heading</h2>
The id value will be based on the actual heading value where characters other than letters, digits or any of the following characters -._~:@!$,;*' will be replaced with a - (dash)
You can then link to a specific heading by using the id in the link. Example
[See sub heading](#main-heading/sub-heading)
- Fixed issue #2 with multiple backtick code blocks on same page.
-
Fixed issue with embedded markdown not escaped inside code blocks (```)
#test
-
Exported MarkdownSharp modification as separate nuget package, Meriworks.Markdown
Markdown now support deleted text blocks using (~deleted text~)
deleted text
Markdown now support code blocks with three backticks
code block
Some indented row
Markdown tables now adds nowrap to a column when a header separator contains of = instead of -
A set of commands related to maintaining version numbers added
- Set-AssemblyInfoVersion
- Set-NuspecVersion
- Get-ProjectVersion
- Get-ProjectSemanticVersion
- Get-VersionData
- Get-BuildVersion
- Format-Version
- Invoke-XmlTransform function added
- Invoke-Robocopy replaces Run-Robocopy #1
- Initial public release