Merge pull request #75 from gep13/ChocolateyPackage

Adding basic creation of Chocolatey Package
This commit is contained in:
Martin Woodward 2015-12-17 09:40:37 +00:00
commit 96b67a4063
4 changed files with 95 additions and 0 deletions

View File

@ -0,0 +1,26 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>openlivewriter</id>
<version>0.5.0.0</version>
<title>OpenLiveWriter (Install)</title>
<authors>See list of authors at http://openlivewriter.org/</authors>
<owners>Darwin Sanoy, OpenLiveWriter</owners>
<licenseUrl>https://github.com/OpenLiveWriter/OpenLiveWriter/blob/master/license.txt</licenseUrl>
<projectUrl>http://openlivewriter.org/</projectUrl>
<iconUrl>https://cdn.rawgit.com/csi-windowschocolatey/openlivewriter/master/app.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Open Live Writer is an open source application enabling users to author, edit, and publish blog posts.
It is based on a fork of the well-loved but not actively developed Windows Live Writer code.</description>
<summary>Open Live Writer makes it easy to write, preview, and post to your blog.</summary>
<copyright>.NET Foundation</copyright>
<tags>Blog WindowsLiveWriter OpenLiveWriter</tags>
<releaseNotes>https://github.com/OpenLiveWriter/OpenLiveWriter/releases</releaseNotes>
<!--<projectSourceUrl>https://github.com/OpenLiveWriter</projectSourceUrl>-->
</metadata>
<files>
<file src="OpenLiveWriterSetup.exe" target="tools" />
<file src="..\choco\chocolateyInstall.ps1" target="tools"/>
<file src="..\choco\chocolateyUninstall.ps1" target="tools"/>
</files>
</package>

View File

@ -0,0 +1,9 @@
$packageName= 'openlivewriter'
$fileType = 'EXE'
$silentArgs = '--silent'
$scriptPath = $(Split-Path $MyInvocation.MyCommand.Path)
$fileFullPath = Join-Path $scriptPath 'OpenLiveWriterSetup.exe'
Install-ChocolateyInstallPackage $packageName $fileType $silentArgs $fileFullPath
Write-Output "The install log is at `"$env:localappdata\SquirrelTemp\SquirrelSetup.log`""

View File

@ -0,0 +1,56 @@
$ErrorActionPreference = 'Stop';
$packageName = 'openlivewriter'
$softwareName = 'open live writer*'
$installerType = 'EXE'
$file = "$env:localappdata\OpenLiveWriter\Update.exe"
$silentArgs = '--uninstall -s'
if ($installerType -ne 'MSI') {
$validExitCodes = @(0)
}
$uninstalled = $false
$local_key = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*'
$machine_key = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*'
$machine_key6432 = 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
$key = Get-ItemProperty -Path @($machine_key6432,$machine_key, $local_key) `
-ErrorAction SilentlyContinue `
| ? { $_.DisplayName -like "$softwareName" }
if (!(Test-Path "$env:localappdata\openlivewriter\openlivewriter.exe"))
{
If (!(Test-Path $file))
{
throw "Could not find $file - because this software is always installed to a user profile folder, it must be uninstalled in the context of the user who installed it."
}
else
{
Try {
Uninstall-ChocolateyPackage -PackageName $packageName `
-FileType $installerType `
-SilentArgs "$silentArgs" `
-ValidExitCodes $validExitCodes `
-File "$file"
#Remove leftovers so new install will succeed
If (test-path "$env:localappdata\openlivewriter\.dead")
{
remove-item "$env:localappdata\openlivewriter" -Recurse -Force -ErrorAction 'SilentlyContinue'
}
If (test-path "C:\ProgramData\SquirrelMachineInstalls\OpenLiveWriter.exe")
{
remove-item "C:\ProgramData\SquirrelMachineInstalls\OpenLiveWriter.exe" -Force -ErrorAction 'SilentlyContinue'
}
Write-Output "The install log is at `"$env:localappdata\SquirrelTemp\SquirrelSetup.log`""
}
Catch
{
throw $_.Exception
}
}
} else {
Write-Warning "$packageName has already been uninstalled by other means or it is installed to a user's profile who is not the current user ($env:username)."
}

View File

@ -22,5 +22,9 @@ ECHO Created Writer NuGet package.
MOVE .\Releases\Setup.exe .\Releases\OpenLiveWriterSetup.exe
ECHO Created Open Live Writer setup file.
%LocalAppData%\Nuget\Nuget.exe pack .\OpenLiveWriter.Install.nuspec -version %dottedVersion% -basepath Releases
ECHO Created Writer Chocolatey Package
:end
POPD