This service will generate an update script for your app and run it via PowerShell Core from the app itself.
- Add nuget to your project
Install-Package Refresher
- Add service to the app
builder.Services.AddSingleton<RefresherService>();
- Inject the service or invoke it directly
C# (service)
app.MapGet("/update", async () =>
{
var provider = builder.Services.BuildServiceProvider();
var updater = provider.GetService<RefresherService>();
await updater.UpdateAsync("https://example.com/update1.zip");
return Results.Ok();
});
F# (direct, minimal API)
app.MapGet("/update", Func<IResult>(fun () ->
task {
let updater = new RefresherService()
updater.UpdateAsync("https://example.com/update1.zip") |> ignore
} |> ignore
Results.Ok()
)) |> ignore
- Invoke it via
http://yourapp.com/update
- Your app will generate an update script in folder.
- Your app will invoke PowerShell CLI.
- PowerShell will shutdown your app, download and unpack the update, replace old files with new files.
- The update script will start your app again.
PowerShell Core on target machine (> 7.2) https://docs.microsoft.com/en-us/powershell/scripting/install/install-ubuntu?view=powershell-7.2
First start of your app via nohup dotnet app.dll > /dev/null 2>&1 &
Correct user rights for the main app and the folders.
- PowerShell is available on all platforms.
- Your app generates and starts the update process.
- No overhead for additional process.
- Fully functional background service with manifest files
- PowerShell checks for errors
- Function to create minimal updates
- Ubuntu 20.04.4 LTS
- Windows 11 (10.0.22000.0)