for packaging modules I wrote this powershell script for use on windows as a post build activity in visual studio:
oh and you need to edit the files in the solution to contain !Release Date! and !Version!
[CmdLetBinding()]
param
(
[Parameter(Mandatory = $true, Position = 0)]
[string]$TargetDir,
[Parameter(Mandatory = $true, Position = 1)]
[string]$ProjectName,
[Parameter(Mandatory = $true, Position = 2)]
[string]$TargetFileName,
[Parameter(Mandatory = $true, Position = 3)]
[string]$ProjectDir
)
$TargetDir = $TargetDir.Replace('"',"")
$ProjectDir = $ProjectDir.Trim()
function Test-Net45 {
if (Test-Path ‘HKLM:SOFTWAREMicrosoftNET Framework SetupNDPv4Full’) {
if (Get-ItemProperty ‘HKLM:SOFTWAREMicrosoftNET Framework SetupNDPv4Full’ -Name Release -ErrorAction SilentlyContinue) {
return $True
}
return $False
}
}
Write-Host "Target Dir: $($TargetDir)"
Write-Host "Project Name: $($ProjectName)"
Write-Host "Project Dir: $($ProjectDir)"
Write-Host "Target File Name: $($TargetFileName)"
if (Test-Net45 -eq $false) {Write-Error ".Net 4.5 is required to create the archive." -ErrorAction stop}
Add-Type -assembly "system.io.compression.filesystem" -ErrorAction stop
$destination = "$($ProjectDir)Output\$($ProjectName).zip"
# Determine Assembly version to version the interface
$file = "$($TargetDir)\$($TargetFileName)"
$ass = [System.Reflection.Assembly]::LoadFile($file)
$v = $ass.GetName().Version;
$version = [string]::Format("{0}.{1:00}.{2:00}.{3}",$v.Major, $v.Minor, $v.Build, $v.Revision)
write-host "DLL $file Version is: $version"
# Replace Date and Version in Package.json
(Get-Content "$TargetDir\Package.json").replace('!RELEASE DATE!', (Get-Date)) | Set-Content "$TargetDir\Package.json"
(Get-Content "$TargetDir\Package.json").replace('!VERSION!', $version) | Set-Content "$TargetDir\Package.json"
# Replace Date and Version in Readme.TXT
(Get-Content "$TargetDir\Readme.TXT").replace('!RELEASE DATE!', (Get-Date)) | Set-Content "$TargetDir\Readme.TXT"
(Get-Content "$TargetDir\Readme.TXT").replace('!VERSION!', $version) | Set-Content "$TargetDir\Readme.TXT"
If(Test-path $destination) {
Write-Host "Removing existing interface archive"
Remove-item $destination -Verbose -Force
}
# Create interface archive
[io.compression.zipfile]::CreateFromDirectory($TargetDir, $destination)
Write-Host "`nInterface zip created at: $($destination)`n"
#If(Test-path "$($ProjectDir)\Output\TexecomWidget.zip") {
# Write-Host "Removing existing widget archive"
# Remove-item "$($ProjectDir)\Output\TexecomWidget.zip"
#}
# Create widget archive
#[io.compression.zipfile]::CreateFromDirectory("$($ProjectDir)TexecomWidget", "$($ProjectDir)Output\TexecomWidget.zip")
#Write-Host "`n Widget zip created at: $($ProjectDir)Output\TexecomWidget.zip`n"
#if $(ConfigurationName) == Release (
# Rem TODO: Push Release to public repository
#)
# Inteface.Import
Then in post build activities (properties on interface project, then Build Events, and in Post-build event command line add:
powershell.exe -executionPolicy Bypass -file "$(SolutionDir)package.ps1" -ProjectDir "$(ProjectDir) " -ProjectName "$(ProjectName)" -TargetFileName "$(TargetFileName)" -TargetDir "$(TargetDir)"
Next step is to suss the interface api commands to disable existing interface, import this one and enable..
David