
Winforms、WPF、およびAvalonia用のUISが組み込まれたC#.NETプロジェクト用の簡単にカスタマイズ可能なソフトウェア更新フレームワーク
NetsParkleは、C#のための非常に構成可能なソフトウェアアップデートフレームワークであり、.NET 6+および.NETフレームワーク4.6.2+と互換性があり、.NETフレームワーク(WINFORMS、WPF)および.NET 6+(WINFORMS、WPF、AVALONIA)用の.NETフレームワーク(WINFORMS、WPF)および.NET 6+用の事前に構築されたUISがあります。まったく!インターネット上のどこかで、更新とバージョンの情報を備えたアプリキャスト、およびMarkdownまたはHTML形式のリリースノートを提供します。このライブラリは、アップデートを確認し、ユーザーにリリースノートを表示し、ソフトウェアの新しいバージョンをダウンロード/インストールすることを申し出ます。
組み込みサポートされている更新ダウンロードタイプ:
メジャーバージョンの変更、更新などの情報については、upgrading.mdを参照してください。
NetsparkleはNuget経由で入手できます。使用するnugetパッケージを選択するには:
NetSparkleUpdater.SparkleUpdater packageを参照してください。| パッケージ | 使用事例 | リリース | プレビュー | ダウンロード |
|---|---|---|---|---|
| netsparkleupdater.sparkleupdater | コアパッケージ。 100%カスタムUIまたはuiなし(組み込みはありません) | |||
| winforms ui(.netフレームワーク) | 内蔵Winforms UIを備えたNetSparkle | |||
| winforms ui(.net 6+) | 内蔵Winforms UIを備えたNetSparkle | |||
| WPF UI(.NETフレームワークと.NET 6+) | 内蔵WPF UIを備えたNetSparkle | |||
| Avalonia UI | ビルトインAvalonia UIを備えたNetSparkle | |||
| アプリキャストジェネレーターツール | netsparkle-generate-appcast CLIツール(ED25519ヘルパーを含む) | |||
| DSAヘルパーツール | 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.、または4であなたを助けません。
sudoで実行する必要がある場合は、Macos Avaloniaサンプルでそれを行う例があります。アプリキャストファイルを作成するには、このドキュメントのアプリキャストセクションを参照してください。
ユーザーにとって、全体的なインストール/更新プロセスをより簡単にする可能性のある貢献に対して開かれています。仕事を始める前に、最初にあなたのアイデアに問題を提出してください。そうすれば、それについて話すことができます。
基本的で実行可能な使用サンプルについては、このリポジトリのサンプルプロジェクトをご覧ください!!ビルトインUIのそれぞれを使用するサンプルと、「自分の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またはMain Formなどに追加します。 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+では、GIT/ソースコードがハッシュをアプリの<Version>番号に含める原因となる.NETのコアに変更が加えられました。この動作は、 AssemblyInformationalVersionAttributeに依存しているため、Netsparkleupdaterによって回避することはできません。この属性の動作は変更されました。ユーザーは、Netsparkleupdater(およびネイティブアプリ自体)で現在1.0.0+commitHashHere実行していると言われる場合があります。また、次の行をプロジェクトファイルに追加することをお勧めします(新しい<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!最初のApplication.Idleイベントでは、アプリキャストXMLファイルがダウンロード、読み取り、現在実行中のバージョンと比較されます。内部にソフトウェアの更新がある場合、ユーザーは、小さなトースト通知(UIでサポートされ、有効になっている場合)またはリリースノートを含む更新ダイアログで通知されます。その後、ユーザーは更新を無視したり、後で思い出させるように依頼するか、今すぐダウンロード/インストールすることができます。
ユーザーが何も見ずにバックグラウンドで更新を確認する場合は、使用してください
var updateInfo = _sparkle . CheckForUpdatesQuietly ( ) ;ユーザーが更新をチェックするようにメニュー項目を持ちたい場合は、ユーザーがUIを確認している間にUIを確認できる場合は、更新を検索してください。
_sparkle . CheckForUpdatesAtUserRequest ( ) ;保存する必要があるファイルがある場合は、PreperingToExitイベントに登録してください。
_sparkle . PreparingToExit += ( ( x , cancellable ) =>
{
// ask the user to save, whatever else is needed to close down gracefully
} ) ; UIFactoryを使用しない場合は、アプリケーションを閉じるためにCloseApplicationまたはCloseApplicationAsyncイベントを使用する必要があることに注意してください。それ以外の場合、ダウンロードした更新ファイルは実行/読み取られません!これの唯一の例外は、自分で更新パッケージをインストールするすべての側面を処理する場合です。
ダウンロードされた更新実行可能ファイルを起動するファイルは、あきらめる前に90秒間待機します!これらのイベントを実装すると、CloseApplication/closeApplicationAsyncから90秒以内にソフトウェアが閉じることを確認してください!キャンセルできるイベントが必要な場合、ユーザーが閉じることが問題であるかどうかを尋ねる必要がある場合(たとえば、作業を保存するために)、 PreparingForExit使用するか、 PreparingToExitAsyncください。
IUIFactory実装してください。 SparkleUpdater.UIFactoryを設定して、オブジェクトのインスタンスを利用します。SparkleUpdaterアップデートをチェックしていることをユーザーに伝えるUIのICheckingForUpdatesを実装するIDownloadProgressは、アップデートがダウンロードされていることをユーザーに示していますIUpdateAvailableを実装して、リリースノートと一緒にアップデートが利用可能であることをユーザーに示すIAppCastDataDownloaderを実装して、アプリキャストデータをダウンロードする独自の方法をセットアップします。 SparkleUpdater.AppCastDataDownloaderを設定して、オブジェクトのインスタンスを利用して。NetSparkleには、デフォルトの2つの実装が含まれています: WebRequestAppCastDataDownloader Internet Warlyのアプリキャスト情報をダウンロードするためのLocalFileAppCastDownloaderIAppCastFilterを実装して、ダウンロードしたアプリキャストのAppCastItemオブジェクトでカスタムフィルタリングを実行します。 AppCastHelper.AppCastFilter ( SparkleUpdater.AppCastHelper.AppCastFilter )を設定して、オブジェクトのインスタンスを利用します。 NetsParkleには、 ChannelAppCastFilterクラスが含まれています。これは、アプリケーションがそれらの機能を利用している場合は、特定の製品チャネル(Alpha、Betaなど)でアイテムを除外するために使用できます。IAppCastGeneratorを実装して、アプリキャストがシリアル化され、脱色された方法を制御します。 SparkleUpdater.AppCastGeneratorを設定して、オブジェクトのインスタンスを利用します。 XMLAppCastGeneratorには、XMLシリアル化/脱介入用の2つの実装が含まれています。 JSONのシリアル化/降下のためのJsonAppCastGenerator 。アプリキャストジェネレーターCLIツールは、XMLとJSONアプリの両方のキャストの両方を出力することもできます。IAssemblyAccessorを実装して、バージョン、著作権、およびその他の製品の詳細がアプリケーションにどのようにロードされるかを制御します。 Configuration.AssemblyAccessor ( SparkleUpdater.Configuration.AssemblyAccessor )を設定して、オブジェクトのインスタンスを利用します。 NetSparkleには、特定のアセンブリからデータをロードする一般的なケースで機能するはずのデフォルトの実装であるAssemblyDiagnosticsAccessorが含まれています。ILoggerを実装し、 SparkleUpdater.LogWriterを設定します。デフォルトでは、 LogWriterクラスが使用されます( LogWriterOutputModeプロパティがあり、ログがConsole 、 Traceなどに書き込まれるかどうかを制御します。)ISignatureVerifierを実装して、アプリキャスト、ダウンロードなどの署名がどのように処理されるかを変更します。 SparkleUpdater.SignatureVerifierを設定して、オブジェクトのインスタンスを利用します。IUpdateDownloaderを実装して、特定のアプリキャストアイテムのアプリアップデートファイル(インストーラーなど)の進行状況をダウンロードおよび送信する独自の方法をセットアップします。 SparkleUpdater.UpdateDownloaderを設定して、オブジェクトのインスタンスを使用して使用します。NetsParkleには、デフォルトの2つの実装が含まれています。Web/インターネットからファイルをダウンロードするWebFileDownloader (デフォルト)、および特定のパスからファイルをコピー/「ダウンロード」するためのLocalFileDownloaderダウンロードします。 Configuration特定のNetsparkle情報の保存方法を変更する方法(例:バージョン情報)。このクラスは、バージョン情報、製品名などを保存およびロードするためにIAssemblyAccessorインスタンスを使用するクラスです。NetSparkleには、Windowsレジストリに情報を保存およびロードするRegistryConfigurationコンフィグレーション(Windowsのデフォルト)を保存します。 JSONConfigurationは、情報をJSONファイルに保存およびロードします(MacOS/Linuxのデフォルト)。 DefaultConfiguration 、 JSONConfigurationデータを保存およびロードするための有効なファイルの場所を見つけることができない場合に、何もしず、フォールバックとして機能します。クラスのインスタンスを使用するには、 SparkleUpdater.Configurationを設定します。RegistryConfiguration BuildRegistryPath使用するJSONConfigurationを使用すると、 GetSavePathを介してデータが保存されるファイルパスをすばやく変更できますAppCastHelper 。おそらく、 AppCastHelperプロパティ( IAppCastFilter AppCastFilterを含む)を介して必要なすべてのことを行うことができることに注意してください。クラスのインスタンスを使用するには、 SparkleUpdater.AppCastHelperを設定します。ReleaseNotesGrabber 。クラスのインスタンスを使用するには、 UIFactory.ReleaseNotesGrabberOverrideを設定します。IUpdateDownloader自分で実装したくない場合はWebFileDownloaderをオーバーライドし、 CreateHttpClientやRetreiveDestinationFileNameAsyncなどの関数を1つまたは2つオーバーライドするだけです。クラスのインスタンスを使用するには、 SparkleUpdater.UpdateDownloaderを設定します。IAppCastDataDownloaderを実装したくない場合、 CreateHttpClientなどの関数をオーバーライドするだけで、 WebRequestAppCastDataDownloaderをオーバーライドします。クラスのインスタンスを使用するには、 SparkleUpdater.AppCastDataDownloaderを設定します。LogWriterをオーバーライドして、 PrintMessage関数を実装します。 ILogger非常にシンプルなインターフェイスであるため、ニーズが複雑な場合は、おそらくそのインターフェイスを自分で実装できます。クラスのインスタンスを使用するには、 SparkleUpdater.LogWriterを設定します。SparkleUpdaterをオーバーライドして、以下を含むいくつかの異なるインストール関連機能を実装します。GetWindowsInstallerCommandGetInstallerCommandRunDownloadedInstallerGetDownloadPathForAppCastItemIUIFactoryインターフェイスの全体を自分で実装したくない場合は、 UIFactoryをオーバーライドし、関数を1つまたは2つ構成するだけです。クラスのインスタンスを使用するには、 SparkleUpdater.UIFactory設定します。 IAppCastFilterを使用しますAppCastHelper.AppCastFilterプロパティを介して、アプリキャストアイテムのフィルタリング方法を変更できます( IAppCastFilterインターフェイスを介して)。これにより、エンドユーザーが利用できるアイテムを変更できます。
NetSparkleには、 ChannelAppCastFilterと呼ばれるチャネルベースのフィルタリング用のIAppCastFilter FILTERの組み込みが含まれています。そのクラスの使用方法に関するいくつかの例については、こちらのユニットテストを参照してください。基本的に、フィルタリングするチャネルにList<string> ChannelSearchNamesプロパティを設定します。チャネル情報( 1.2.3など)のないアイテムを保持したい場合は、 KeepItemsWithNoChannelInfo true設定します。
アプリキャストアイテム /アプリキャストで実際にチャネルを設定するには、アプリキャストCLIツールの--channelプロパティを使用するか、プロジェクトファイルの<Version>プロパティを該当するSEMVER互換バージョン(EG <Version>1.0.2-beta1</Version> )に設定し、アプリキャストCLIツールを自動的にピックアップします。または、アプリを手動でキャストしている場合は、 <sparkle:channel>YourChannelHere</sparkle:channel>プロパティを<item> (または、JSONを使用する場合、 channelプロパティ)を設定します。
netsparkleupdaterは、UIで使用する必要はありません。 SparkleUpdater.UserInteractionMode = UserInteractionMode.DownloadAndInstallを設定して、すべてを自分で実行するか、ダウンロードした更新を自動的に実行させることもできます。このレポは、src/netsparkle.samples.handleeventsyourselfに事前に構築されたUIなしで自分で物事を行うためのサンプルがあります。
UIが必要な場合は、WinForms、WPF、Avalonia用の少数のカスタマイズ可能なオプションを備えたさまざまなNugetパッケージで事前に構築されたUIを提供します。 UIは、組み込みオプションのそれぞれでUIFactoryと呼ばれるIUIFactory実装を介してトリガーされます。 UIFactoryのほとんどの方法は、動作を微調整する場合にオーバーライドできます。また、 ProcessWindowAfterInit使用すると、各ウィンドウを作成した後にカスタマイズできます。
独自のUIを完全にロールしたい場合は、使用するUIライブラリを使用してIUIFactoryインターフェイスを実装するだけです。 netsparkleupdaterの事前に構築されたオプションからビューモデル、コードなどをコピーまたは再利用でき、このレポンからコードをコピー+貼り付けコードは、おそらく開始するのに適しています。ただし、 IUIFactory実装のインスタンスでSparkleUpdater.UIFactoryプロパティを設定することを忘れないでください!
注:Netsparkleは基本的に、 SparkleUpdaterインスタンスを開始したメインスレッドへのバックグラウンドループ呼び出しを除き、スレッド(メインスレッドへの呼び出しなど)を心配することを試みません。言い換えれば、一般的に言えば、Netsparkleは、もともとSparkleUpdaterインスタンスを作成したスレッド上ですべてを行います。ほとんどのアプリでは、メインのUIスレッドを使用しているだけなので、これは問題ありません。疑わしい場合は、独自のUIのニーズについては、WinformsおよびWPF/AvaloniaでInvokeRequiredを確認してください。UIスレッドに物事をマーシャリングしてください(データバインディングを使用していない限り!
新しいスレッドのWindows/ThingsをSparkleUpdaterに開始する独自のIUIFactory実装を渡すことは、サポートされている構成ではありません。複数のスレッドで独自のUIを実行したい場合(たとえば、メインフォームが閉じるときにnetsparkleupdaterのウィンドウを閉じない場合)、 SparkleUpdater UIFactoryイベントを使用してください。また、これを行う方法の実用的な例については、SRC/netsparkle.samples.forms.Multithreadサンプルもご覧ください。
アプリキャストは、XMLまたはJSONファイルにすぎません。製品のタイトルや説明などのフィールド、およびソフトウェアのリリースごとの定義が含まれています。
Netsparkle-Generate-Appcastツールを使用して、ファイルを作成する(後で再作成/更新)することを強くお勧めします。
dotnet tool install --global NetSparkleUpdater.Tools.AppCastGeneratornetsparkle-generate-appcastコマンドとしてコマンドラインで利用できるようになりました。 netsparkle-generate-appcast --helpを使用して、このツールのオプションの完全なリストを表示できます。デフォルトでは、Netsparkleは、ほとんどの場合、 Sparkle互換XMLアプリキャストを使用しています。 Netsparkleはsparkle:signature sparkle:edSignatureを使用して、ファイル/アプリキャストの署名方法を選択できるようにします。 ( sparkle:edSignature 、pass --use-ed25519-signature-attributeへのアプリキャストジェネレーターへの使用を使用する場合。)Netsparkleはデフォルトでed25519シグネチャと互換性があり、フレームワークは、メジャーバージョンの署名クラスをチェックするために、 ISignatureVerifierクラスの異なる実装を処理できます。
これがサンプルXMLアプリキャストです:
<? 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を設定しない限り、この署名をチェックしません。ChecksReaSeNotESSignatureをtrueに設定しますが、 ReleaseNotesGrabber.ChecksReleaseNotesSignature = trueを設定した場合は、ChangElog Signaturesを手動で検証できます。<pubDate>sparkle:channel :このアプリキャストアイテムのチャネル、例: beta (不要) - 1つのチャネルのみを受け入れる<enclosure>url :更新ファイルのURLsparkle: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="..." )注:アプリキャストジェネレーターツールは、appcast.xmlファイルを再作成すると、これらの両方の署名を作成します。
AppCastGeneratorツールを使用してED25519署名を生成できます(このNUGETパッケージから、またはこちらのソースコードから)。このツールには、.NET 6、7、8、または9デスクトップランタイムをインストールする必要があります。 ED25519キーの生成に関するオプションと例、およびアプリキャストの作成時にそれらを使用するためのオプションと例については、以下のセクションを参照してください。
AppCastGeneratorツール(このNUGETパッケージからまたはこちらのソースコードから)を使用して、アプリキャストファイルを簡単に作成します。使用可能なオプションについては、以下に説明します。 dotnet tool install --global NetSparkleUpdater.Tools.AppCastGeneratorを介してCLIにインストールできます。string.Formatまたは同様は素晴らしいことです)。XMLではなくJSONアプリキャストを使用したい場合:
--output-type jsonアプリキャストジェネレーターを介してアプリキャストファイルを生成するときSparkleUpdater.AppCastGenerator new JsonAppCastGenerator(mySparkleUpdater.LogWriter)に設定します。JsonAppCastGenerator.HumanReadableOutputプロパティをfalseに設定します。あなたが見たいいくつかのオプションがありませんか?このリポジトリに問題を提出するか、自分で追加して、プルリクエストを送信してください!
--show-examples :コンソールへの使用例を印刷します。--help :すべてのオプションとその説明を表示します。 -a / --appcast-output-directory :出力appcast.xmlファイルを書き込むディレクトリ。使用例: -a ./MyAppCastOutput-e / --ext :アプリキャストに追加するファイルを探している場合、ファイルを探すときに指定された拡張機能を使用します。デフォルトはexeになります。使用例: -e exe,msi-b / --binaries :アプリキャストに追加するファイルを探すときに検索する必要があるディレクトリへのパスをファイルします。デフォルトです. 。使用例: -b my/build/directory-r / --search-binary-subdirectories :バイナリのバイナリディレクトリを再帰的に検索するのに忠実です。 TOPディレクトリのみを検索するためのfalse。デフォルトはfalseになります。使用例: -r 。--single-file :アプリキャストに追加するシングルファイル - 設定の場合、 --binaries 、 --extなどはすべて無視されます。出力ファイルに拡張機能がない場合に使用するのに役立ちます(例えば、UNIX実行可能です)。例の例: --single-file path/to/my/file-f / --file-extract-version :ファイル(dll)自体ではなく、ファイルの名前からファイルのバージョンを抽出するかどうか。デフォルトはfalseになります。 NetsparkLeupdaterによってダウンロードされるファイルがファイル名にバージョン番号を持つ場合、「マイアプリ1.3.2-alpha1.exe」のバージョン番号が表示されます。これは、最後の4つのディレクトリアイテム/フォルダーのみを検索することに注意してください。使用例: -f true--file-version :アプリキャストに入るバイナリのバージョンを設定するために使用します。このバージョンは1回しか設定できないため、アプリキャストを生成するときは、次のことを確認してください。a)アプリキャストに1つのバイナリしか持っていないことを確認してください| 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 :アプリに入力するテキストは、説明タグ/情報をキャストします。デフォルトは、「更新へのリンクを備えた最新の変更」になります。使用例: --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 :ソフトウェアのログファイルを変更するパス。これらは、 .mdの拡張機能でマークダウン形式であると予想されます。変更ログファイルのファイル名には、ソフトウェアのバージョン、例えば1.3.2.md含まれている必要があります。使用例-p path/to/change/logs 。 (注:ジェネレーターは、ファイル名がそのようにフォーマットされている変更ログを見つけようとします: MyApp 1.3.2.md )--change-log-name-prefix :ログファイル名を変更するプレフィックス。デフォルトでは、ジェネレーターはフォーマット「[version] .md」を使用してファイル名を検索します。このパラメーターを(たとえば、私のアプリの変更ログ」に設定すると、「My App Change log [version] .md」と「[version] .md」という形式でファイル名を検索します。-n / --product-name :ソフトウェアの製品名。アプリキャストとそのアイテムのタイトルを設定するときに使用されます。デフォルトはApplicationになります。使用例: -n "My Awesome App"-x / --url-prefix-version :ダウンロードURLのファイル名のプレフィックスとしてバージョン番号を追加します。デフォルトはfalseになります。たとえば、 --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 : NetSparkle_Ed25519.privおよびNetSparkle_Ed25519.pubファイルへのパス。これは、ソフトウェアアップデート用のプライベートおよびパブリックED25519キーです。使用例: --key-path my/path/to/keysgenerate_appcast実行する前に、 SPARKLE_PRIVATE_KEYとSPARKLE_PUBLIC_KEY環境変数を設定できます。このツールは、ディスク上に座っているキー上の環境キーを優先します!--signature-file-extension :拡張機能(なし.アプリキャスト署名ファイルに使用します。デフォルトはsignatureになります。使用例: --signature-file-extension txt 。--output-file-name :アプリの出力ファイル名をwith .または拡張機能。拡張は、XMLまたはJSON出力であり、構成できないかどうかによって制御されます。デフォルトは「Appcast」になります。もちろん、アプリキャストが生成された後、いつでもこれを後で変更できます。このオプションは便利なものです。使用例: --output-file-name super_app_download_info 。--use-ed25519-signature-attribute :TrueとXML出力を実行する場合、XMLの出力署名属性は、元のSparkleライブラリと一致するsignatureではなく、 edSignatureになります。 JSONアプリキャストには影響しません。--file-version :アプリキャストに入るバイナリのバージョンを設定するために使用します。このバージョンは1回しか設定できないため、アプリキャストを生成するときは、次のことを確認してください。a)アプリキャストに1つのバイナリしか持っていないことを確認してください| b) --reparse-existingパラメーターを利用して、古いアイテムが取り上げられるようにします。ジェネレーターが既知のバージョンなしで2つのバイナリを見つけ、 --file-versionが設定されている場合、エラーが発生します。--critical-versions :アプリキャストで重要であるとマークするバージョンのコンマセパレーションリスト。バージョンのテキストを正確に一致させる必要があります。例:「1.0.2,1.2.3.1」。--reparse-existing :既存のアプリキャストを無効にして、新たに作成するのではなく、既存のアプリキャストを再分圧します。アプリキャストにすでにバージョンをスキップするため、同じバージョンで新しいバイナリを展開する場合は、リプロイするバージョンの古いリストを削除するためにアプリキャストを手動で編集する必要があります。使用例: --reparse-existing true--overwrite-old-items :同じバージョン番号があるディスク上のバイナリ上のディスクが見つかった場合、アプリキャストアイテムをアプリキャストに書き換えます。言い換えれば、1.0.1がすでにアプリキャストされている場合(賠償または別のバイナリから)、ディスクに別の1.0.1が見つかった場合、アプリキャストの1.0.1データは、見つかったバイナリに基づいて書き直されます。これは、ディスクに複数の1.0.1バージョンがある場合(すべきではない...)、最後に見つかったバージョンがアプリのキャストにあることを意味することに注意してください。使用例: --overwrite-old-items--human-readable :Trueの場合、出力アプリキャストファイルをHuman Readable(NewsLines、Indents)にします。使用例: --human-readable true--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: