
Winforms, WPF 및 Avalonia 용 UIS가 내장 된 C# .NET 프로젝트를위한 쉽게 사용자 정의 할 수있는 소프트웨어 업데이트 프레임 워크
NetSparkle은 .NET 6+ 및 .NET 프레임 워크 4.6.2+와 호환되는 C#에 대한 고도로 구성 가능한 소프트웨어 업데이트 프레임 워크입니다. 인터넷 어딘가에서 업데이트 및 버전 정보가 포함 된 앱과 Markdown 또는 HTML 형식의 릴리스 노트를 제공합니다. 이 라이브러리를 사용하면 업데이트를 확인하고 사용자에게 릴리스 노트를 표시하며 새 버전의 소프트웨어를 다운로드/설치하도록 제안합니다.
내장 지원 업데이트 다운로드 유형 :
주요 버전 변경, 업데이트 등에 대한 정보는 업그레이드 .md를 참조하십시오.
Netsparkle은 Nuget을 통해 제공됩니다. 사용할 Nuget 패키지를 선택하려면 다음과 같습니다.
NetSparkleUpdater.SparkleUpdater package 참조하십시오.| 패키지 | 유스 케이스 | 풀어 주다 | 시사 | 다운로드 |
|---|---|---|---|---|
| Netsparkleupdater.sparkleupdater | 핵심 패키지; 100% 사용자 정의 UI 또는 UI를 사용하지 않습니다 (내장 내장 없음) | |||
| Winforms UI (.NET Framework) | 내장 된 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 Tool (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 또는 기본 형식 또는 이와 유사한 코드를 추가하십시오. 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> 번호에 포함되도록 변경되었습니다. 이 동작은 현재 우리가 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를 볼 수 있도록 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 초 동안 기다립니다! 해당 이벤트를 구현하면 CloseApplication/CloseApplicationAsync의 90 초 이내에 소프트웨어가 닫히도록하십시오! 사용자에게 문을 닫는 것이 괜찮은지 (예 : 작업을 저장하기 위해) PreparingForExit 또는 PreparingToExitAsync 사용하는 것과 같이 취소 할 수있는 이벤트가 필요한 경우.
IUIFactory 구현하십시오. SparkleUpdater.UIFactory 설정하여 객체의 인스턴스를 사용하십시오.SparkleUpdater 업데이트를 확인하고 있음을 사용자에게 알려주는 UI에 대한 ICheckingForUpdates 구현IDownloadProgress 는 업데이트가 다운로드되고 있음을 사용자에게 보여줍니다.IUpdateAvailable 구현 릴리스 노트와 함께 업데이트를 사용할 수 있음을 사용자에게 표시합니다.IAppCastDataDownloader 구현하려면 앱 캐스트 데이터를 다운로드하기위한 고유 한 방법을 설정합니다. SparkleUpdater.AppCastDataDownloader 설정 객체의 인스턴스를 활용하십시오. Netsparkle은 기본적으로 두 가지 구현이 포함되어 있습니다 : WebRequestAppCastDataDownloader 인터넷에서 앱을 크게 다운로드하기위한 앱을 다운로드하기위한 LocalFileAppCastDownloader 포함하여 주어진 경로에서 주어진 경로에서 캐스트됩니다.IAppCastFilter 구현하여 다운로드 된 앱 캐스트에서 AppCastItem 객체에서 사용자 정의 필터링을 수행하십시오. AppCastHelper.AppCastFilter ( SparkleUpdater.AppCastHelper.AppCastFilter )를 설정하려면 객체의 인스턴스를 사용하십시오. ChannelAppCastFilter 에는 Application이 해당 기능을 사용하는 경우 주어진 제품 채널 (예 : Alpha, Beta)으로 항목을 필터링하는 데 사용할 수 있습니다.IAppCastGenerator 구현하여 앱 캐스트가 직렬화되고 사형화되는 방법을 제어합니다. SparkleUpdater.AppCastGenerator 를 설정하여 객체의 인스턴스를 사용하십시오. Netsparkle은 두 가지 구현을 포함합니다 : XMLAppCastGenerator , XML 직렬화/사제 화; 및 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에는 웹/인터넷에서 파일을 다운로드하기 위해 WebFileDownloader (기본값)와 주어진 경로에서 파일을 복사하기위한 LocalFileDownloader 의 두 가지 구현이 포함되어 있습니다. Configuration 특정 Netsparkle 정보가 저장 및로드되는 방법 (예 : 건너 뛰는 버전 정보)을 변경합니다. 이 클래스는 버전 정보, 제품 이름 등을 저장하고로드하기 위해 IAssemblyAccessor 인스턴스를 사용하는 클래스입니다. NetSparkle은 세 가지 구현을 포함합니다. RegistryConfiguration , Windows 레지스트리 (Windows의 기본값)에 정보를 저장하고로드하는 클래스; JSONConfiguration , 정보를 JSON 파일에 저장하고로드합니다 (MacOS/Linux의 기본값); 그리고 JSONConfiguration 데이터를 저장하고로드 할 유효한 파일 위치를 찾을 수없는 경우, 아무것도 수행하지 않고 폴백 역할을하는 DefaultConfiguration . 클래스의 인스턴스를 사용하려면 SparkleUpdater.Configuration 설정하십시오.RegistryConfiguration BuildRegistryPath 통해 항목을 저장하는 레지스트리 경로를 신속하게 변경할 수 있습니다.JSONConfiguration GetSavePath 통해 데이터를 저장하는 파일 경로를 신속하게 변경할 수 있습니다.AppCastHelper . AppCastHelper 속성 ( IAppCastFilter AppCastFilter 포함)을 통해 수행해야 할 모든 작업을 수행 할 수 있지만 서브 클래싱은 전체 프로세스에 대한 완전하고 절대적인 제어를 제공합니다. 클래스의 인스턴스를 사용하려면 SparkleUpdater.AppCastHelper 설정하십시오.ReleaseNotesGrabber . 수업 인스턴스를 사용하려면 UIFactory.ReleaseNotesGrabberOverride 를 설정하십시오.IUpdateDownloader 직접 구현하고 싶지 않은 경우 WebFileDownloader 재정의하고 CreateHttpClient 또는 RetreiveDestinationFileNameAsync 와 같은 기능을 무시하려는 경우. 클래스의 인스턴스를 사용하려면 SparkleUpdater.UpdateDownloader 설정하십시오.IAppCastDataDownloader 구현하지 않으려면 WebRequestAppCastDataDownloader 재정의하고 CreateHttpClient 와 같은 기능을 무시하려는 경우. 클래스 인스턴스를 사용하려면 SparkleUpdater.AppCastDataDownloader 설정하십시오.LogWriter 재정의하여 PrintMessage 함수를 구현하십시오. ILogger 매우 간단한 인터페이스이므로 필요가 복잡한 경우 해당 인터페이스를 직접 구현할 수 있습니다. 수업 인스턴스를 사용하려면 SparkleUpdater.LogWriter 설정하십시오.SparkleUpdater 재정의하여 다음을 포함하여 다른 설치 관련 기능을 구현합니다.GetWindowsInstallerCommandGetInstallerCommandRunDownloadedInstallerGetDownloadPathForAppCastItemIUIFactory 인터페이스 전체를 직접 구현하지 않으려면 UIFactory 재정의하십시오. 수업 인스턴스를 사용하려면 SparkleUpdater.UIFactory 설정하십시오. IAppCastFilter 사용 AppCastHelper.AppCastFilter 속성 ( IAppCastFilter 인터페이스를 통해)을 통해 앱 캐스트 항목을 필터링하는 방법을 변경할 수 있습니다. 이를 통해 최종 사용자가 제공하는 항목을 변경할 수 있습니다.
NetSparkle에는 ChannelAppCastFilter 라는 채널 기반 필터링을위한 내장 IAppCastFilter 구현이 포함되어 있습니다. 해당 클래스 사용 방법에 대한 몇 가지 예는 여기에서 단위 테스트를 참조하십시오. 기본적으로 List<string> ChannelSearchNames 속성을 필터링하려는 채널로 설정하십시오. 채널 정보가없는 항목을 유지하려면 (예 : 1.2.3 ), KeepItemsWithNoChannelInfo true 로 설정하십시오.
앱 캐스트 / 앱 캐스트에서 실제로 채널을 설정하려면 앱 캐스트 CLI 도구의 --channel 속성을 사용하거나 프로젝트 파일의 <Version> 속성을 해당 Semver 호환 버전 (예 : <Version>1.0.2-beta1</Version> )으로 설정하면 앱 캐스트 CLI 도구가 자동으로 선택됩니다. 또는 앱을 수동으로 구축하는 경우 <Sparkle : Channel> <item> <sparkle:channel>YourChannelHere</sparkle:channel> 속성 (또는 JSON을 사용하는 경우 channel 속성)을 설정하십시오.
Netsparkleupdater는 UI와 함께 사용할 필요가 없습니다. SparkleUpdater.UserInteractionMode = UserInteractionMode.DownloadAndInstall 을 설정하여 모든 것을 직접 수행하거나 라이브러리가 다운로드 된 업데이트를 자동으로 실행할 수 있습니다. 이 repo에는 src/netsparkle.samples.handleeventsyourself에서 사전 구축 된 UI없이 직접 작업하는 샘플이 있습니다.
UI를 원한다면 Winforms, WPF 및 Avalonia를위한 적은 수의 사용자 정의 가능한 옵션이있는 다른 Nuget 패키지로 사전 구축 된 UI를 제공합니다. UIS는 각 내장 옵션에서 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의 창이 닫히지 않도록 Winforms가 닫히지 않도록) 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은 기본적 으로 스파클 호환 XML 앱 캐스트를 사용합니다. Netsparkle은 sparkle:signature sparkle:edSignature 를 사용하여 파일/앱 캐스트에 서명하는 방법을 선택할 수 있습니다. ( sparkle:edSignature , Pass --use-ed25519-signature-attribute 사용하려면 NetSparkle은 기본적으로 ED25519 서명과 호환되며 사용하지만 프레임 워크는 ISignatureVerifier 버전의 Bump/Update없이 다른 종류의 서명없이 다른 종류의 신호를 확인할 수 있습니다.
다음은 샘플 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 버를 설정하지 않는 true 서명을 확인하지 않지만 ReleaseNotesGrabber.ChecksReleaseNotesSignature = true 좋아하거나 설정하면 Changelog 서명을 수동으로 확인할 수 있습니다.<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="..." )참고 : App Cast Generator 도구는 AppCast.xml 파일을 재현 할 때이 두 서명을 모두 생성합니다.
AppCastGenerator 도구 (이 NUGET 패키지 또는 소스 코드에서)를 사용하여 ED25519 서명을 생성 할 수 있습니다. 이 도구에는 .NET 6, 7, 8 또는 9 데스크탑 런타임이 설치되어야합니다. ED25519 키를 생성하고 앱 캐스트를 생성 할 때 사용하려는 옵션 및 예제는 아래 섹션을 참조하십시오.
AppCastGenerator 도구 (이 NUGET 패키지 또는 여기의 소스 코드)를 사용하여 앱 캐스트 파일을 쉽게 만듭니다. 사용 가능한 옵션은 아래에 설명되어 있습니다. dotnet tool install --global NetSparkleUpdater.Tools.AppCastGenerator .string.Format 또는 이와 유사한 것은 훌륭합니다).XML 대신 JSON 앱 캐스트를 사용하려면 :
--output-type json 사용하십시오.SparkleUpdater.AppCastGenerator new JsonAppCastGenerator(mySparkleUpdater.LogWriter) 로 설정하십시오.JsonAppCastGenerator.HumanReadableOutput 속성을 false 로 설정하십시오.보고 싶은 옵션이 없습니까? 이 저장소에 문제를 제기하거나 직접 추가하고 풀 요청을 보내십시오!
--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 상단 디렉토리 만 검색합니다. 기본값으로 false . 예제 사용 : -r .--single-file : 앱 캐스트에 추가 할 단일 파일-세트, --binaries , --ext 등이 모두 무시됩니다. 출력 파일에 확장자가없는 경우 사용하는 데 도움이됩니다 (예 : UNIX 실행 파일). 예제 사용 : --single-file path/to/my/file-f / --file-extract-version : 파일 (예 : dll)이 아닌 파일 이름에서 파일의 버전을 추출할지 여부. 기본값으로 false . NetSparkleUpdater에서 다운로드 할 파일이 파일 이름에 버전 번호와 예를 들어 "My App 1.3.2-alpha1.exe"에 사용됩니다. 이것은 마지막 4 개의 디렉토리 항목/폴더 만 검색합니다. 예제 사용 : -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 : 앱 캐스트 설명 태그/정보에 넣을 텍스트. 기본값은 "가장 최근의 업데이트 링크로 변경"으로 이동합니다. 예제 사용 : --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 : 변경 로그 파일 이름을위한 접두사. 기본적으로 생성기는 "[버전] .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 : NetSparkle_Ed25519.priv 및 NetSparkle_Ed25519.pub 파일로가는 경로. 소프트웨어 업데이트를위한 개인 및 공개 ED25519 키입니다. 예제 사용 : --key-path my/path/to/keysgenerate_appcast 실행하기 전에 SPARKLE_PRIVATE_KEY 및 SPARKLE_PUBLIC_KEY 환경 변수를 설정할 수 있습니다. 이 도구는 디스크에 앉아있는 키보다 환경 키를 우선시합니다!--signature-file-extension : 앱 캐스트 서명 파일에 사용하는 확장 (extension . . signature 으로 서명. 예제 사용 : --signature-file-extension txt .--output-file-name : 앱이있는 앱의 출력 파일 이름 . 또는 확장. Extension은 XML 또는 JSON 출력 여부에 따라 제어되고 구성 가능하지 않습니다. 기본값은 'appcast'입니다. 물론, 앱 캐스트가 생성 된 후에 나중에 나중에 이것을 변경할 수 있습니다. 이 옵션은 편의를위한 것입니다. 예제 사용 : --output-file-name super_app_download_info .--use-ed25519-signature-attribute : true and xml 출력을 수행하는 경우 XML의 출력 서명 속성은 원래 Sparkle 라이브러리와 일치하는 signature 아닌 edSignature 됩니다. JSON 앱 캐스트에는 영향을 미치지 않습니다.--file-version : 앱 캐스트에 들어가는 이진을위한 버전을 설정하는 데 사용합니다. 이 버전은 한 번만 설정할 수 있으므로 앱 캐스트를 생성 할 때 다음을 확인하십시오. a) 앱 캐스트에 하나의 바이너리가 있습니다 | 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 : 사실이라면, 출력 앱 캐스트 파일을 인간 읽기 가능 (뉴스 라인, 들여 쓰기)으로 만듭니다. 예제 사용 : --human-readable true--channel : 앱 캐스트에 추가 된 항목의 릴리스 채널 이름. 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: