diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..aeebc167c9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,25 @@ +*~ +*.bak +*.cache +*.nupkg +*.old +*.orig +*.swp +*.swo +*.suo +*.test +*.work +*.handover +*.new +*.exist +*-orig.* +Thumbs.db +.DS_Store +_ReSharper* +*.resharper +New folder* +New Text Document*.txt +obj +*/working +ketarin/soluto.xml +*.stackdump \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000000..e06d208186 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,202 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/README.md b/README.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/automatic/_output/README.md b/automatic/_output/README.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/icons/1password.png b/icons/1password.png new file mode 100644 index 0000000000..3d80ade278 Binary files /dev/null and b/icons/1password.png differ diff --git a/icons/README.md b/icons/README.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ketarin/README.md b/ketarin/README.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/manual/README.md b/manual/README.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ops/ketarinupdate.cmd b/ops/ketarinupdate.cmd new file mode 100644 index 0000000000..a9e168ff90 --- /dev/null +++ b/ops/ketarinupdate.cmd @@ -0,0 +1,29 @@ +@echo off + +SET DIR=%~dp0% + +For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c%%a%%b) +For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set mytime=%%a%%b) + +echo Updating the github repo first +pushd %DIR% +call git add --all :/ +call git commit -m "updates prior to automatic run for %mydate%_%mytime%" +::call git reset --hard HEAD +call git fetch && git rebase origin/master +call git push origin master +popd + +:: /database="%DIR%\jobs.db" + +::import all the files +FOR /f "tokens=*" %%F IN ('dir %DIR%..\ /b *.ketarin.xml') DO ( + call ketarin.exe /import="%DIR%..\%%F" + TIMEOUT /T 2 +) + +Echo Wait for all of those to finish importing... +TIMEOUT /T 15 + +echo Calling ketarin now the the repo has been updated +call "Ketarin.exe" /silent /notify /log=C:\ProgramData\chocolateypackageupdater\ketarin.%mydate%_%mytime%.log diff --git a/setup/KetarinSettings.xml b/setup/KetarinSettings.xml new file mode 100644 index 0000000000..a41bec7329 --- /dev/null +++ b/setup/KetarinSettings.xml @@ -0,0 +1,2665 @@ + + + + + + + AuthorGuid + + + System.String:{75a093b7-da5f-493a-b8f0-22c278f874c1} + + + + + LastUpdateCheck + + + AAEAAAD/////AQAAAAAAAAAEAQAAAA9TeXN0ZW0uRGF0ZVRpbWUCAAAABXRpY2tzCGRhdGVEYXRhAAAJEOGhVC47mtII4aFULjua0ogL + + + + + MainForm/Size + + + System.Drawing.Size:2329,476 + + + + + MainForm/Location + + + System.Drawing.Point:-6,1300 + + + + + MainForm/WindowState + + + System.Int32:0 + + + + + olvJobs/Application:Visibility + + + System.Boolean:True + + + + + olvJobs/Application:Width + + + System.Int32:126 + + + + + olvJobs/Application:LastDisplayIndex + + + System.Int32:0 + + + + + olvJobs/Last updated:Visibility + + + System.Boolean:True + + + + + olvJobs/Last updated:Width + + + System.Int32:96 + + + + + olvJobs/Last updated:LastDisplayIndex + + + System.Int32:2 + + + + + olvJobs/Progress:Visibility + + + System.Boolean:True + + + + + olvJobs/Progress:Width + + + System.Int32:100 + + + + + olvJobs/Progress:LastDisplayIndex + + + System.Int32:4 + + + + + olvJobs/Target:Visibility + + + System.Boolean:True + + + + + olvJobs/Target:Width + + + System.Int32:152 + + + + + olvJobs/Target:LastDisplayIndex + + + System.Int32:5 + + + + + olvJobs/Category:Visibility + + + System.Boolean:True + + + + + olvJobs/Category:Width + + + System.Int32:80 + + + + + olvJobs/Category:LastDisplayIndex + + + System.Int32:15 + + + + + olvJobs/Status:Visibility + + + System.Boolean:True + + + + + olvJobs/Status:Width + + + System.Int32:79 + + + + + olvJobs/Status:LastDisplayIndex + + + System.Int32:6 + + + + + olvJobs/LastSortColumn + + + System.String:Application + + + + + olvJobs/LastSortOrder + + + System.Int32:1 + + + + + Ketarin/ShowGroups + + + System.Boolean:True + + + + + Ketarin/ShowStatusBar + + + System.Boolean:False + + + + + Ketarin/ShowLog + + + System.Boolean:True + + + + + Ketarin/AutoScroll + + + System.Boolean:True + + + + + PreUpdateCommand + + + System.String:# Script version: 1.3.0.0 +# +# Changelog +# evaluate custom variables rather than using variables' CachedContent +# +# Requires: +# chocolateypackageupdater +# >=ketarin-1.8.5 +# +# To configure Ketarin: +# 1. Copy this file +# 2. Navigate to: Ketarin >> File >> Settings >> Commands tab +# 3a. >> Before updating an application +# 3b. >> Command >> Powershell script +# 3c. Remove any existing text and paste this file into text area + +# Package variables to be checked for content +$vars = "version","url","url64","checksum","checksumx64","packageGuid","nopush" +$hash = @{} + +# Build hash using $vars for $hash.keys and corresponding content, if any, to $hash.values +foreach ($var in $vars) { + if ($app.variables.ContainsKey($var)) { + #$hash[$var] = $app.variables.item($var).cachedcontent + $hash[$var] = $app.variables.ReplaceAllInString("{$var}") + } else { + $hash[$var] = "{$var}" + } + Write-Host "`$hash[$var] is: $($hash[$var])" +} + +Write-Host @" +Running: +chocopkgup $($hash["nopush"]) `` + --packagename=$app `` + --version=`"$($hash["version"])`" `` + --url=`"$($hash["url"])`" `` + --urlx64=`"$($hash["url64"])`" `` + --checksum=`"$($hash["checksum"])`" `` + --c64=`"$($hash["checksumx64"])`" `` + --pg=`"$($hash["packageguid"])`" `` + --debug +"@ + +# Using corresponding hash values of keys from $vars, set parameters of +# https://chocolatey.org/packages/chocolateypackageupdater +chocopkgup $hash["nopush"] ` + --packagename=$app ` + --version="$($hash["version"])" ` + --url="$($hash["url"])" ` + --urlx64="$($hash["url64"])" ` + --checksum="$($hash["checksum"])" ` + --c64="$($hash["checksumx64"])" ` + --pg="$($hash["packageguid"])" ` + --debug + + + + + PreUpdateCommandType + + + System.String:PowerShell + + + + + CustomColumns + + + System.String:<?xml version="1.0" encoding="utf-16"?> +<dictionary> + <item> + <key> + <string>version</string> + </key> + <value> + <string>{version}</string> + </value> + </item> + <item> + <key> + <string>filesize</string> + </key> + <value> + <string>{filesize:formatfilesize}</string> + </value> + </item> + <item> + <key> + <string>host</string> + </key> + <value> + <string>{url:regex:(?&lt;=//)([\w-]+\.)*(?=[\w-]+\.[\w-]+(?=/))}</string> + </value> + </item> + <item> + <key> + <string>packageGuid</string> + </key> + <value> + <string>{packageGuid}</string> + </value> + </item> + <item> + <key> + <string>fileDate</string> + </key> + <value> + <string>{f:yyyy}-{f:MM}-{f:dd} {f:HH}:{f:mm}</string> + </value> + </item> + <item> + <key> + <string>fixedUrl</string> + </key> + <value> + <string>{property:FixedDownloadUrl:regex:(?&lt;=//).*}</string> + </value> + </item> + <item> + <key> + <string>referer</string> + </key> + <value> + <string>{property:HttpReferer}</string> + </value> + </item> + <item> + <key> + <string>user-agent</string> + </key> + <value> + <string>{property:UserAgent}</string> + </value> + </item> + <item> + <key> + <string>delPrevFile</string> + </key> + <value> + <string>{property:DeletePreviousFile:multireplace:,:True,False:X,}</string> + </value> + </item> + <item> + <key> + <string>varChgInd</string> + </key> + <value> + <string>{property:VariableChangeIndicator}</string> + </value> + </item> + <item> + <key> + <string>cscript</string> + </key> + <value> + <string>{cscript}</string> + </value> + </item> + <item> + <key> + <string>enabled</string> + </key> + <value> + <string>{property:Enabled}</string> + </value> + </item> + <item> + <key> + <string>nopush</string> + </key> + <value> + <string>{nopush}</string> + </value> + </item> + <item> + <key> + <string>domain</string> + </key> + <value> + <string>{url:regex:(?&lt;=//[\w-]+\.)*[\w-]+\.[\w-]+(?=/)}</string> + </value> + </item> + <item> + <key> + <string>checksum64file</string> + </key> + <value> + <string>{checksum64file}</string> + </value> + </item> + <item> + <key> + <string>url64</string> + </key> + <value> + <string>{url64}</string> + </value> + </item> + <item> + <key> + <string>hashInternal</string> + </key> + <value> + <string>{hash}</string> + </value> + </item> + <item> + <key> + <string>hashType</string> + </key> + <value> + <string>{property:HashType:replace:None:}</string> + </value> + </item> + <item> + <key> + <string>proto</string> + </key> + <value> + <string>{url:regex:.*?(?=.//)}</string> + </value> + </item> + <item> + <key> + <string>bytes</string> + </key> + <value> + <string>{filesize}</string> + </value> + </item> + <item> + <key> + <string>hashExternal</string> + </key> + <value> + <string>{checksum}</string> + </value> + </item> + <item> + <key> + <string>checksum64</string> + </key> + <value> + <string>{checksumx64}</string> + </value> + </item> +</dictionary> + + + + + CustomColumn + + + + + + + + CustomColumn2 + + + + + + + + UpdateAtStartup + + + System.Boolean:False + + + + + AvoidFileHippoBeta + + + System.Boolean:True + + + + + ConnectionTimeout + + + AAEAAAD/////AQAAAAAAAAAEAQAAAA5TeXN0ZW0uRGVjaW1hbAQAAAAFZmxhZ3MCaGkCbG8DbWlkAAAAAAgICAgAAAAAAAAAADwAAAAAAAAACw== + + + + + ThreadCount + + + System.Int32:4 + + + + + RetryCount + + + System.Int32:2 + + + + + UpdateOnlineDatabase + + + System.Boolean:False + + + + + MinimizeToTray + + + System.Boolean:True + + + + + CreateDatabaseBackups + + + System.Boolean:True + + + + + OpenWebsiteOnDoubleClick + + + System.Boolean:False + + + + + ProxyPort + + + AAEAAAD/////AQAAAAAAAAAEAQAAAA5TeXN0ZW0uRGVjaW1hbAQAAAAFZmxhZ3MCaGkCbG8DbWlkAAAAAAgICAgAAAAAAAAAALgiAAAAAAAACw== + + + + + ProxyServer + + + System.String: + + + + + ProxyUser + + + System.String: + + + + + ProxyPassword + + + System.String: + + + + + olvJobs/Version:Visibility + + + System.Boolean:True + + + + + olvJobs/Version:Width + + + System.Int32:99 + + + + + olvJobs/Version:LastDisplayIndex + + + System.Int32:1 + + + + + SetPlaceholderDialog/Size + + + System.Drawing.Size:397,147 + + + + + SetPlaceholderDialog/Location + + + System.Drawing.Point:1118,929 + + + + + SetPlaceholderDialog/WindowState + + + System.Int32:0 + + + + + EditVariablesDialog/Size + + + System.Drawing.Size:1004,492 + + + + + EditVariablesDialog/Location + + + System.Drawing.Point:-11,212 + + + + + EditVariablesDialog/WindowState + + + System.Int32:0 + + + + + ApplicationJobDialog/Size + + + System.Drawing.Size:507,507 + + + + + ApplicationJobDialog/Location + + + System.Drawing.Point:173,12 + + + + + ApplicationJobDialog/WindowState + + + System.Int32:0 + + + + + LogDialog/Size + + + System.Drawing.Size:1825,423 + + + + + LogDialog/Location + + + System.Drawing.Point:-7,747 + + + + + LogDialog/WindowState + + + System.Int32:0 + + + + + ErrorsDialog/Size + + + System.Drawing.Size:1096,965 + + + + + olvErrors/Application:Visibility + + + System.Boolean:True + + + + + olvErrors/Application:Width + + + System.Int32:98 + + + + + olvErrors/Application:LastDisplayIndex + + + System.Int32:-1 + + + + + olvErrors/Error:Visibility + + + System.Boolean:True + + + + + olvErrors/Error:Width + + + System.Int32:952 + + + + + olvErrors/Error:LastDisplayIndex + + + System.Int32:-1 + + + + + olvErrors/LastSortColumn + + + System.String:Application + + + + + olvErrors/LastSortOrder + + + System.Int32:1 + + + + + ProgressDialog/Size + + + System.Drawing.Size:302,112 + + + + + Hotkey: OpenWebsite + + + System.String: + + + + + Hotkey: Edit + + + System.String: + + + + + Hotkey: Update + + + System.String: + + + + + Hotkey: ForceDownload + + + System.String: + + + + + Hotkey: InstallSelected + + + System.String: + + + + + Hotkey: OpenFile + + + System.String: + + + + + Hotkey: OpenFolder + + + System.String: + + + + + Hotkey: CheckUpdate + + + System.String: + + + + + Hotkey: UpdateAndInstall + + + System.String: + + + + + InstallingApplicationsDialog/Size + + + System.Drawing.Size:406,250 + + + + + InstallingApplicationsDialog/Location + + + System.Drawing.Point:164,724 + + + + + InstallingApplicationsDialog/WindowState + + + System.Int32:0 + + + + + olvLog/Time:Visibility + + + System.Boolean:True + + + + + olvLog/Time:Width + + + System.Int32:55 + + + + + olvLog/Time:LastDisplayIndex + + + System.Int32:-1 + + + + + olvLog/Message:Visibility + + + System.Boolean:True + + + + + olvLog/Message:Width + + + System.Int32:310 + + + + + olvLog/Message:LastDisplayIndex + + + System.Int32:-1 + + + + + olvLog/LastSortColumn + + + System.String:Time + + + + + olvLog/LastSortOrder + + + System.Int32:0 + + + + + InstallingApplicationsDialog/Expanded + + + System.Boolean:True + + + + + DefaultCommand + + + System.String://////////////////////////////////////////////////////////////////////////////////////// +/// version 6.8.0.0 +/// +/// Changelog: Calc SHA256 sums +/// Ticket: https://github.com/dtgm/chocolatey-packages/issues/196 +/// + +// REQUIRES: +// global vars: saveDir=corresponds to download location of installer file +// app vars: nopush, checksum64file=corresponds to 64 bit install file +// file vars: same as specified by chocopkgup + +// get package variable 'cscript' +string varCScript = app.Variables.ReplaceAllInString("{cscript}"); + +// determine whether we run this by checking cscript exists AND is 1 or 2 +if ((varCScript == "1") || (varCScript == "2")) { + +// ketarin variables we pass for this script to use +string varAppname = app.Variables.ReplaceAllInString("{appname}"); +string varVersion = app.Variables.ReplaceAllInString("{version}"); +string varChocoPkgOutput = app.Variables.ReplaceAllInString("{chocoPkgOut}"); +string varChecksum = app.Variables.ReplaceAllInString("{checksum}"); +string varChecksumx64 = app.Variables.ReplaceAllInString("{checksumx64}"); +string varChecksum64File = app.Variables.ReplaceAllInString("{checksum64file}"); +// string varChecksum64basefile = app.Variables.ReplaceAllInString("{checksum64file:basefile}"); +string varChecksum64ext = app.Variables.ReplaceAllInString("{checksum64file:ext}"); +string varSaveDir = app.Variables.ReplaceAllInString("{saveDir}"); + +// custom variables used in this script +string saveFileName64 = String.Concat(varAppname, "_64_", varVersion, ".", varChecksum64ext); +string savePath64 = Path.Combine(varSaveDir, saveFileName64); +// equivalent to ketarin variable "{file}" +string savePath = app.PreviousLocation; +string pkgPath = Path.Combine(varChocoPkgOutput, varAppname, varVersion); +string fileNameNuspec = String.Concat(varAppname, ".nuspec"); +string fileUriNuspec = Path.Combine(pkgPath, fileNameNuspec); +string fileNameNupkg = String.Concat(varAppname, ".", varVersion, ".nupkg"); +string fileUriNupkg = Path.Combine(pkgPath, fileNameNupkg); + +/* DEBUG + MessageBox.Show(varSaveDir + System.Environment.NewLine + + saveFileName64 + System.Environment.NewLine + + savePath64);*/ + +// do not re-push package if package already created +DateTime today = DateTime.Today; +DateTime pkgCreateDate = File.GetCreationTime(pkgPath); +if (today > pkgCreateDate) { + return; +} + +// if package variable 'checksum' does not exist or is null +if (varChecksum == "{checksum}") { + // calculate SHA256 from {url} Note we are leveraging ketarin's downloaded copy + System.IO.FileStream fileSha = new System.IO.FileStream(savePath, System.IO.FileMode.Open); + System.Security.Cryptography.SHA256 sha256 = new System.Security.Cryptography.SHA256Managed(); + byte[] retValSha = sha256.ComputeHash(fileSha); + fileSha.Close(); + + // build string from byte value + System.Text.StringBuilder sbSha = new System.Text.StringBuilder(); + for (int i = 0; i < retValSha.Length; i++) { + sbSha.Append(retValSha[i].ToString("x2")); + } + + // find $pkgPath -iname "*.nuspec" -o -iname "*.ps1" -exec sed -i 's/'$sbSha'/{checksum}/g' '{}' \; + string replaceChecksum = sbSha.ToString(); + //MessageBox.Show(replaceChecksum); + List<string> fileList = new List<string>(Directory.GetFiles(pkgPath, "*.ps1", SearchOption.AllDirectories)); + string[] filesNuspec = Directory.GetFiles(pkgPath, "*.nuspec", SearchOption.AllDirectories); + fileList.AddRange(filesNuspec); + string[] files = fileList.ToArray(); + foreach (string file in files) { + try { + string contents = File.ReadAllText(file); + //MessageBox.Show(contents); + contents = contents.Replace("{checksum}", replaceChecksum); + //MessageBox.Show(contents); + // Make files writable + // File.SetAttributes(file, FileAttributes.Normal); + File.WriteAllText(file, contents); + } catch (Exception ex) { + Console.WriteLine(ex.Message); + } + } +} + +// only get checksum if checksumx64 does NOT exist and 'checksum64file' DOES exists +if (varChecksumx64 == "{checksumx64}" && varChecksum64File != "{checksum64file}") { + // TODO: verify and validate URI checksum64file points to a downloadable file + + // we must download the file to calculate checksum ... may as well save it + System.Net.WebClient webClient = new System.Net.WebClient(); + webClient.DownloadFile(varChecksum64File, savePath64); + + // calculate SHA256 from file of url pointed to by 'checksum64file' + System.IO.FileStream file64Sha = new System.IO.FileStream(savePath64, System.IO.FileMode.Open); + System.Security.Cryptography.SHA256 sha256_64 = new System.Security.Cryptography.SHA256Managed(); + byte[] retVal64Sha = sha256_64.ComputeHash(file64Sha); + file64Sha.Close(); + + // build string from byte value + System.Text.StringBuilder sb64Sha = new System.Text.StringBuilder(); + for (int i = 0; i < retVal64Sha.Length; i++) { + sb64Sha.Append(retVal64Sha[i].ToString("x2")); + } + + // find $pkgPath -iname "*.nuspec" -o -iname "*.ps1" -exec sed -i 's/'$sb64Sha'/{checksumx64}/g' '{}' \; + // Note chocopkgup will strip 1 set of curly braces so {{checksum}} becomes {checksum} + string replace64Checksum = sb64Sha.ToString(); + //MessageBox.Show(replace64Checksum); + List<string> fileList = new List<string>(Directory.GetFiles(pkgPath, "*.ps1", SearchOption.AllDirectories)); + string[] filesNuspec = Directory.GetFiles(pkgPath, "*.nuspec", SearchOption.AllDirectories); + fileList.AddRange(filesNuspec); + string[] files = fileList.ToArray(); + foreach (string file in files) { + try { + string contents = File.ReadAllText(file); + //MessageBox.Show(contents); + contents = contents.Replace("{checksumx64}", replace64Checksum); + //MessageBox.Show(contents); + File.WriteAllText(file, contents); + } catch (Exception ex) { + Console.WriteLine(ex.Message); + } + } +} + +// attempt to fix chocopkgup failure when faced with letters in version variable +// ...what was I thinking? no, seriously. +/* +int checkBeta = varVersion.Split('-').Length; +if ( checkBeta == 2) { + string strPre = varVersion.Split('-')[1]; + string strReplace = String.Concat(strPre, "</version>"); + string strCheck = String.Concat(".", DateTime.Now.ToString("yyyyMMdd"), "</version>"); + string[] fileNuspec = Directory.GetFiles(pkgPath, "*.nuspec", SearchOption.AllDirectories); + foreach (string file in fileNuspec) { + string contents = File.ReadAllText(file); + contents = contents.Replace(strCheck, strReplace); + File.WriteAllText(file, contents); + } +} +*/ + +// delete existing nupkg made by chocopkgup; we leverage chocopkgup to create the structure/files in destination +System.Diagnostics.Process process1 = new System.Diagnostics.Process(); +System.Diagnostics.ProcessStartInfo proc1 = new System.Diagnostics.ProcessStartInfo(); +proc1.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; +proc1.UseShellExecute = true; +proc1.WorkingDirectory = pkgPath; +proc1.FileName = "cmd.exe"; +proc1.Arguments = "/c "+"del /f " + fileUriNupkg; +process1.StartInfo = proc1; +process1.Start(); + +// create a new nupkg +System.Diagnostics.Process process2 = new System.Diagnostics.Process(); +System.Diagnostics.ProcessStartInfo proc2 = new System.Diagnostics.ProcessStartInfo(); +proc2.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; +proc2.UseShellExecute = true; +proc2.WorkingDirectory = pkgPath; +proc2.FileName = "cmd.exe"; +proc2.Arguments = "/c "+"choco pack "+fileUriNuspec+" -d"; +process2.StartInfo = proc2; +process2.Start(); + +// push the nupkg +if (varCScript == "2") { + System.Diagnostics.Process process3 = new System.Diagnostics.Process(); + System.Diagnostics.ProcessStartInfo proc3 = new System.Diagnostics.ProcessStartInfo(); + proc3.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; + proc3.UseShellExecute = true; + proc3.WorkingDirectory = pkgPath; + proc3.FileName = "cmd.exe"; + // find nupkg in pkgPath + string[] pushPkg = Directory.GetFiles(pkgPath, "*.nupkg", SearchOption.TopDirectoryOnly); + foreach (String file in pushPkg) { + proc3.Arguments = "/c "+"cpush " + file + " -d"; + } + process3.StartInfo = proc3; + System.Threading.Thread.Sleep(2000); + process3.Start(); +} +} + + + + + DefaultCommandType + + + System.String:CS + + + + + PostUpdateCommand + + + System.String: + + + + + PostUpdateCommandType + + + System.String:Batch + + + + + DefaultApplication + + + System.String:<?xml version="1.0" encoding="utf-8"?> +<Jobs> + <ApplicationJob xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <WebsiteUrl /> + <UserAgent /> + <UserNotes /> + <LastFileSize>0</LastFileSize> + <LastFileDate xsi:nil="true" /> + <IgnoreFileInformation>false</IgnoreFileInformation> + <DownloadBeta>Default</DownloadBeta> + + <CheckForUpdatesOnly>false</CheckForUpdatesOnly> + <VariableChangeIndicator /> + <HashVariable /> + <HashType>None</HashType> + <CanBeShared>true</CanBeShared> + <ShareApplication>false</ShareApplication> + <ExclusiveDownload>false</ExclusiveDownload> + <HttpReferer /> + <SetupInstructions /> + <Variables> + <item> + <key> + <string>nopush</string> + </key> + <value> + <UrlVariable> + <RegexRightToLeft>false</RegexRightToLeft> + <VariableType>Textual</VariableType> + <Regex /> + <TextualContent>--nopush</TextualContent> + <Name>nopush</Name> + </UrlVariable> + </value> + </item> + <item> + <key> + <string>version</string> + </key> + <value> + <UrlVariable> + <RegexRightToLeft>false</RegexRightToLeft> + <VariableType>RegularExpression</VariableType> + <Regex>Last program version.*?([\d\.]+)</Regex> + <Url>x</Url> + <Name>version</Name> + </UrlVariable> + </value> + </item> + <item> + <key> + <string>url</string> + </key> + <value> + <UrlVariable> + <RegexRightToLeft>false</RegexRightToLeft> + <VariableType>Textual</VariableType> + <Regex /> + <TextualContent>{getUrl}</TextualContent> + <Name>url</Name> + </UrlVariable> + </value> + </item> + <item> + <key> + <string>url64</string> + </key> + <value> + <UrlVariable> + <RegexRightToLeft>false</RegexRightToLeft> + <VariableType>Textual</VariableType> + <Regex /> + <TextualContent>{getUrl64}</TextualContent> + <Name>url64</Name> + </UrlVariable> + </value> + </item> + <item> + <key> + <string>getUrl</string> + </key> + <value> + <UrlVariable> + <RegexRightToLeft>false</RegexRightToLeft> + <VariableType>RegularExpression</VariableType> + <Regex>[^ "'&lt;&gt;\*]+\.exe</Regex> + <Url>x</Url> + <Name>getUrl</Name> + </UrlVariable> + </value> + </item> + <item> + <key> + <string>getUrl64</string> + </key> + <value> + <UrlVariable> + <RegexRightToLeft>false</RegexRightToLeft> + <VariableType>RegularExpression</VariableType> + <Regex>[^ "'&lt;&gt;\*]+\.exe</Regex> + <Url>x</Url> + <Name>getUrl64</Name> + </UrlVariable> + </value> + </item> + <item> + <key> + <string>checksum</string> + </key> + <value> + <UrlVariable> + <RegexRightToLeft>false</RegexRightToLeft> + <VariableType>RegularExpression</VariableType> + <Regex>[A-Fa-f0-9]{32}</Regex> + <Url>md5</Url> + <TextualContent>{checksum}</TextualContent> + <Name>checksum</Name> + </UrlVariable> + </value> + </item> + <item> + <key> + <string>checksumx64</string> + </key> + <value> + <UrlVariable> + <RegexRightToLeft>false</RegexRightToLeft> + <VariableType>RegularExpression</VariableType> + <Regex>(?&lt;=ResponseUri: )[^\r\n]+</Regex> + <Url>{url64}</Url> + <TextualContent>{checksum}</TextualContent> + <Name>checksumx64</Name> + </UrlVariable> + </value> + </item> + <item> + <key> + <string>checksum64file</string> + </key> + <value> + <UrlVariable> + <RegexRightToLeft>false</RegexRightToLeft> + <VariableType>Textual</VariableType> + <Regex /> + <TextualContent>{url64}</TextualContent> + <Name>checksum64file</Name> + </UrlVariable> + </value> + </item> + <item> + <key> + <string>cscript</string> + </key> + <value> + <UrlVariable> + <RegexRightToLeft>false</RegexRightToLeft> + <VariableType>Textual</VariableType> + <Regex /> + <TextualContent>0</TextualContent> + <Name>cscript</Name> + </UrlVariable> + </value> + </item> + </Variables> + <ExecuteCommand /> + <ExecutePreCommand /> + <ExecuteCommandType>Batch</ExecuteCommandType> + <ExecutePreCommandType>Batch</ExecutePreCommandType> + <Category /> + <SourceType>FixedUrl</SourceType> + + <DeletePreviousFile>false</DeletePreviousFile> + <Enabled>true</Enabled> + <FileHippoId /> + + <TargetPath>{saveDir}\{appname}_{version}.{url:ext}</TargetPath> + <FixedDownloadUrl>{url}</FixedDownloadUrl> + <Name>x </Name> + </ApplicationJob> +</Jobs> + + + + + olvJobs/x:Visibility + + + System.Boolean:True + + + + + olvJobs/x:Width + + + System.Int32:89 + + + + + olvJobs/x:LastDisplayIndex + + + System.Int32:-1 + + + + + olvJobs/Filesize:Visibility + + + System.Boolean:True + + + + + olvJobs/Filesize:Width + + + System.Int32:68 + + + + + olvJobs/Filesize:LastDisplayIndex + + + System.Int32:5 + + + + + olvJobs/url:Visibility + + + System.Boolean:True + + + + + olvJobs/url:Width + + + System.Int32:147 + + + + + olvJobs/url:LastDisplayIndex + + + System.Int32:-1 + + + + + olvJobs/host:Visibility + + + System.Boolean:True + + + + + olvJobs/host:Width + + + System.Int32:120 + + + + + olvJobs/host:LastDisplayIndex + + + System.Int32:10 + + + + + olvJobs/packageGuid:Visibility + + + System.Boolean:True + + + + + olvJobs/packageGuid:Width + + + System.Int32:77 + + + + + olvJobs/packageGuid:LastDisplayIndex + + + System.Int32:14 + + + + + olvJobs/fileDate:Visibility + + + System.Boolean:True + + + + + olvJobs/fileDate:Width + + + System.Int32:97 + + + + + olvJobs/fileDate:LastDisplayIndex + + + System.Int32:3 + + + + + olvJobs/fixedUrl:Visibility + + + System.Boolean:True + + + + + olvJobs/fixedUrl:Width + + + System.Int32:96 + + + + + olvJobs/fixedUrl:LastDisplayIndex + + + System.Int32:9 + + + + + olvJobs/referer:Visibility + + + System.Boolean:True + + + + + olvJobs/referer:Width + + + System.Int32:65 + + + + + olvJobs/referer:LastDisplayIndex + + + System.Int32:13 + + + + + olvJobs/User-Agent:Visibility + + + System.Boolean:True + + + + + olvJobs/User-Agent:Width + + + System.Int32:80 + + + + + olvJobs/User-Agent:LastDisplayIndex + + + System.Int32:8 + + + + + olvJobs/DeletePreviousFile:Visibility + + + System.Boolean:True + + + + + olvJobs/DeletePreviousFile:Width + + + System.Int32:41 + + + + + olvJobs/DeletePreviousFile:LastDisplayIndex + + + System.Int32:20 + + + + + olvJobs/VariableChangeIndicator:Visibility + + + System.Boolean:True + + + + + olvJobs/VariableChangeIndicator:Width + + + System.Int32:55 + + + + + olvJobs/VariableChangeIndicator:LastDisplayIndex + + + System.Int32:15 + + + + + olvJobs/github:Visibility + + + System.Boolean:True + + + + + olvJobs/github:Width + + + System.Int32:64 + + + + + olvJobs/github:LastDisplayIndex + + + System.Int32:16 + + + + + olvJobs/kde:Visibility + + + System.Boolean:True + + + + + olvJobs/kde:Width + + + System.Int32:49 + + + + + olvJobs/kde:LastDisplayIndex + + + System.Int32:17 + + + + + olvJobs/cscript:Visibility + + + System.Boolean:True + + + + + olvJobs/cscript:Width + + + System.Int32:32 + + + + + olvJobs/cscript:LastDisplayIndex + + + System.Int32:22 + + + + + olvJobs/enabled:Visibility + + + System.Boolean:True + + + + + olvJobs/enabled:Width + + + System.Int32:60 + + + + + olvJobs/enabled:LastDisplayIndex + + + System.Int32:26 + + + + + olvJobs/nopush:Visibility + + + System.Boolean:True + + + + + olvJobs/nopush:Width + + + System.Int32:60 + + + + + olvJobs/nopush:LastDisplayIndex + + + System.Int32:23 + + + + + olvJobs/domainname:Visibility + + + System.Boolean:True + + + + + olvJobs/domainname:Width + + + System.Int32:166 + + + + + olvJobs/domainname:LastDisplayIndex + + + System.Int32:10 + + + + + olvJobs/domain:Visibility + + + System.Boolean:True + + + + + olvJobs/domain:Width + + + System.Int32:141 + + + + + olvJobs/domain:LastDisplayIndex + + + System.Int32:17 + + + + + olvJobs/checksum64file:Visibility + + + System.Boolean:True + + + + + olvJobs/checksum64file:Width + + + System.Int32:91 + + + + + olvJobs/checksum64file:LastDisplayIndex + + + System.Int32:25 + + + + + olvJobs/Target2:Visibility + + + System.Boolean:True + + + + + olvJobs/Target2:Width + + + System.Int32:60 + + + + + olvJobs/Target2:LastDisplayIndex + + + System.Int32:-1 + + + + + olvJobs/AppName:Visibility + + + System.Boolean:True + + + + + olvJobs/AppName:Width + + + System.Int32:164 + + + + + olvJobs/AppName:LastDisplayIndex + + + System.Int32:-1 + + + + + olvJobs/version:Visibility + + + System.Boolean:True + + + + + olvJobs/version:Width + + + System.Int32:120 + + + + + olvJobs/version:LastDisplayIndex + + + System.Int32:1 + + + + + olvJobs/filesize:Visibility + + + System.Boolean:True + + + + + olvJobs/filesize:Width + + + System.Int32:68 + + + + + olvJobs/filesize:LastDisplayIndex + + + System.Int32:8 + + + + + olvJobs/user-agent:Visibility + + + System.Boolean:True + + + + + olvJobs/user-agent:Width + + + System.Int32:60 + + + + + olvJobs/user-agent:LastDisplayIndex + + + System.Int32:12 + + + + + olvJobs/delPrevFile:Visibility + + + System.Boolean:True + + + + + olvJobs/delPrevFile:Width + + + System.Int32:60 + + + + + olvJobs/delPrevFile:LastDisplayIndex + + + System.Int32:27 + + + + + olvJobs/varChangeIndicator:Visibility + + + System.Boolean:True + + + + + olvJobs/varChangeIndicator:Width + + + System.Int32:60 + + + + + olvJobs/varChangeIndicator:LastDisplayIndex + + + System.Int32:20 + + + + + olvJobs/varChgInd:Visibility + + + System.Boolean:True + + + + + olvJobs/varChgInd:Width + + + System.Int32:82 + + + + + olvJobs/varChgInd:LastDisplayIndex + + + System.Int32:16 + + + + + olvJobs/url64:Visibility + + + System.Boolean:True + + + + + olvJobs/url64:Width + + + System.Int32:60 + + + + + olvJobs/url64:LastDisplayIndex + + + System.Int32:24 + + + + + olvJobs/hash:Visibility + + + System.Boolean:True + + + + + olvJobs/hash:Width + + + System.Int32:60 + + + + + olvJobs/hash:LastDisplayIndex + + + System.Int32:24 + + + + + olvJobs/hashType:Visibility + + + System.Boolean:True + + + + + olvJobs/hashType:Width + + + System.Int32:60 + + + + + olvJobs/hashType:LastDisplayIndex + + + System.Int32:18 + + + + + ImportFromDatabaseDialog/Size + + + System.Drawing.Size:524,1596 + + + + + olvApplications/Application name:Visibility + + + System.Boolean:True + + + + + olvApplications/Application name:Width + + + System.Int32:291 + + + + + olvApplications/Application name:LastDisplayIndex + + + System.Int32:-1 + + + + + olvApplications/Last updated:Visibility + + + System.Boolean:True + + + + + olvApplications/Last updated:Width + + + System.Int32:130 + + + + + olvApplications/Last updated:LastDisplayIndex + + + System.Int32:-1 + + + + + olvApplications/Uses:Visibility + + + System.Boolean:True + + + + + olvApplications/Uses:Width + + + System.Int32:40 + + + + + olvApplications/Uses:LastDisplayIndex + + + System.Int32:-1 + + + + + olvApplications/LastSortColumn + + + System.String:Application name + + + + + olvApplications/LastSortOrder + + + System.Int32:1 + + + + + ChooseAppsToInstallDialog/Size + + + System.Drawing.Size:618,433 + + + + + ChooseAppsToInstallDialog/Location + + + System.Drawing.Point:675,637 + + + + + ChooseAppsToInstallDialog/WindowState + + + System.Int32:0 + + + + + olvApps/Name:Visibility + + + System.Boolean:True + + + + + olvApps/Name:Width + + + System.Int32:263 + + + + + olvApps/Name:LastDisplayIndex + + + System.Int32:-1 + + + + + olvApps/LastSortColumn + + + System.String:Name + + + + + olvApps/LastSortOrder + + + System.Int32:1 + + + + + olvLists/Name:Visibility + + + System.Boolean:True + + + + + olvLists/Name:Width + + + System.Int32:80 + + + + + olvLists/Name:LastDisplayIndex + + + System.Int32:-1 + + + + + olvLists/Applications:Visibility + + + System.Boolean:True + + + + + olvLists/Applications:Width + + + System.Int32:80 + + + + + olvLists/Applications:LastDisplayIndex + + + System.Int32:-1 + + + + + olvLists/LastSortColumn + + + System.String:Name + + + + + olvLists/LastSortOrder + + + System.Int32:0 + + + + + ChooseAppsToInstallDialog/ListsView + + + System.Int32:4 + + + + + olvJobs/proto:Visibility + + + System.Boolean:True + + + + + olvJobs/proto:Width + + + System.Int32:60 + + + + + olvJobs/proto:LastDisplayIndex + + + System.Int32:11 + + + + + CopyFileInstructionDialog/Size + + + System.Drawing.Size:402,163 + + + + + olvJobs/bytes:Visibility + + + System.Boolean:True + + + + + olvJobs/bytes:Width + + + System.Int32:71 + + + + + olvJobs/bytes:LastDisplayIndex + + + System.Int32:7 + + + + + olvJobs/hashExtVar:Visibility + + + System.Boolean:True + + + + + olvJobs/hashExtVar:Width + + + System.Int32:60 + + + + + olvJobs/hashExtVar:LastDisplayIndex + + + System.Int32:23 + + + + + olvJobs/hashInternal:Visibility + + + System.Boolean:True + + + + + olvJobs/hashInternal:Width + + + System.Int32:60 + + + + + olvJobs/hashInternal:LastDisplayIndex + + + System.Int32:19 + + + + + olvJobs/hashExternal:Visibility + + + System.Boolean:True + + + + + olvJobs/hashExternal:Width + + + System.Int32:60 + + + + + olvJobs/hashExternal:LastDisplayIndex + + + System.Int32:20 + + + + + olvJobs/checksum64:Visibility + + + System.Boolean:True + + + + + olvJobs/checksum64:Width + + + System.Int32:33 + + + + + olvJobs/checksum64:LastDisplayIndex + + + System.Int32:21 + + + + + + + + + + + + + + + + + + + + chocopkgup {nopush} --packagename={appname} --version={version} --pg="{packageGuid}" --url="{preupdate-url}" --urlx64="{url64}" --packagepath="{file}" --checksum="{checksum}" --c64="{checksumx64}" --debug + //////////////////////////////////////////////////////////////////////////////////////// +/// version 6.5 +/// +/// FIX: do not re-push package if package already created +/// + +// REQUIRES: +// global vars: workdir=corresponds to download location of installer file +// app vars: nopush, checksum64file=corresponds to 64 bit install file +// file vars: same as specified by chocopkgup +string varCScript = app.Variables.ReplaceAllInString("{cscript}"); +if ((varCScript == "1") || (varCScript == "2")) { +string varAppname = app.Variables.ReplaceAllInString("{appname}"); +string varVersion = app.Variables.ReplaceAllInString("{version}"); +string varChocoPkgOutput = app.Variables.ReplaceAllInString("{chocoPkgOutput}"); +string varChecksum = app.Variables.ReplaceAllInString("{checksum}"); +string varChecksumx64 = app.Variables.ReplaceAllInString("{checksumx64}"); +string varChecksum64File = app.Variables.ReplaceAllInString("{checksum64file}"); +string varChecksum64basefile = app.Variables.ReplaceAllInString("{checksum64file:basefile}"); +string varChecksum64ext = app.Variables.ReplaceAllInString("{checksum64file:ext}"); +string varWorkdir = app.Variables.ReplaceAllInString("{workdir}"); +string saveFileName64 = String.Concat(varChecksum64basefile, ".", varChecksum64ext); +// equivalent to ketarin variable "{file}" +//string savePath = app.PreviousLocation; +string savePath = app.PreviousLocation; +string pkgPath = Path.Combine(varChocoPkgOutput, varAppname, varVersion); +string fileNameNuspec = String.Concat(varAppname, ".nuspec"); +string fileUriNuspec = Path.Combine(pkgPath, fileNameNuspec); +string fileNameNupkg = String.Concat(varAppname, ".", varVersion, ".nupkg"); +string fileUriNupkg = Path.Combine(pkgPath, fileNameNupkg); + +// do not re-push package if package already created +DateTime today = DateTime.Today; +DateTime pkgCreateDate = File.GetCreationTime(pkgPath); +if (today > pkgCreateDate) { + return; +} + +if (varChecksum == "{checksum}") { + // calculate SHA1 + System.IO.FileStream fileSha1 = new System.IO.FileStream(savePath, System.IO.FileMode.Open); + System.Security.Cryptography.SHA1 sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider(); + byte[] retValSha1 = sha1.ComputeHash(fileSha1); + fileSha1.Close(); + + // create a string + System.Text.StringBuilder sbSha1 = new System.Text.StringBuilder(); + for (int i = 0; i < retValSha1.Length; i++) { + sbSha1.Append(retValSha1[i].ToString("x2")); + } + + string replaceChecksum = sbSha1.ToString(); + List<string> fileList = new List<string>(Directory.GetFiles(pkgPath, "*.ps1", SearchOption.AllDirectories)); + string[] filesNuspec = Directory.GetFiles(pkgPath, "*.nuspec", SearchOption.AllDirectories); + fileList.AddRange(filesNuspec); + string[] files = fileList.ToArray(); + foreach (string file in files) { + try { + string contents = File.ReadAllText(file); + contents = contents.Replace("{checksum}", replaceChecksum); + // Make files writable + // File.SetAttributes(file, FileAttributes.Normal); + File.WriteAllText(file, contents); + } catch (Exception ex) { + Console.WriteLine(ex.Message); + } + } +} + +// only get checksum if {checksum64file} exists and points to a downloadable file +if (varChecksumx64 == "{checksumx64}" && varChecksum64File != "{checksum64file}") { + string savePath64 = Path.Combine(varWorkdir, saveFileName64); + System.Net.WebClient webClient = new System.Net.WebClient(); + webClient.DownloadFile(varChecksum64File, savePath64); + + // calculate SHA1 + System.IO.FileStream file64Sha1 = new System.IO.FileStream(savePath64, System.IO.FileMode.Open); + System.Security.Cryptography.SHA1 sha164 = new System.Security.Cryptography.SHA1CryptoServiceProvider(); + byte[] retVal64Sha1 = sha164.ComputeHash(file64Sha1); + file64Sha1.Close(); + + // create a string + System.Text.StringBuilder sb64Sha1 = new System.Text.StringBuilder(); + for (int i = 0; i < retVal64Sha1.Length; i++) { + sb64Sha1.Append(retVal64Sha1[i].ToString("x2")); + } + + string replace64Checksum = sb64Sha1.ToString(); + List<string> fileList = new List<string>(Directory.GetFiles(pkgPath, "*.ps1", SearchOption.AllDirectories)); + string[] filesNuspec = Directory.GetFiles(pkgPath, "*.nuspec", SearchOption.AllDirectories); + fileList.AddRange(filesNuspec); + string[] files = fileList.ToArray(); + foreach (string file in files) { + try { + string contents = File.ReadAllText(file); + contents = contents.Replace("{checksumx64}", replace64Checksum); + File.WriteAllText(file, contents); + } catch (Exception ex) { + Console.WriteLine(ex.Message); + } + } +} + +int checkBeta = varVersion.Split('-').Length; +if ( checkBeta == 2) { + string strPre = varVersion.Split('-')[1]; + string strReplace = String.Concat(strPre, "</version>"); + string strCheck = String.Concat(".", DateTime.Now.ToString("yyyyMMdd"), "</version>"); + string[] fileNuspec = Directory.GetFiles(pkgPath, "*.nuspec", SearchOption.AllDirectories); + foreach (string file in fileNuspec) { + string contents = File.ReadAllText(file); + contents = contents.Replace(strCheck, strReplace); + File.WriteAllText(file, contents); + } +} + +// delete existing nupkg made by chocopkgup; we leverage chocopkgup to create the structure/files in destination +System.Diagnostics.Process process1 = new System.Diagnostics.Process(); +System.Diagnostics.ProcessStartInfo proc1 = new System.Diagnostics.ProcessStartInfo(); +proc1.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; +proc1.UseShellExecute = true; +proc1.WorkingDirectory = pkgPath; +proc1.FileName = "cmd.exe"; +proc1.Arguments = "/c "+"del /f " + fileUriNupkg; +process1.StartInfo = proc1; +process1.Start(); + +// create a new nupkg +System.Diagnostics.Process process2 = new System.Diagnostics.Process(); +System.Diagnostics.ProcessStartInfo proc2 = new System.Diagnostics.ProcessStartInfo(); +proc2.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; +proc2.UseShellExecute = true; +proc2.WorkingDirectory = pkgPath; +proc2.FileName = "cmd.exe"; +proc2.Arguments = "/c "+"choco pack "+fileUriNuspec+" -d"; +process2.StartInfo = proc2; +process2.Start(); + +// push the nupkg +if (varCScript == "2") { + System.Diagnostics.Process process3 = new System.Diagnostics.Process(); + System.Diagnostics.ProcessStartInfo proc3 = new System.Diagnostics.ProcessStartInfo(); + proc3.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; + proc3.UseShellExecute = true; + proc3.WorkingDirectory = pkgPath; + proc3.FileName = "cmd.exe"; + // find nupkg in pkgPath + string[] pushPkg = Directory.GetFiles(pkgPath, "*.nupkg", SearchOption.TopDirectoryOnly); + foreach (String file in pushPkg) { + proc3.Arguments = "/c "+"cpush " + file + " -d"; + } + process3.StartInfo = proc3; + System.Threading.Thread.Sleep(2000); + process3.Start(); +} +} + + + \ No newline at end of file