Automate WinForm app publish to match NAppUpdate standard
If you’re using NAppUpdate framework to publish your WinForm app, this post is for you.
Assume that you already setup NAppUpdate successfully. Now we want to simplify it to just 1 click publish, and the others clients can just update it
Server side
In your server, you need a path to store the xml file. For my case, I will create a subdomain for it. E.g.
1 | cd /var/www/pub.yoursite.com |
Assume your site hosted in this path
1 | . |
The index.php you can just simply put some dummy text into it, because the most important file is release.xml
The content of release.xml is auto generated. I’ve created the php file, download it to your server, and place it anywhere, (e.g. /path/to/publish.php)
Then create a cronjob for it
1 | * * * * * /usr/bin/php /path/to/publish.php > /dev/null 2>&1 |
This cronjob will run every minute, so once you have new file published to server, it will auto generate the release.xml
WinForm (Visual Studio)
First you need to build the project
Then go to property there
And the go to Publish tab
Set your FTP details, then publish it
Server side
Edit the file /path/to/publish.php, change the constants to match your own
- PUBLISH_INPUT_ROOT:
/home/ftpuser/path/to/releases/Application\ Files
- PUBLISH_OUTPUT_ROOT:
/var/www/pub.yoursite.com/releases
- PUBLISH_XML_FEED:
/var/www/pub.yoursite.com/release.xml
- WINFORM_PREFIX:
YourProject_
- BASE_URL:
http://pub.yoursite.com
Now once your app published, the cronjob will execute this php script, and the script will generate release.xml,
and copy the necessary files to releases folder.
1 | . |
Inside the releases folder will then have all version of what you have published.