Giter Site home page Giter Site logo

barsgroup / nuselfupdate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from caleb-vear/nuselfupdate

0.0 4.0 0.0 6.03 MB

NuSelfUpdate allows you to easily update your applications by simply publishing a new version to a NuGet package repository.

License: MIT License

PowerShell 51.18% C# 48.82%

nuselfupdate's Introduction

NuSelfUpdate

NuSelfUpdate allows you to easily update your applications by simply publishing a new version to a NuGet package repository.

NuSelfUpdate will handle everything that is needed to download the new version, extract it and switch the application's executable files with the new version. It will do all this while your application is running; so you can install updates in the background and next time the application is run it will be the new version. To top it all off you can easily relaunch the new version of the application with the same command line arguments the app was originally with.

Contributing

Contributions are welcome; fork NuSelfUpdate and submit a pull request :) If your looking for something to do you can always check out issues page to see what features or bugs need some work. If you have an awesome idea feel free to submit an issue, but pull requests are best.

You can clone/fork NuSelfUpdate with either git or mercurial:

An Example

NuSelfUpdate lets you write code like this:

    
    static void Main()
    {
        var appUpdater = CreateAppUpdater();
        
		// This will run the UpdateDatabase method if this is the first 
		// time we have run the application after an update is installed.
        if (appUpdater.OldVersionExists)
		{
			UpgradeDatabase();
			appUpdater.RemoveOldVersionFiles();
		}
        
        var updateCheck = appUpdater.CheckForUpdate();
        
        if (updateCheck.UpdateAvailable)
        {
            var preparedUpdate = appUpdater.PrepareUpdate(updateCheck.Update);
            var installedUpdate = appUpdater.ApplyPreparedUpdate(preparedUpdate);
            // Runs the new version of the application with the same command
            // line arguments that we were initially given.
            appUpdater.LaunchInstalledUpdate(installedUpdate);
            return;
        }
        
        DoYourApplicationStuff();
    }    

    AppUpdater CreateSelfUpdater()
    {
        // Some configuration code here:
        return new AppUpdaterBuilder("NuSelfUpdate.Sample").Build();
    }

    void UpgradeDatabase()
    {
        // Do some important stuff here.
    }
    
    void DoYourApplicationStuff()
    {
        // What you would normally have in your main method goes here
    }

Building The Project

While the simplest way to get your hands on NuSelfUpdate is via nuget it is possible you may like to make your own modifications and then build them. This can useful if for example you complete a new feature and it hasn't been pulled into the main repository yet.

Running the build is simple, all you have to do is fire up powershell navigate to the source repository root and run the following:

PS> .\psake.sp1

A directory named build will be created which will contain a brand new nupkg file. It also contains the raw binary files in the /bin/ folder and all build log output in a folder named /output/.

Running The Sample

The NuSelfUpdate source includes a working sample of the library in action. A psake powershell script has been provided to facilitate the running of the sample. The following instructions assume that you will have powershell open and the current directory is the root of the source repository.

The first step is to build and run the sample. To build the sample and start it run the following:

PS> .\psake.ps1 sample.ps1 RunSample

A new console window will open up and start checking for updates. Not the version number shown on the first line. Next up to publish a new version run the following:

PS> .\psake.ps1 sample.ps1 PublishNewVersion

Running PowerShell Scripts

Depending on your powershell script execution policy you may have difficulty running the script.
See this page for more information. The simplest way to enable the script is to run the following from an admin powershell console:

PS> Set-ExecutionPolicy Unrestricted

You should however understand that can pose security risks so you might like to set it back to Restricted afterwards

nuselfupdate's People

Contributors

caleb-vear avatar chripede avatar

Watchers

James Cloos avatar Dmitri avatar Rustam Davletov avatar Tim avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.