|
| 1 | +# IMPORTANT: Before releasing this package, copy/paste the next 2 lines into PowerShell to remove all comments from this file: |
| 2 | +# $f='c:\path\to\thisFile.ps1' |
| 3 | +# gc $f | ? {$_ -notmatch "^\s*#"} | % {$_ -replace '(^.*?)\s*?[^``]#.*','$1'} | Out-File $f+".~" -en utf8; mv -fo $f+".~" $f |
| 4 | + |
| 5 | +$ErrorActionPreference = 'Stop'; # stop on all errors |
| 6 | + |
| 7 | +$packageName= 'usecasemaker' # arbitrary name for the package, used in messages |
| 8 | +$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" |
| 9 | +$url = 'https://github.com/hsharpsoftware/use-case-maker/releases/download/v2.0.0.3/setup.exe' # download url, HTTPS preferred |
| 10 | +$url64 = 'https://github.com/hsharpsoftware/use-case-maker/releases/download/v2.0.0.3/setup.exe' # 64bit URL here (HTTPS preferred) or remove - if installer contains both (very rare), use $url |
| 11 | +#$fileLocation = Join-Path $toolsDir 'NAME_OF_EMBEDDED_INSTALLER_FILE' |
| 12 | +#$fileLocation = '\\SHARE_LOCATION\to\INSTALLER_FILE' |
| 13 | + |
| 14 | +$packageArgs = @{ |
| 15 | + packageName = $packageName |
| 16 | + unzipLocation = $toolsDir |
| 17 | + fileType = 'exe' #only one of these: exe, msi, msu |
| 18 | + url = $url |
| 19 | + url64bit = $url64 |
| 20 | + #file = $fileLocation |
| 21 | + |
| 22 | + softwareName = 'Use Case Maker' #part or all of the Display Name as you see it in Programs and Features. It should be enough to be unique |
| 23 | + |
| 24 | + # Checksums are now required as of 0.10.0. |
| 25 | + # To determine checksums, you can get that from the original site if provided. |
| 26 | + # You can also use checksum.exe (choco install checksum) and use it |
| 27 | + # e.g. checksum -t sha256 -f path\to\file |
| 28 | + checksum = '2B58142B9D3D87C41AE8178CBF5280070368D1D06D8D3BE9D833D2E8273B1A80' |
| 29 | + checksumType = 'sha256' #default is md5, can also be sha1, sha256 or sha512 |
| 30 | + checksum64 = '2B58142B9D3D87C41AE8178CBF5280070368D1D06D8D3BE9D833D2E8273B1A80' |
| 31 | + checksumType64= 'sha256' #default is checksumType |
| 32 | + |
| 33 | + #MSI |
| 34 | + #silentArgs = "/qn /norestart /l*v `"$($env:TEMP)\$($packageName).$($env:chocolateyPackageVersion).MsiInstall.log`"" # ALLUSERS=1 DISABLEDESKTOPSHORTCUT=1 ADDDESKTOPICON=0 ADDSTARTMENU=0 |
| 35 | + validExitCodes= @(0, 3010, 1641) |
| 36 | + #OTHERS |
| 37 | + # Uncomment matching EXE type (sorted by most to least common) |
| 38 | + #silentArgs = '/S' # NSIS |
| 39 | + #silentArgs = '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-' # Inno Setup |
| 40 | + #silentArgs = '/s' # InstallShield |
| 41 | + #silentArgs = '/s /v"/qn"' # InstallShield with MSI |
| 42 | + #silentArgs = '/s' # Wise InstallMaster |
| 43 | + #silentArgs = '-s' # Squirrel |
| 44 | + #silentArgs = '-q' # Install4j |
| 45 | + #silentArgs = '-s -u' # Ghost |
| 46 | + # Note that some installers, in addition to the silentArgs above, may also need assistance of AHK to achieve silence. |
| 47 | + #silentArgs = '' # none; make silent with input macro script like AutoHotKey (AHK) |
| 48 | + # https://chocolatey.org/packages/autohotkey.portable |
| 49 | + #validExitCodes= @(0) #please insert other valid exit codes here |
| 50 | +} |
| 51 | + |
| 52 | +Install-ChocolateyPackage @packageArgs # https://chocolatey.org/docs/helpers-install-chocolatey-package |
| 53 | +#Install-ChocolateyZipPackage @packageArgs # https://chocolatey.org/docs/helpers-install-chocolatey-zip-package |
| 54 | +## If you are making your own internal packages (organizations), you can embed the installer or |
| 55 | +## put on internal file share and use the following instead (you'll need to add $file to the above) |
| 56 | +#Install-ChocolateyInstallPackage @packageArgs # https://chocolatey.org/docs/helpers-install-chocolatey-install-package |
| 57 | + |
| 58 | +## Main helper functions - these have error handling tucked into them already |
| 59 | +## see https://chocolatey.org/docs/helpers-reference |
| 60 | + |
| 61 | +## Install an application, will assert administrative rights |
| 62 | +## - https://chocolatey.org/docs/helpers-install-chocolatey-package |
| 63 | +## - https://chocolatey.org/docs/helpers-install-chocolatey-install-package |
| 64 | +## add additional optional arguments as necessary |
| 65 | +##Install-ChocolateyPackage $packageName $fileType $silentArgs $url [$url64 -validExitCodes $validExitCodes -checksum $checksum -checksumType $checksumType -checksum64 $checksum64 -checksumType64 $checksumType64] |
| 66 | + |
| 67 | +## Download and unpack a zip file - https://chocolatey.org/docs/helpers-install-chocolatey-zip-package |
| 68 | +##Install-ChocolateyZipPackage $packageName $url $toolsDir [$url64 -checksum $checksum -checksumType $checksumType -checksum64 $checksum64 -checksumType64 $checksumType64] |
| 69 | + |
| 70 | +## Install Visual Studio Package - https://chocolatey.org/docs/helpers-install-chocolatey-vsix-package |
| 71 | +#Install-ChocolateyVsixPackage $packageName $url [$vsVersion] [-checksum $checksum -checksumType $checksumType] |
| 72 | +#Install-ChocolateyVsixPackage @packageArgs |
| 73 | + |
| 74 | +## see the full list at https://chocolatey.org/docs/helpers-reference |
| 75 | + |
| 76 | +## downloader that the main helpers use to download items |
| 77 | +## if removing $url64, please remove from here |
| 78 | +## - https://chocolatey.org/docs/helpers-get-chocolatey-web-file |
| 79 | +#Get-ChocolateyWebFile $packageName 'DOWNLOAD_TO_FILE_FULL_PATH' $url $url64 |
| 80 | + |
| 81 | +## Installer, will assert administrative rights - used by Install-ChocolateyPackage |
| 82 | +## use this for embedding installers in the package when not going to community feed or when you have distribution rights |
| 83 | +## - https://chocolatey.org/docs/helpers-install-chocolatey-install-package |
| 84 | +#Install-ChocolateyInstallPackage $packageName $fileType $silentArgs '_FULLFILEPATH_' -validExitCodes $validExitCodes |
| 85 | + |
| 86 | +## Unzips a file to the specified location - auto overwrites existing content |
| 87 | +## - https://chocolatey.org/docs/helpers-get-chocolatey-unzip |
| 88 | +#Get-ChocolateyUnzip "FULL_LOCATION_TO_ZIP.zip" $toolsDir |
| 89 | + |
| 90 | +## Runs processes asserting UAC, will assert administrative rights - used by Install-ChocolateyInstallPackage |
| 91 | +## - https://chocolatey.org/docs/helpers-start-chocolatey-process-as-admin |
| 92 | +#Start-ChocolateyProcessAsAdmin 'STATEMENTS_TO_RUN' 'Optional_Application_If_Not_PowerShell' -validExitCodes $validExitCodes |
| 93 | + |
| 94 | +## add specific folders to the path - any executables found in the chocolatey package |
| 95 | +## folder will already be on the path. This is used in addition to that or for cases |
| 96 | +## when a native installer doesn't add things to the path. |
| 97 | +## - https://chocolatey.org/docs/helpers-install-chocolatey-path |
| 98 | +#Install-ChocolateyPath 'LOCATION_TO_ADD_TO_PATH' 'User_OR_Machine' # Machine will assert administrative rights |
| 99 | + |
| 100 | +## Add specific files as shortcuts to the desktop |
| 101 | +## - https://chocolatey.org/docs/helpers-install-chocolatey-shortcut |
| 102 | +#$target = Join-Path $toolsDir "$($packageName).exe" |
| 103 | +# Install-ChocolateyShortcut -shortcutFilePath "<path>" -targetPath "<path>" [-workDirectory "C:\" -arguments "C:\test.txt" -iconLocation "C:\test.ico" -description "This is the description"] |
| 104 | + |
| 105 | +## Outputs the bitness of the OS (either "32" or "64") |
| 106 | +## - https://chocolatey.org/docs/helpers-get-o-s-architecture-width |
| 107 | +#$osBitness = Get-ProcessorBits |
| 108 | + |
| 109 | +## Set persistent Environment variables |
| 110 | +## - https://chocolatey.org/docs/helpers-install-chocolatey-environment-variable |
| 111 | +#Install-ChocolateyEnvironmentVariable -variableName "SOMEVAR" -variableValue "value" [-variableType = 'Machine' #Defaults to 'User'] |
| 112 | + |
| 113 | +## Set up a file association |
| 114 | +## - https://chocolatey.org/docs/helpers-install-chocolatey-file-association |
| 115 | +#Install-ChocolateyFileAssociation |
| 116 | + |
| 117 | +## Adding a shim when not automatically found - Cocolatey automatically shims exe files found in package directory. |
| 118 | +## - https://chocolatey.org/docs/helpers-install-bin-file |
| 119 | +## - https://chocolatey.org/docs/create-packages#how-do-i-exclude-executables-from-getting-shims |
| 120 | +#Install-BinFile |
| 121 | + |
| 122 | +##PORTABLE EXAMPLE |
| 123 | +#$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" |
| 124 | +# despite the name "Install-ChocolateyZipPackage" this also works with 7z archives |
| 125 | +#Install-ChocolateyZipPackage $packageName $url $toolsDir $url64 |
| 126 | +## END PORTABLE EXAMPLE |
| 127 | + |
| 128 | +## [DEPRECATING] PORTABLE EXAMPLE |
| 129 | +#$binRoot = Get-BinRoot |
| 130 | +#$installDir = Join-Path $binRoot "$packageName" |
| 131 | +#Write-Host "Adding `'$installDir`' to the path and the current shell path" |
| 132 | +#Install-ChocolateyPath "$installDir" |
| 133 | +#$env:Path = "$($env:Path);$installDir" |
| 134 | + |
| 135 | +# if removing $url64, please remove from here |
| 136 | +# despite the name "Install-ChocolateyZipPackage" this also works with 7z archives |
| 137 | +#Install-ChocolateyZipPackage "$packageName" "$url" "$installDir" "$url64" |
| 138 | +## END PORTABLE EXAMPLE |
0 commit comments