
กรอบการอัปเดตซอฟต์แวร์ที่ปรับแต่งได้ง่ายสำหรับโครงการ C# .NET พร้อม UIs ในตัวสำหรับ Winforms, WPF และ Avalonia
NetSparkle เป็นเฟรมเวิร์กซอฟต์แวร์ที่กำหนดค่าได้สูงสำหรับ C# ที่เข้ากันได้กับ. NET 6+ และ. NET Framework 4.6.2+ มี UIs ที่สร้างไว้ล่วงหน้าสำหรับ. NET Framework (Winforms, WPF) และ. Net 6+ UI ในตัว! คุณให้บริการที่ไหนสักแห่งบนอินเทอร์เน็ตแอปที่มีการอัปเดตและข้อมูลเวอร์ชันพร้อมกับบันทึกย่อในรูปแบบ Markdown หรือ HTML ไลบรารีนี้จะช่วยให้คุณตรวจสอบการอัปเดตแสดงโน้ตประจำรุ่นของผู้ใช้และเสนอให้ดาวน์โหลด/ติดตั้งซอฟต์แวร์เวอร์ชันใหม่
การดาวน์โหลดอัปเดตที่รองรับในตัว:
โปรดดู UPGRADING.MD สำหรับข้อมูลเกี่ยวกับการเปลี่ยนแปลงเวอร์ชันสำคัญการอัปเดต ฯลฯ
NetSparkle มีให้บริการผ่าน NUGET เพื่อเลือกแพ็คเกจ NuGet ที่จะใช้:
NetSparkleUpdater.SparkleUpdater package หากคุณไม่สนใจที่จะมี UI ในตัวและสามารถจัดการสิ่งต่าง ๆ ได้ด้วยตัวเอง| บรรจุุภัณฑ์ | ใช้เคส | ปล่อย | ดูตัวอย่าง | การดาวน์โหลด |
|---|---|---|---|---|
| NetSparkleupdater.sparkleupdater | แพ็คเกจหลัก; ใช้ UI ที่กำหนดเอง 100% หรือไม่มี UI (ไม่มีอะไรในตัว) | |||
| Winforms UI (. NET Framework) | NetSparkle กับ Winforms UI ในตัวในตัว | |||
| Winforms UI (.NET 6+) | NetSparkle กับ Winforms UI ในตัวในตัว | |||
| WPF UI (.NET Framework และ. NET 6+) | NetSparkle กับ WPF UI ในตัว | |||
| Avalonia UI | NetSparkle กับ Avalonia UI ในตัว | |||
| เครื่องมือเครื่องกำเนิดแอป | เครื่องมือ CLI netsparkle-generate-appcast (รวม ED25519 ผู้ช่วย) | |||
| เครื่องมือ DSA Helper | เครื่องมือ netsparkle-dsa CLI (ผู้ช่วย DSA) |
ข้อมูลด่วนสำหรับการติดตั้งเครื่องมือ:
dotnet tool install --global NetSparkleUpdater.Tools.AppCastGenerator ; มีให้บริการในรูปแบบ netsparkle-generate-appcast บนบรรทัดคำสั่งของคุณหลังจากการติดตั้งdotnet tool install --global NetSparkleUpdater.Tools.DSAHelper ; มีให้เป็น netsparkle-dsa บนบรรทัดคำสั่งของคุณหลังจากการติดตั้ง เส้นทางการอัปเดตซอฟต์แวร์ทั่วไปสำหรับซอฟต์แวร์ชิ้นส่วนโปรเฟสเซอร์อาจมีลักษณะเช่นนี้:
dotnet publish )ตอนนี้ NetSparkleupdater ไม่ได้ ช่วยคุณ 1. , 2. , 2. หรือ 4 "ทำไมไม่?" คุณอาจถาม:
sudo ด้วยเหตุผลใดก็ตามมีตัวอย่างของการทำเช่นนั้นในตัวอย่าง MacOS Avaloniaในการสร้างไฟล์ Cast แอปของคุณดูส่วนการหล่อแอพของเอกสารนี้
เราเปิดให้มีการมีส่วนร่วมที่อาจทำให้กระบวนการติดตั้ง/อัปเดตโดยรวมง่ายขึ้นสำหรับผู้ใช้ โปรดยื่นปัญหาก่อนกับแนวคิดของคุณก่อนที่จะเริ่มงานเพื่อให้เราสามารถพูดคุยเกี่ยวกับเรื่องนี้
โปรดดูที่โครงการตัวอย่างในที่เก็บนี้สำหรับตัวอย่างการใช้งานพื้นฐานที่รันได้ !! มีตัวอย่างเกี่ยวกับการใช้ UIs ในตัวแต่ละตัวรวมถึงตัวอย่าง "ทำเองใน UI ของคุณเอง"!
dotnet tool install --global NetSparkleUpdater.Tools.AppCastGeneratornetsparkle-generate-appcast --generate-keys
# By default, your Ed25519 signatures are stored on disk in your local
# application data folder in a subdirectory called `netsparkle`.
# If you want to export your keys to the console, you can do:
netsparkle-generate-appcast --exportMainWindow หรือรูปแบบหลักหรือที่คล้ายกัน: private SparkleUpdater _sparkle ;
// on your main thread...
_sparkle = new SparkleUpdater (
"https://mywebsite.com/appcast.xml" , // link to your app cast file - change extension to .json if using json
new Ed25519Checker ( SecurityMode . Strict , // security mode -- use .Unsafe to ignore all signature checking (NOT recommended!!)
"base_64_public_key_from_generate_app_cast_tool" ) // your base 64 public key
) {
UIFactory = new NetSparkleUpdater . UI . WPF . UIFactory ( icon ) , // or null, or choose some other UI factory, or build your own IUIFactory implementation!
RelaunchAfterUpdate = false , // set to true if needed
} ;
_sparkle . StartLoop ( true ) ; // will auto-check for updatesInnoSetup (Windows), ไฟล์ DMG (Linux), ไฟล์. tar.gz (Linux) หรือคล้ายกัน ข้อมูลเพิ่มเติมในส่วนการอัพเดททำงานnetsparkle-generate-appcast --help สำหรับตัวเลือก): netsparkle-generate-appcast -b binary/folder -p change/log/folder -u https://example.com/downloads -l https://example.com/downloads/changelogs.signature หรือไฟล์ที่คล้ายกัน) ไปยังตำแหน่งที่เหมาะสมบนเซิร์ฟเวอร์ของคุณSparkleUpdater.LogWriter เพื่อดูว่ามีข้อมูลการดีบักที่เป็นประโยชน์ใด ๆ ที่ปรากฏบนคอนโซล! ในไฟล์โครงการของคุณตรวจสอบให้แน่ใจว่าคุณตั้งค่าบางอย่างเพื่อให้ห้องสมุดสามารถอ่านในรายละเอียดที่เกี่ยวข้องในภายหลัง หมายเหตุ: คุณสามารถใช้ IAssemblyAccessor ของคุณเองเพื่อโหลดข้อมูลเวอร์ชันจากที่อื่น อย่างไรก็ตามการตั้งค่าสิ่งต่าง ๆ ในไฟล์โครงการของคุณเป็นเรื่องง่ายและ NetSparkleUpdater สามารถอ่านได้ในสภาพปกติ!
< PropertyGroup >
< Version >1.0.2-beta1</ Version > <!-- accepts semver -->
< AssemblyVersion >1.0.2</ AssemblyVersion > <!-- only accepts Major.Minor.Patch.Revision -->
< AssemblyTitle >My Best App</ AssemblyTitle >
<!-- When using AssemblyDiagnosticsAccessor, accessor.AssemblyTitle is actually the
<Product> information due to limitations with the way the diagnostics access works -->
< Description >My app is cool (not required)</ Description >
< Company >My Company Name (required unless you set the IAssemblyAccessor save path yourself)</ Company >
< Product >My Product (required unless you set the IAssemblyAccessor save path yourself; set to product name e.g. MyBestApp)</ Product >
< Copyright >2024 MyCompanyName</ Copyright >
</ PropertyGroup > หมายเหตุสำคัญ: ใน. NET 8+ การเปลี่ยนแปลงเกิดขึ้นในแกนกลางของ. NET ที่ทำให้แฮช GIT/ซอร์สโค้ดของคุณรวมอยู่ในหมายเลข <Version> ของแอปของคุณ พฤติกรรมนี้ไม่สามารถหลีกเลี่ยงได้โดย NetSparkleupdater ในเวลานี้เนื่องจากเราพึ่งพา AssemblyInformationalVersionAttribute และพฤติกรรมของคุณลักษณะนี้เปลี่ยนไป ผู้ใช้ของคุณอาจได้รับการบอกกล่าวว่าพวกเขากำลังทำงานอยู่ที่ 1.0.0+commitHashHere โดย NetSparkleUpdater (และแอพดั้งเดิมของคุณเอง!) นอกจากนี้เรายังขอแนะนำให้เพิ่มบรรทัดต่อไปนี้ในไฟล์โครงการของคุณ (ใน <PropertyGroup> ใหม่หรือบรรทัดที่มีอยู่):
< IncludeSourceRevisionInInformationalVersion >false</ IncludeSourceRevisionInInformationalVersion > // NOTE: Under most, if not all, circumstances, SparkleUpdater should be initialized on your app's main UI thread.
// This way, if you're using a built-in UI with no custom adjustments, all calls to UI objects will automatically go to the UI thread for you.
// Basically, SparkleUpdater's background loop will make calls to the thread that the SparkleUpdater was created on via SyncronizationContext.
// So, if you start SparkleUpdater on the UI thread, the background loop events will auto-call to the UI thread for you.
_sparkle = new SparkleUpdater (
"http://example.com/appcast.xml" , // link to your app cast file
new Ed25519Checker ( SecurityMode . Strict , // security mode -- use .Unsafe to ignore all signature checking (NOT recommended!!)
"base_64_public_key" ) // your base 64 public key -- generate this with the NetSparkleUpdater.Tools.AppCastGenerator .NET CLI tool on any OS
) {
UIFactory = new NetSparkleUpdater . UI . WPF . UIFactory ( icon ) , // or null, or choose some other UI factory, or build your own IUIFactory implementation!
RelaunchAfterUpdate = false , // default is false; set to true if you want your app to restart after updating (keep as false if your installer will start your app for you)
CustomInstallerArguments = "" , // set if you want your installer to get some command-line args
} ;
_sparkle . StartLoop ( true ) ; // `true` to run an initial check online -- only call StartLoop **once** for a given SparkleUpdater instance!ในเหตุการณ์แรกแอปพลิเคชันไฟล์แอพ Cast XML ของคุณจะถูกดาวน์โหลดอ่านและเปรียบเทียบกับเวอร์ชันที่กำลังทำงานอยู่ในปัจจุบัน หากมีการอัปเดตซอฟต์แวร์ภายในผู้ใช้จะได้รับแจ้งด้วยการแจ้งเตือนขนมปังเล็กน้อย (หากรองรับโดย UI และเปิดใช้งาน) หรือด้วยกล่องโต้ตอบอัปเดตที่มีบันทึกย่อของคุณ จากนั้นผู้ใช้สามารถเพิกเฉยต่อการอัปเดตขอให้ได้รับการเตือนในภายหลังหรือดาวน์โหลด/ติดตั้งทันที
หากคุณต้องการตรวจสอบการอัปเดตในพื้นหลังโดยไม่มีผู้ใช้เห็นอะไรเลยให้ใช้
var updateInfo = _sparkle . CheckForUpdatesQuietly ( ) ;หากคุณต้องการมีรายการเมนูสำหรับผู้ใช้เพื่อตรวจสอบการอัปเดตเพื่อให้ผู้ใช้สามารถดู UI ได้ในขณะที่ NetSparkle ค้นหาการอัปเดตให้ใช้
_sparkle . CheckForUpdatesAtUserRequest ( ) ;หากคุณมีไฟล์ที่ต้องการการบันทึกสมัครรับเหตุการณ์ PreparingToExit:
_sparkle . PreparingToExit += ( ( x , cancellable ) =>
{
// ask the user to save, whatever else is needed to close down gracefully
} ) ; โปรดทราบว่าหากคุณ ไม่ได้ ใช้ UIFactory คุณ ต้อง ใช้เหตุการณ์ CloseApplication หรือ CloseApplicationAsync เพื่อปิดแอปพลิเคชันของคุณ มิฉะนั้นไฟล์อัปเดตที่ดาวน์โหลดของคุณจะไม่ถูกเรียกใช้/อ่าน! ข้อยกเว้นเพียงอย่างเดียวคือถ้าคุณต้องการจัดการทุกด้านของการติดตั้งแพ็คเกจอัปเดตด้วยตัวเอง
ไฟล์ที่เปิดใช้งานการอัปเดตที่ดาวน์โหลดมาของคุณจะรอเพียง 90 วินาทีก่อนที่จะยอมแพ้! ตรวจสอบให้แน่ใจว่าซอฟต์แวร์ของคุณปิดภายใน 90 วินาทีของการปิด/ปิดการใช้งานที่ถูกเรียกใช้หากคุณใช้กิจกรรมเหล่านั้น! หากคุณต้องการเหตุการณ์ที่สามารถยกเลิกได้เช่นเมื่อผู้ใช้ต้องการถามว่าสามารถปิดได้หรือไม่ (เช่นเพื่อบันทึกงานของพวกเขา) ให้ใช้ PreparingForExit หรือ PreparingToExitAsync
IUIFactory ; ตั้งค่า SparkleUpdater.UIFactory เพื่อใช้อินสแตนซ์ของวัตถุของคุณICheckingForUpdates สำหรับ UI ของคุณที่บอกผู้ใช้ว่า SparkleUpdater กำลังตรวจสอบการอัปเดตIDownloadProgress สำหรับ UI ของคุณที่แสดงให้ผู้ใช้เห็นว่ามีการดาวน์โหลดการอัปเดตIUpdateAvailable สำหรับ UI ของคุณที่แสดงให้ผู้ใช้เห็นว่าการอัปเดตพร้อมใช้งานพร้อมกับบันทึกประจำรุ่นIAppCastDataDownloader เพื่อตั้งค่าวิธีการของคุณเองสำหรับการดาวน์โหลดข้อมูล CAST APP Set SparkleUpdater.AppCastDataDownloader เพื่อใช้อินสแตนซ์ของวัตถุของคุณ .. NetSparkle รวมการใช้งาน LocalFileAppCastDownloader ครั้งตามค่าเริ่มต้น: WebRequestAppCastDataDownloader สำหรับการดาวน์โหลดข้อมูลการร่ายแอพจากอินเทอร์เน็ตที่มีขนาดใหญ่IAppCastFilter เพื่อทำการกรองที่กำหนดเองบนวัตถุ AppCastItem ในแอปที่ดาวน์โหลดของคุณเช่นเดียวกับการพิจารณาชุดย่อยของรายการที่กำหนดเป็นการอัปเดตที่ถูกต้องสำหรับแอปพลิเคชันของคุณเท่านั้น ตั้งค่า AppCastHelper.AppCastFilter ( SparkleUpdater.AppCastHelper.AppCastFilter ) เพื่อใช้อินสแตนซ์ของวัตถุของคุณ NetSparkle มีคลาส ChannelAppCastFilter ซึ่งคุณสามารถใช้เพื่อกรองรายการโดยช่องผลิตภัณฑ์ที่กำหนด (เช่น Alpha, Beta) หากแอปพลิเคชันของคุณใช้คุณสมบัติเหล่านั้นIAppCastGenerator เพื่อควบคุมวิธีการที่แอป Casts ถูกทำให้เป็นอนุกรมและ deserialized; Set SparkleUpdater.AppCastGenerator ใช้ประโยชน์จากวัตถุของคุณ NetSparkle รวมถึงการใช้งานสองครั้ง: XMLAppCastGenerator สำหรับ XML Serialization/Deserialization; และ JsonAppCastGenerator สำหรับ JSON Serialization/Deserialization เครื่องมือ CLI เครื่องกำเนิดแอพพลิเคชั่นสามารถส่งออกทั้ง XML และ JSON App CastsIAssemblyAccessor เพื่อควบคุมวิธีการที่เวอร์ชันลิขสิทธิ์และรายละเอียดผลิตภัณฑ์อื่น ๆ ถูกโหลดสำหรับแอปพลิเคชันของคุณ ตั้งค่า Configuration.AssemblyAccessor ( SparkleUpdater.Configuration.AssemblyAccessor ) เพื่อใช้อินสแตนซ์ของวัตถุของคุณ NetSparkle มีการใช้งานเริ่มต้น AssemblyDiagnosticsAccessor ซึ่งควรทำงานในกรณีทั่วไปของการโหลดข้อมูลจากแอสเซมบลีที่กำหนดILogger และตั้งค่า SparkleUpdater.LogWriter โดยค่าเริ่มต้นคลาส LogWriter จะถูกใช้ (ซึ่งมีคุณสมบัติ LogWriterOutputMode เพื่อควบคุมว่าบันทึกถูกเขียนลงใน Console Trace ฯลฯ )ISignatureVerifier เพื่อเปลี่ยนวิธีการจัดการลายเซ็นของคุณสำหรับการแสดงแอพดาวน์โหลด ฯลฯ ; Set SparkleUpdater.SignatureVerifier เพื่อใช้อินสแตนซ์ของวัตถุของคุณIUpdateDownloader เพื่อตั้งค่าวิธีการของคุณเองสำหรับการดาวน์โหลดและส่งความคืบหน้าในไฟล์อัปเดตแอพ (เช่นตัวติดตั้ง) สำหรับรายการหล่อแอปที่กำหนด Set SparkleUpdater.UpdateDownloader เพื่อใช้อินสแตนซ์ของวัตถุของคุณ .. NetSparkle มีการใช้งานสองครั้งโดยค่าเริ่มต้น: WebFileDownloader (ค่า LocalFileDownloader ต้น) เพื่อดาวน์โหลดไฟล์จากเว็บ/อินเทอร์เน็ต Configuration subclass เพื่อเปลี่ยนวิธีการบันทึกและโหลดข้อมูล NetSparkle บางอย่าง - เช่นข้อมูลเวอร์ชันที่ข้าม คลาสนี้เป็นคลาสที่ใช้อินสแตนซ์ IAssemblyAccessor เพื่อบันทึกและโหลดข้อมูลเวอร์ชันชื่อผลิตภัณฑ์ ฯลฯ NetSparkle มีการใช้งานสามครั้ง: RegistryConfiguration ซึ่งบันทึกและโหลดข้อมูลไปยัง Windows Registry (เริ่มต้นบน Windows); JSONConfiguration ซึ่งบันทึกและโหลดข้อมูลไปยังไฟล์ JSON (เริ่มต้นบน MACOS/Linux); และ DefaultConfiguration ซึ่งไม่ได้ทำอะไรเลยและทำหน้าที่เป็นทางเลือกในกรณีที่ JSONConfiguration ไม่สามารถหาตำแหน่งไฟล์ที่ถูกต้องเพื่อบันทึกและโหลดข้อมูล หากต้องการใช้อินสแตนซ์ของคลาสของคุณให้ตั้งค่า SparkleUpdater.ConfigurationRegistryConfiguration ช่วยให้คุณเปลี่ยนเส้นทางรีจิสทรีได้อย่างรวดเร็วซึ่งรายการจะถูกบันทึกผ่าน BuildRegistryPathJSONConfiguration ช่วยให้คุณเปลี่ยนเส้นทางไฟล์ได้อย่างรวดเร็วซึ่งข้อมูลถูกบันทึกผ่าน GetSavePathAppCastHelper ถ้าคุณต้องการควบคุมอย่างเต็มที่กับกระบวนการดาวน์โหลดและการแยกวิเคราะห์แอป โปรดทราบว่าคุณสามารถทำทุกอย่างที่คุณต้องทำผ่านคุณสมบัติ AppCastHelper (รวมถึง IAppCastFilter AppCastFilter ) แต่การแบ่งประเภทย่อยจะช่วยให้คุณควบคุมกระบวนการทั้งหมดได้อย่างสมบูรณ์ หากต้องการใช้อินสแตนซ์ของคลาสของคุณให้ตั้งค่า SparkleUpdater.AppCastHelperReleaseNotesGrabber เพื่อควบคุมกระบวนการดาวน์โหลด (และแสดงผล) กระบวนการ หากต้องการใช้อินสแตนซ์ของชั้นเรียนของคุณให้ตั้งค่า UIFactory.ReleaseNotesGrabberOverrideWebFileDownloader หากคุณไม่ต้องการใช้ IUpdateDownloader ด้วยตัวเองและต้องการแทนที่ฟังก์ชั่นหรือสองรายการเช่น CreateHttpClient หรือ RetreiveDestinationFileNameAsync หากต้องการใช้อินสแตนซ์ของคลาสของคุณให้ตั้งค่า SparkleUpdater.UpdateDownloaderWebRequestAppCastDataDownloader หากคุณไม่ต้องการใช้ IAppCastDataDownloader และต้องการแทนที่ฟังก์ชั่นหรือสองรายการเช่น CreateHttpClient หากต้องการใช้อินสแตนซ์ของคลาสของคุณให้ตั้งค่า SparkleUpdater.AppCastDataDownloaderLogWriter เพื่อใช้ฟังก์ชัน PrintMessage ; เนื่องจาก ILogger เป็นอินเทอร์เฟซที่ค่อนข้างง่ายคุณจึงสามารถใช้อินเทอร์เฟซนั้นได้หากความต้องการของคุณซับซ้อน หากต้องการใช้อินสแตนซ์ของคลาสของคุณให้ตั้งค่า SparkleUpdater.LogWriterSparkleUpdater เพื่อใช้ฟังก์ชั่นที่เกี่ยวข้องกับการติดตั้งที่แตกต่างกันรวมถึง:GetWindowsInstallerCommandGetInstallerCommandRunDownloadedInstallerGetDownloadPathForAppCastItemUIFactory หากคุณไม่ต้องการใช้อินเทอร์เฟซ IUIFactory ทั้งหมดด้วยตัวคุณเองและต้องการกำหนดค่าฟังก์ชั่นหรือสองอย่าง หากต้องการใช้อินสแตนซ์ของชั้นเรียนของคุณให้ตั้งค่า SparkleUpdater.UIFactory IAppCastFilter คุณสามารถเปลี่ยนวิธีการกรองรายการแอปของคุณผ่านคุณสมบัติ AppCastHelper.AppCastFilter (ผ่านอินเตอร์เฟส IAppCastFilter ) สิ่งนี้ช่วยให้คุณสามารถเปลี่ยนรายการที่มีให้กับผู้ใช้ปลายทางของคุณ
NetSparkle มีการใช้งาน IAppCastFilter ในตัวสำหรับการกรองตามช่องทางที่เรียกว่า ChannelAppCastFilter สำหรับตัวอย่างบางส่วนเกี่ยวกับวิธีการใช้คลาสนั้นดูการทดสอบหน่วยที่นี่ โดยพื้นฐานแล้วตั้ง List<string> ChannelSearchNames เป็นช่องทางที่คุณต้องการกรองโดย หากคุณต้องการเก็บรายการที่ไม่มีข้อมูลช่อง (เช่น 1.2.3 ) ให้ตั้งค่า KeepItemsWithNoChannelInfo เป็น true
หากต้องการตั้งค่าช่องทางบนรายการร่ายแอปของคุณ / ในแอปของคุณให้ใช้คุณสมบัติ --channel ของเครื่องมือ CAT CLI <Version>1.0.2-beta1</Version> แอพหรือตั้งค่าคุณสมบัติ <Version> ของไฟล์โครงการของคุณเป็นเวอร์ชันที่เข้ากันได้กับ SEMVER ที่ใช้งานได้ หรือหากคุณกำลังสร้างแอปของคุณด้วยตนเองให้ตั้งค่า <sparkle:channel>YourChannelHere</sparkle:channel> คุณสมบัติบน <item> (หรือถ้าใช้ JSON, คุณสมบัติ channel )
NetSparkleupdater ไม่จำเป็นต้องใช้กับ UI เลย คุณสามารถทำทุกอย่างด้วยตัวเองหรือแม้กระทั่งให้ไลบรารีเรียกใช้การอัปเดตที่คุณดาวน์โหลดโดยอัตโนมัติโดยการตั้งค่า SparkleUpdater.UserInteractionMode = UserInteractionMode.DownloadAndInstall repo นี้มีตัวอย่างเกี่ยวกับการทำสิ่งต่าง ๆ ด้วยตัวเองโดยไม่มี UI ที่สร้างไว้ล่วงหน้าใน src/netsparkle.samples.handleeventsyourself
หากคุณต้องการ UI เราเสนอ UIs ที่สร้างไว้ล่วงหน้าในแพ็คเกจ NuGet ที่แตกต่างกันด้วยตัวเลือกที่ปรับแต่งได้จำนวนเล็กน้อยสำหรับ Winforms, WPF และ Avalonia UIs จะถูกกระตุ้นผ่านการใช้งาน IUIFactory ที่เรียกว่า UIFactory ในแต่ละตัวเลือกในตัว วิธีการส่วนใหญ่ใน UIFactory สามารถแทนที่ได้หากคุณต้องการปรับแต่งพฤติกรรมและ ProcessWindowAfterInit ช่วยให้คุณปรับแต่งแต่ละหน้าต่างหลังจากทำ
หากคุณต้องการม้วน UI ของคุณเองทั้งหมดเพียงแค่ใช้อินเทอร์เฟซ IUIFactory กับไลบรารี UI ที่คุณต้องการใช้ คุณสามารถคัดลอกหรือนำโมเดลมุมมองกลับมาใช้ใหม่รหัส ฯลฯ จากตัวเลือก prebuilt ของ NetSparkleUpdater และคัดลอก+รหัสการวางจาก repo นี้ลงในตัวคุณเองอาจเป็นวิธีที่ดีและรวดเร็วในการเริ่มต้น อย่าลืมตั้งค่าคุณสมบัติ SparkleUpdater.UIFactory ด้วยตัวอย่างของการใช้งาน IUIFactory ของคุณ!
โปรดทราบ: NetSparkle โดยทั่วไปไม่พยายามกังวลเกี่ยวกับการทำเกลียว (เช่นการเรียกไปยังเธรดหลัก) ยกเว้นการวนรอบพื้นหลังไปยังเธรดหลักที่เริ่มต้นอินสแตนซ์ SparkleUpdater กล่าวอีกนัยหนึ่งโดยทั่วไปแล้ว NetSparkle จะทำทุกอย่างบนเธรดที่สร้างอินสแตนซ์ SparkleUpdater สำหรับแอพส่วนใหญ่นี่จะดีเพราะพวกเขาใช้เธรด UI หลักของพวกเขา เมื่อมีข้อสงสัยสำหรับความต้องการ UI ของคุณเองตรวจสอบให้แน่ใจว่าได้ตรวจสอบ InvokeRequired บน winforms และบน WPF/Avalonia สิ่งที่จอมพลไปยังเธรด UI (เว้นแต่คุณจะใช้ข้อมูลที่มีผลผูกพันในกรณีนี้
การผ่านการใช้งาน IUIFactory ของคุณเองที่เริ่มต้น Windows/สิ่งต่าง ๆ บนเธรดใหม่ลงใน SparkleUpdater ไม่ใช่การกำหนดค่าที่รองรับ หากคุณต้องการเรียกใช้ UI ของคุณเองในหลายเธรด (เช่นสำหรับ winforms ที่จะไม่มีหน้าต่างของ NetSparkleupdater ปิดเมื่อรูปแบบหลักปิด) ให้ทำเช่นนั้นโดยใช้เหตุการณ์ของ SparkleUpdater และไม่ใช่ UIFactory ; โปรดดู SRC/NetSparkle.samples.forms.multithread ตัวอย่างสำหรับตัวอย่างที่ใช้งานได้จริงของวิธีการทำเช่นนี้
แอป Cast เป็นเพียงไฟล์ XML หรือ JSON มันมีฟิลด์เช่นชื่อและคำอธิบายของผลิตภัณฑ์ของคุณรวมถึงคำจำกัดความต่อการเปิดตัวซอฟต์แวร์ของคุณ
เราขอแนะนำอย่างยิ่งให้คุณใช้เครื่องมือ NetSparkle-Generate-Appcast เพื่อสร้าง (และใหม่กว่าสร้างใหม่/อัปเดต) ไฟล์เพราะสามารถช่วยดูแลข้อกำหนดการลงนามทั้งหมดให้คุณ
dotnet tool install --global NetSparkleUpdater.Tools.AppCastGeneratornetsparkle-generate-appcast คุณสามารถใช้ netsparkle-generate-appcast --help เพื่อดูรายการตัวเลือกทั้งหมดสำหรับเครื่องมือนี้ โดยค่าเริ่มต้น NetSparkle ใช้แอพ XML ที่เข้ากันได้กับ Sparkle ส่วนใหญ่ NetSparkle ใช้ sparkle:signature มากกว่า sparkle:edSignature เพื่อให้คุณสามารถเลือกวิธีลงนามในไฟล์/แอปของคุณ (หากคุณต้องการใช้ sparkle:edSignature , Pass --use-ed25519-signature-attribute กับเครื่องกำเนิดแอพ Cast) โปรดทราบว่า NetSparkle เข้ากันได้กับและใช้ลายเซ็น ISignatureVerifier โดยค่าเริ่มต้น
นี่คือตัวอย่างแอป XML Cast:
<? xml version = " 1.0 " encoding = " UTF-8 " ?>
< rss xmlns : dc = " http://purl.org/dc/elements/1.1/ " xmlns : sparkle = " http://www.andymatuschak.org/xml-namespaces/sparkle " version = " 2.0 " >
< channel >
< title >NetSparkle Test App</ title >
< link >https://netsparkleupdater.github.io/NetSparkle/files/sample-app/appcast.xml</ link >
< description >Most recent changes with links to updates.</ description >
< language >en</ language >
< item >
< title >Version 2.0 (2 bugs fixed; 3 new features)</ title >
< sparkle : releaseNotesLink >
https://netsparkleupdater.github.io/NetSparkle/files/sample-app/2.0-release-notes.md
</ sparkle : releaseNotesLink >
< pubDate >Thu, 27 Oct 2016 10:30:00 +0000</ pubDate >
< enclosure url = " https://netsparkleupdater.github.io/NetSparkle/files/sample-app/NetSparkleUpdate.exe "
sparkle : version = " 2.0 "
sparkle : os = " windows "
length = " 12288 "
type = " application/octet-stream "
sparkle : signature = " NSG/eKz9BaTJrRDvKSwYEaOumYpPMtMYRq+vjsNlHqRGku/Ual3EoQ== " />
</ item >
</ channel >
</ rss > NetSparkle อ่านแท็ก <item> เพื่อพิจารณาว่ามีการอัปเดตหรือไม่
แท็กสำคัญในแต่ละรายการ <item> คือ:
<description><sparkle:releaseNotesLink><sparkle:releaseNotesLink><description> อยู่จะใช้แทนsparkle:signature , ตัวเลือก: DSA/ED25519 ลายเซ็นของเอกสาร; NetSparkle ไม่ได้ตรวจสอบลายเซ็นนี้สำหรับคุณเว้นแต่คุณจะตั้งค่า ReleaseNotesGrabber.ChecksReleaseNotesSignature เป็น true แต่คุณอาจตรวจสอบการเปลี่ยนแปลงของ Signatures หากคุณชอบหรือตั้งค่า ReleaseNotesGrabber.ChecksReleaseNotesSignature = true<pubDate>sparkle:channel : Channel สำหรับรายการ Cast แอพนี้เช่น beta (ไม่จำเป็น) - ยอมรับเฉพาะ 1 ช่อง<enclosure>url : URL ของไฟล์อัปเดตsparkle:version : หมายเลขเวอร์ชันที่อ่านได้ของการอัปเดตนี้length ตัวเลือก: (ไม่ผ่านการตรวจสอบ) ขนาดของไฟล์อัปเดตในไบต์type : ละเว้นsparkle:signature : DSA/ED25519 ลายเซ็นของไฟล์อัปเดตsparkle:criticalUpdate , เป็นทางเลือก: ถ้าเท่ากับ true หรือ 1 , UI จะระบุว่านี่เป็นการอัปเดตที่สำคัญsparkle:os : ระบบปฏิบัติการสำหรับรายการหล่อแอป ค่าเริ่มต้นไปยัง Windows หากไม่ได้ให้มา สำหรับ Windows ให้ใช้ "win" หรือ "windows"; สำหรับ macOS ให้ใช้ "macOS" หรือ "OSX"; สำหรับ Linux ให้ใช้ "Linux" โดยค่าเริ่มต้นคุณต้องมีลายเซ็น 2 ( SecurityMode.Strict ):
sparkle:signature="..." )หมายเหตุ: เครื่องมือเครื่องกำเนิดแอพ Cast สร้างทั้งสองลายเซ็นสำหรับคุณเมื่อมันสร้างไฟล์ appcast.xml ใหม่
คุณสามารถสร้างลายเซ็น ED25519 โดยใช้เครื่องมือ AppCastGenerator (จากแพ็คเกจ NUGET นี้หรือในซอร์สโค้ดที่นี่) เครื่องมือนี้ต้องการ. NET 6, 7, 8 หรือ 9 รันไทม์เดสก์ท็อปที่จะติดตั้ง โปรดดูส่วนด้านล่างสำหรับตัวเลือกและตัวอย่างเกี่ยวกับการสร้างคีย์ ED25519 และใช้งานเมื่อสร้างแอป
AppCastGenerator (จากแพ็คเกจ NUGET นี้หรือในซอร์สโค้ดที่นี่) เพื่อสร้างไฟล์แคสต์แอปของคุณได้อย่างง่ายดาย ตัวเลือกที่มีอยู่มีการอธิบายไว้ด้านล่าง คุณสามารถติดตั้งบน CLI ของคุณผ่าน dotnet tool install --global NetSparkleUpdater.Tools.AppCastGeneratorstring.Format หรือคล้ายกันเป็นสิ่งที่ยอดเยี่ยม)หากคุณต้องการใช้แอป JSON แทนที่จะเป็น XML:
--output-type json เมื่อสร้างแอพ Cast File ของคุณผ่านตัวสร้างแอปSparkleUpdater.AppCastGenerator เป็น new JsonAppCastGenerator(mySparkleUpdater.LogWriter)JsonAppCastGenerator.HumanReadableOutput เป็น falseไม่มีตัวเลือกบางอย่างที่คุณต้องการดู? ยื่นปัญหาเกี่ยวกับ repo นี้หรือเพิ่มด้วยตัวคุณเองและส่งคำขอดึงมาให้เรา!
--show-examples : พิมพ์ตัวอย่างการใช้งานไปยังคอนโซล--help : แสดงตัวเลือกทั้งหมดและคำอธิบายของพวกเขา -a / --appcast-output-directory : ไดเรกทอรีที่จะเขียนไฟล์ output appcast.xml ตัวอย่างการใช้: -a ./MyAppCastOutput-e / --ext : เมื่อมองหาไฟล์เพื่อเพิ่มลงในแอปที่หล่อให้ใช้ส่วนขยายที่กำหนดเมื่อค้นหาไฟล์ ค่าเริ่มต้นเป็น exe ตัวอย่างการใช้: -e exe,msi-b / --binaries : เส้นทางไฟล์ไปยังไดเรกทอรีที่ควรค้นหาเมื่อมองหาไฟล์เพื่อเพิ่มลงในแอป ค่าเริ่มต้น . - ตัวอย่างการใช้: -b my/build/directory-r / --search-binary-subdirectories : จริงเพื่อค้นหาไดเรกทอรีไบนารีซ้ำสำหรับไบนารี; เท็จเพื่อค้นหาไดเรกทอรีด้านบนเท่านั้น ค่าเริ่มต้นเป็น false ตัวอย่างการใช้: -r .--single-file : ไฟล์เดียวที่จะเพิ่มลงในแอป Cast-หากตั้งค่า --binaries --ext ฯลฯ ทั้งหมดจะถูกละเว้น เป็นประโยชน์ในการใช้งานหากไฟล์เอาต์พุตของคุณไม่มีส่วนขยาย (เช่นการทำงานของ Unix) ตัวอย่างการใช้: --single-file path/to/my/file-f / --file-extract-version : ไม่ว่าจะแยกเวอร์ชันของไฟล์ออกจากชื่อไฟล์มากกว่าไฟล์ (เช่น DLL) หรือไม่ ค่าเริ่มต้นเป็น false ใช้เมื่อไฟล์ของคุณที่จะดาวน์โหลดโดย NetSparkleUpdater จะมีหมายเลขเวอร์ชันในชื่อไฟล์เช่น "แอปของฉัน 1.3.2-alpha1.exe" โปรดทราบว่าสิ่งนี้จะค้นหาเฉพาะรายการไดเรกทอรี/โฟลเดอร์สุดท้ายสี่รายการเท่านั้น ตัวอย่างการใช้: -f true--file-version : ใช้ตั้งค่าเวอร์ชันสำหรับไบนารีที่จะเข้าสู่การคัดเลือกแอป โปรดทราบว่าสามารถตั้งค่าเวอร์ชันนี้ได้เพียงครั้งเดียวดังนั้นเมื่อสร้างแอปหล่อตรวจสอบให้แน่ใจว่าคุณ: a) มีไบนารีเพียงหนึ่งเดียวในแอปของคุณ b) ใช้พารามิเตอร์ --reparse-existing เพื่อให้รายการเก่าได้รับ หากเครื่องกำเนิดไฟฟ้าพบ 2 ไบนารีที่ไม่มีรุ่นที่รู้จักและ --file-version ถูกตั้งค่าจะมีการปล่อยข้อผิดพลาด ตัวอย่างการใช้งาน: --file-version 1.3.2-o / --os : ระบบปฏิบัติการที่รายการหล่อแอปเป็นของ สตริงจะต้องมีหนึ่งในสิ่งต่อไปนี้: windows , mac , linux ค่าเริ่มต้นเป็น windows ตัวอย่างการใช้งาน: -o macos-arm64 ; -o windows-x64--description-tag : ข้อความที่จะใส่ในแอพ Cast Description Tag/ข้อมูล ค่าเริ่มต้นเป็น "การเปลี่ยนแปลงล่าสุดด้วยลิงก์ไปยังการอัปเดต" ตัวอย่างการใช้งาน: --description-tag "Hello I am a Cool App"--link-tag : ข้อความที่จะใส่ใน link ก/ข้อมูลการเชื่อมโยงแอป ควรเป็น URL ดาวน์โหลดแอปของคุณหากคุณใช้สิ่งนี้ ตัวอย่างการใช้งาน: --link-tag https://mysite.com/coolapp/appcast.xml-u / --base-url : ส่วนเริ่มต้นของ URL ที่จะใช้สำหรับการดาวน์โหลด ชื่อไฟล์ที่จะดาวน์โหลดจะถูกนำมาใช้หลังจากส่วนนี้ของ URL ตัวอย่างการใช้: -u https://myawesomecompany.com/downloads-l / --change-log-url : ส่วนเริ่มต้นของ URL เพื่อใช้สำหรับไฟล์บันทึกการเปลี่ยนแปลงของคุณ ไฟล์บันทึกการเปลี่ยนแปลงที่จะดาวน์โหลดจะถูกนำมาใช้หลังจากส่วนนี้ของ URL หากไม่ได้ระบุตัวเลือกนี้ข้อมูลบันทึกการเปลี่ยนแปลงจะถูกใส่ลงในแอป ตัวอย่างการใช้: -l https://myawesomecompany.com/changes-p / --change-log-path : เส้นทางไปยังไฟล์บันทึกการเปลี่ยนแปลงสำหรับซอฟต์แวร์ของคุณ สิ่งเหล่านี้คาดว่าจะอยู่ในรูปแบบ markdown โดยมีส่วนขยายของ .md ชื่อไฟล์ของไฟล์บันทึกการเปลี่ยนแปลงจะต้องมีเวอร์ชันของซอฟต์แวร์เช่น 1.3.2.md ตัวอย่างการใช้: -p path/to/change/logs (หมายเหตุ: เครื่องกำเนิดไฟฟ้าจะพยายามค้นหาบันทึกการเปลี่ยนแปลงที่มีชื่อไฟล์ถูกจัดรูปแบบเช่น MyApp 1.3.2.md )--change-log-name-prefix : คำนำหน้าสำหรับการเปลี่ยนชื่อไฟล์บันทึก โดยค่าเริ่มต้นเครื่องกำเนิดไฟฟ้าจะค้นหาชื่อไฟล์ด้วยรูปแบบ "[เวอร์ชัน] .MD" หากคุณตั้งค่าพารามิเตอร์นี้เป็น (ตัวอย่าง) "บันทึกการเปลี่ยนแปลงแอปของฉัน" มันจะค้นหาชื่อไฟล์ด้วยรูปแบบ "บันทึกแอปของฉันเปลี่ยน [เวอร์ชัน] .MD" เช่นเดียวกับ "[เวอร์ชัน] .MD"-n / --product-name : ชื่อผลิตภัณฑ์สำหรับซอฟต์แวร์ของคุณ ใช้เมื่อตั้งชื่อชื่อสำหรับนักแสดงแอปและรายการของคุณ ค่าเริ่มต้นไปยัง Application ตัวอย่างการใช้: -n "My Awesome App"-x / --url-prefix-version : เพิ่มหมายเลขเวอร์ชันเป็นคำนำหน้าไปยังชื่อไฟล์สำหรับ URL ดาวน์โหลด ค่าเริ่มต้นเป็นเท็จ ตัวอย่างเช่นถ้า --base-url คือ www.example.com/downloads เวอร์ชันของคุณคือ 1.4.2 และชื่อแอพของคุณคือ MyApp.exe URL ดาวน์โหลดของคุณจะกลายเป็น www.example.com/downloads/1.4.2/MyApp.exe ตัวอย่างการใช้: -x true--key-path : Path to NetSparkle_Ed25519.priv และ NetSparkle_Ed25519.pub ไฟล์ซึ่งเป็นคีย์ ED25519 ส่วนตัวและสาธารณะของคุณสำหรับการอัปเดตซอฟต์แวร์ของคุณตามลำดับ ตัวอย่างการใช้งาน: --key-path my/path/to/keysSPARKLE_PRIVATE_KEY และ SPARKLE_PUBLIC_KEY ก่อนที่จะใช้งาน generate_appcast เครื่องมือจัดลำดับความสำคัญของคีย์สภาพแวดล้อมเหนือคีย์ที่นั่งอยู่บนดิสก์!--signature-file-extension : Extension (ไม่มี . ) เพื่อใช้สำหรับไฟล์ลายเซ็นของแอป ค่าเริ่มต้นเป็น signature ตัวอย่างการใช้: --signature-file-extension txt--output-file-name : ชื่อไฟล์เอาต์พุตสำหรับแอป CAST . หรือส่วนขยาย ส่วนขยายถูกควบคุมโดยไม่ว่าจะเป็นเอาต์พุต XML หรือ JSON และไม่สามารถกำหนดค่าได้ ค่าเริ่มต้นเป็น 'appcast' แน่นอนคุณสามารถเปลี่ยนแปลงสิ่งนี้ได้ในภายหลังด้วยตัวเองหลังจากสร้างแอปแล้ว ตัวเลือกนี้มีไว้เพื่อความสะดวกเท่านั้น ตัวอย่างการใช้งาน: --output-file-name super_app_download_info--use-ed25519-signature-attribute : หากเป็นจริงและทำเอาต์พุต XML แอตทริบิวต์ลายเซ็นเอาท์พุทใน XML จะเป็น edSignature แทนที่จะเป็น signature เพื่อให้ตรงกับไลบรารี Sparkle ดั้งเดิม ไม่มีผลกระทบต่อแอป JSON--file-version : ใช้ตั้งค่าเวอร์ชันสำหรับไบนารีที่จะเข้าสู่การคัดเลือกแอป โปรดทราบว่าสามารถตั้งค่าเวอร์ชันนี้ได้เพียงครั้งเดียวดังนั้นเมื่อสร้างแอปหล่อตรวจสอบให้แน่ใจว่าคุณ: a) มีไบนารีเพียงหนึ่งเดียวในแอปของคุณ b) ใช้พารามิเตอร์ --reparse-existing เพื่อให้รายการเก่าได้รับ หากเครื่องกำเนิดไฟฟ้าพบ 2 ไบนารีที่ไม่มีรุ่นที่รู้จักและ --file-version ถูกตั้งค่าจะมีการปล่อยข้อผิดพลาด--critical-versions : รายการเวอร์ชันที่คั่นด้วยเครื่องหมายจุลภาคเพื่อทำเครื่องหมายว่ามีความสำคัญในการคัดเลือกแอป ต้องตรงกับข้อความเวอร์ชันอย่างแน่นอน เช่น "1.0.2,1.2.3.1"--reparse-existing : เปลี่ยนแอพที่มีอยู่อีกครั้งแทนที่จะเอาชนะมันและสร้างมันใหม่อีกครั้ง Skips เวอร์ชันที่มีอยู่แล้วในการคัดเลือกแอปดังนั้นหากคุณปรับใช้ไบนารีใหม่ด้วยเวอร์ชันเดียวกันคุณจะต้องแก้ไขแอปของคุณด้วยตนเองเพื่อลบรายชื่อเก่าสำหรับเวอร์ชันที่คุณกำลังปรับใช้อีกครั้ง ตัวอย่างการใช้: --reparse-existing true--overwrite-old-items : ทำให้แอพแสดงรายการที่จะเขียนใหม่ในแอพ Cast หากพบไบนารีบนดิสก์ที่มีหมายเลขเวอร์ชันเดียวกัน กล่าวอีกนัยหนึ่งถ้า 1.0.1 อยู่ในแอพที่หล่ออยู่แล้ว (ไม่ว่าจะเป็นจากการซ่อมแซมหรือจากไบนารีอื่น) และอีก 1.0.1 พบได้ในดิสก์จากนั้นข้อมูล 1.0.1 ในแอปจะถูกเขียนขึ้นมาจากไบนารีที่พบ โปรดทราบว่านี่หมายความว่าหากคุณมีหลายรุ่น 1.0.1 บนดิสก์ (ซึ่งคุณไม่ควรทำ ... ) คนสุดท้ายที่พบจะเป็นรุ่นในแอปของคุณ! ตัวอย่างการใช้งาน: --overwrite-old-items--human-readable : ถ้าเป็นจริงให้สร้างแอพเอาท์พุทไฟล์ Cast Human Readable (Newslines, Indents) ตัวอย่างการใช้งาน: --human-readable true--channel : Name of release channel for any items added into the app cast. Should be a single channel; does not support multiple channels at once, eg beta,gamma . Do not set if you want to use your release channel - if you set this to release or stable , those names/words will be treated as special channels and not as the stable channel. (Unless you want all your items to be in a specific channel, of course.) Example use: --channel beta--output-type : Output type for the app cast file ( xml or json ). Defaults to xml . Example use: --output-type json --public-key-override : Public key override (ignores whatever is in the public key file) for signing binaries. This overrides ALL other public keys set when verifying binaries, INCLUDING public key set via environment variables! If not set, uses --key-path (if set) or the default SignatureManager location. Not used in --generate-keys or --export . Example use: --public-key-override asoj341ljsdflj--private-key-override : Private key override (ignores whatever is in the private key file) for signing binaries. This overrides ALL other public keys set when verifying binaries, INCLUDING private key set via environment variables! If not set, uses --key-path (if set) or the default SignatureManager location. Not used in --generate-keys or --export . Example use: --private-key-override asoj341ljsdflj --generate-keys : If set, will attempt to generate NEW Ed25519 keys for you. Can be used in conjunction with --key-path . Once keys are successfully (or unsuccessfully) generated, the program ends without generating an app cast. By default, existing keys are not overwritten. This option defaults to false .--force : If set to true , will overwrite existing keys on disk. WARNING: THIS COULD RESULT IN A LOSS OF YOUR PUBLIC AND PRIVATE KEYS. USE WITH CAUTION. DO NOT USE IF YOU DO NOT KNOW WHAT YOU ARE DOING! THIS WILL MAKE NO ATTEMPT TO BACK UP YOUR DATA. This option defaults to false . Example use: --generate-keys --force true .--export : Export keys as base 64 strings to the console. Defaults to false . Example use: --export true . Output format: Private Key:
2o34usledjfs0
Public Key:
sdljflase;ru2u3
--generate-signature : Generate a signature for a file and output it to the console. Example use: --generate-signature path/to/app/MyApp.exe . Outputs in format: Signature: seljr13412zpdfj . Note that these options are only for verifying Ed25519 signatures. For DSA signatures, please use the DSAHelper tool. Both of the following options must be used together. You must have keys already generated in order to verify file signatures.
--verify : Path to the file that has a signature you want to verify.--signature : Base 64 signature of the file. Example use: --verify my/path/MyApp.exe --signature 123l4ijsdfzderu23 .
This will return either Signature valid (signature is good!) or Signature invalid (signature does not match file).
# ### Key Generation
# Generate Ed25519 keys for the first time
netsparkle-generate-appcast --generate-keys
# Store keys in a custom location
netsparkle-generate-appcast --key-path path/to/store/keys
# Pass in public key via command line
netsparkle-generate-appcast --public-key-override [YourPublicKeyHere]
# Pass in private key via command line
netsparkle-generate-appcast --private-key-override [YourPrivateKeyHere]
# By default, your Ed25519 signatures are stored on disk in your local
# application data folder in a subdirectory called `netsparkle`.
# If you want to export your keys to the console, you can do:
netsparkle-generate-appcast --export
# You can also store your keys in the following environment variables:
# set public key: SPARKLE_PUBLIC_KEY
# set private key: SPARKLE_PRIVATE_KEY
# ### Generate a signature for a binary without creating an app cast:
netsparkle-generate-appcast --generate-signature path/to/binary.exe
# ### Verifying Binaries
netsparkle-generate-appcast --verify path/to/binary.exe --signature base_64_signature
# ### Using a custom key location:
# If your keys are sitting on disk somewhere
# (`NetSparkle_Ed25519.priv` and `NetSparkle_Ed25519.pub` -- both
# in base 64 and both on disk in the same folder!), you can pass in
# the path to these keys like this:
netsparkle-generate-appcast --key-path path/to/keys/
# ### Generating an app cast
# Generate an app cast for Windows executables that are sitting in a
# specific directory
netsparkle-generate-appcast -a directory/for/appcast/output/ -e exe -b directory/with/binaries/ -o windows
# Add change log info to your app cast
netsparkle-generate-appcast -b binary/folder -p change/log/folder
# Customize download URL for binaries and change logs
netsparkle-generate-appcast -b binary/folder -p change/log/folder -u https://example.com/downloads -l https://example.com/downloads/changelogs
# Set your application name for the app cast
netsparkle-generate-appcast -n " My Awesome App " -b binary/folder
# Use file versions in file names, e.g. for apps like "My App 1.2.1.dmg"
netsparkle-generate-appcast -n " macOS version " -o macos -f true -b binary_folder -e dmg
# Don't overwrite the entire app cast file
netsparkle-generate-appcast --reparse-existing
# Don't overwrite the entire app cast file, but do overwrite items that are still on disk
netsparkle-generate-appcast --reparse-existing --overwrite-old-itemsPlease see the UPGRADING.md file for information on breaking changes and fixes between major versions.
ไม่. You can just reference the core library and handle everything yourself, including any custom UI. Check out the code samples for an example of doing that!
This isn't a built-in feature, as NetSparkleUpdater assumes that it can safely make calls/events to the UI on the thread that started the SparkleUpdater instance. However, if you'd like to do this, we have a sample on how to do this: NetSparkle.Samples.Forms.Multithread . Basically, instead of passing in a UIFactory to SparkleUpdater , you handle SparkleUpdater 's events yourself and show the UI however you want to show it - and yes, you can still use the built-in UI objects for this!
(Note that on Avalonia, the answer is always "No" since they only support one UI thread at this time.)
ใช่. You need to start the NetSparkleUpdater forms on a new thread(s). See the NetSparkle.Samples.Forms.Multithread sample for how to do this by handling events yourself and still using the built-in WinForms UIFactory .
See #238 and this documentation for the fix for making this work on the sample application. Basically, you need to use an app config file and manifest file to let Windows know that your application is DPI-aware. If that doesn't work for you, try some of the tips at this SO post.
ใช่!
--os command line parameter.macos-arm64 or windows-x64 rather than just macos or windows Trimming is a great way to reduce the file size of your application when it is self-published and/or built as a self-contained application. In short, trimming removes unused code from your applications, including external libraries, so you can ship your application with a reduced file size. To trim your application on publish, add <PublishTrimmed>true</PublishTrimmed> to your csproj file. If you want to trim all assemblies (including those that may not have specified they are compatible with trimming), add <TrimMode>full</TrimMode> to your csproj file; to only trim those that have opted-in, use <TrimMode>partial</TrimMode> . To enable warnings for trimming, add <SuppressTrimAnalysisWarnings>false</SuppressTrimAnalysisWarnings> .
There are other options to use, which you can learn more about on Microsoft's documentation here. For those applications that may not work with the built-in trimming options, please try Zack.DotNetTrimmer or other solutions you may find.
We recommend that you trim your application before publishing it and distributing it to your users. Some of NetSparkle's default dependencies are rather large, but the file size can be drastically reduced by the trim process. If you choose to trim your application, don't forget to test it after trimming and make sure you fix any warnings that come up!
You can also read more about trimming libraries here.
ใช่.
ใช่.
ใช่. In the app cast generator, you can do things like, -u ../ to make NetSparkle check the directory above the server's appcast.xml file for download files.
NetSparkleUpdater.SparkleUpdater is the right package if you want the library with no built-in UI. Otherwise, use NetSparkleUpdater.UI.{YourChoiceOfUI} , which will give you a built-in UI and the core library. Previous to 2.0, the UI libraries reference NetSparkle.New , which is now deprecated.
Here is the full list of deprecated packages:
com.pikleproductions.netsparkle -- replaced by NetSparkleUpdater.SparkleUpdatercom.pikleproductions.netsparkle.tools -- replaced by NetSparkleUpdater.Tools.AppCastGenerator and NetSparkleUpdater.Tools.DSAHelperNetSparkle.New -- replaced by NetSparkleUpdater.SparkleUpdaterNetSparkle.New.Tools -- replaced by NetSparkleUpdater.Tools.AppCastGenerator and NetSparkleUpdater.Tools.DSAHelperNetSparkleUpdater.Tools -- replaced by NetSparkleUpdater.Tools.AppCastGenerator and NetSparkleUpdater.Tools.DSAHelperNo. If your app is just using NetSparkle to work out if there is a later release - and you are not using the app cast as a way to refer to historical versions of your app in any way - then you don't need to add all the released versions into the app cast file.
Having just the latest version of your software in the app cast has the added side effect that you won't need all the binaries & changelogs of all the versions to be available to the app cast generator tool. For example, this might make an automated release build easier via GitHub Actions - because the only data required is the generated .exe and changelogs from your git repository.
SecurityMode.Unsafe or the following IAppCastHandler override: public override bool DownloadAndParse ( )
{
try
{
_logWriter . PrintMessage ( "Downloading app cast data..." ) ;
var appCast = _dataDownloader . DownloadAndGetAppCastData ( _castUrl ) ;
if ( ! string . IsNullOrWhiteSpace ( appCast ) )
{
Items . Clear ( ) ;
Items . AddRange ( ParseAppCast ( appcast ) ) ;
return true ;
}
}
catch ( Exception e )
{
_logWriter . PrintMessage ( "Error reading app cast {0}: {1} " , _castUrl , e . Message ) ;
}
return false ;
}The answer is both yes and no. No, because that is not the default behavior. Yes, because if you use installers for each of your versions, you can use your app cast to see which previous versions are available and download those versions. If your installers are standalone, they should install an old version just fine. Just keep in mind that if you install an old version and then there is a newer version in your app cast, after opening the older software, it will ask them if they want to update to the newer version!
Here's a summary of what you can do:
SparkleUpdater object_updateInfo = await _sparkle.CheckForUpdatesQuietly(); (no UI shown) or _sparkle.CheckForUpdatesAtUserRequest() (shows UI). I would recommend checking quietly because the UI method will always show the latest version. You can always show your own UI._updateInfo.Updates for the available versions in your app cast. You can compare it with your currently installed version to see which ones are new and which ones are old.await _sparkle.InitAndBeginDownload(update); with the update you want to download. The download path is provided in the DownloadFinished event._sparkle.InstallUpdate(update, _downloadPath);The Handle Events Yourself sample and the Rollback sample will be very helpful to you in learning how to do these sort of things.
ใช่. Implement IAppCastGenerator and set the SparkleUpdater.AppCastGenerator property to an instance of your class. You will have to implement the following methods:
AppCast DeserializeAppCast ( string appCastString ) ;
Task < AppCast > DeserializeAppCastAsync ( string appCastString ) ;
AppCast DeserializeAppCastFromFile ( string filePath ) ;
Task < AppCast > DeserializeAppCastFromFileAsync ( string filePath ) ;
string SerializeAppCast ( AppCast appCast ) ;
Task < string > SerializeAppCastAsync ( AppCast appCast ) ;
void SerializeAppCastToFile ( AppCast appCast , string outputPath ) ;
Task SerializeAppCastToFileAsync ( AppCast appCast , string outputPath ) ; As you can see, many of those functions are small variants of the core serialization and deserialization processes that you want to accomplish. You can look at the implementation of JsonAppCastGenerator and XMLAppCastGenerator for implementation examples.
ใช่. Implement IAppCastGenerator and set the SparkleUpdater.AppCastGenerator property to an instance of your class. You'll have to make the actual app cast file yourself, though, since the app cast generator is only currently compatible with XML and JSON.
Right now, we are compatible with version 11. If you need to make changes, you can use your own IUIFactory implementation to fix any issues that come up.
DSA signatures are not recommended when using NetSparkleUpdater 2.0+. They are considered insecure!
You can still generate/use these signatures, however, using the DSAHelper tool (from this NuGet package or in the source code here). Key generation only works on Windows because .NET Core 3 does not have the proper implementation to generate DSA keys on macOS/Linux; however, you can get DSA signatures for a file on any platform. If you need to generate a DSA public/private key, please use the DSAHelper tool on Windows like this:
netsparkle-dsa /genkey_pair
You can use the DSAHelper to get a signature like this:
netsparkle-dsa /sign_update {YourInstallerPackage.msi} {NetSparkle_PrivateKey_DSA.priv}
dotnet tool install --global NetSparkleUpdater.Tools.DSAHelpernetsparkle-dsa command Pass a DSAChecker into your SparkleUpdater constructor rather than an Ed25519Checker .
If your app has DSA signatures, the app cast generator uses Ed25519 signatures by default starting with preview 2.0.0-20200607001 . To transition to Ed25519 signatures, create an update where the software has your new Ed25519 public key and a NEW url for a NEW app cast that uses Ed25519 signatures. Upload this update with an app cast that has DSA signatures so your old DSA-enabled/containing app can download the Ed25519-enabled update. Then, future updates and app casts should all use Ed25519.
Here are some things you can do to figure out how to get your app running:
SparkleUpdater.LogWriter = new LogWriter(LogWriterOutputMode.Console) and then watch your console output while debugging.ใช่! Please help us make this library awesome!
NetSparkle is available under the MIT License.
Contributions are ALWAYS welcome! If you see a new feature you'd like to add, please open an issue to talk about it first, then open a PR for that implementation. If there's a bug you find, please open a PR with the fix or file an issue! ขอบคุณ!! :) You can also join us in our Gitter chat room!
An incomplete list of other projects related to software updating that you might want to look at if NetSparkleUpdater doesn't work for you: