20

I'm wondering if you can create a ClickOnce installer for a project and then host the installation folder on GitHub (via the downloads page)?

I guess by default ClickOnce publishes the installation files to a subfolder which I think is not supported on the Github downloads page but maybe there is another way.

Maslow
  • 18,464
  • 20
  • 106
  • 193
Koen
  • 3,626
  • 1
  • 34
  • 55

5 Answers5

17

Yes you can.

And actually I think it's a more convenient way comparing to FTP.

  1. Make sure your Git is set to "commit as-is", so that you can avoid some signature issues.
  2. Publish your ClickOnce application to a directory in your git repository (you may want another branch for that) with the url of raw on Github as the download/update url. E.g. for repository "xxx", branch "master", directory "clickonce" of user "vilic", the url should be "https://raw.github.com/vilic/xxx/master/clickonce/"
  3. Commit and push your application.

BTW, you will be able to download exe file and the application is able to check and download update as you are directly using raw.github.com. However, you may not open the xml file from your browser because the MIME type of xml file would be "text/plain". But I think you can try to use Github Pages to build this server, which should response with the right MIME type.

vilicvane
  • 11,625
  • 3
  • 22
  • 27
  • 1
    Thanks to your answer, I tried this out and is working really well. Here is my post documenting how this is being done. - http://flickrdownloadr.com/blogs/blog/2013/01/15/single-click-deployment-of-wpf-application-to-github-pages/ – Hari Pachuveetil Jan 15 '13 at 07:10
  • So you can reference in your readme.md to the setup.exe like this `https://rawgithub.com/vilic/xxx/master/clickonce/setup.exe`? – JP Hellemons Jan 27 '15 at 07:57
  • Thank you @vilicvane I probably did something wrong then http://stackoverflow.com/questions/28174391/publish-wpf-clickonce-application-to-github – JP Hellemons Jan 27 '15 at 15:46
5

Yes, definitely you can!. You can use raw GitHub for free hosting your .NET applications.

Follow the following steps:
(I have also created an illustrative video for the same here: https://youtu.be/iMEGtrjMXPU)

  1. If your project isn't on GitHub, create a repository and push your code there. It has to be public.
  2. On your computer, create a folder called 'published' at the root of your repository. Make sure this folder is not ignored in the .gitignore
  3. Create a file called .gitattributes in this /published folder. Add the following contents
*.manifest binary
*.application binary
*.deploy binary
*  -text
  1. Now commit and push to the Github repository. Navigate to this file in the repository click on the RAW button. Copy the URL address till '/publish/'. It will look like this
    https://raw.githubusercontent.com/{your-account-name}/{your-repo-name}/{branch}/published/
  2. In the ClickOnce installer enter the following paths
    1. Publish Path: {repo-path}/pubhished
    2. Install Path: https://raw.githubusercontent.com/{your-account-name}/{your-repo-name}/{branch}/published/ This is the server address from where the setup will install your application from.
    3. Update Path: https://raw.githubusercontent.com/{your-account-name}/{your-repo-name}/{branch}/published/ This is the server address from where the setup will check for updates.
      NOTE: Use this link to navigate through the clickonce installer:
      https://learn.microsoft.com/en-us/visualstudio/deployment/quickstart-deploy-using-clickonce-folder?view=vs-2022.
      Make sure the check the 'Create Desktop Shortcut' option before publishing. Now commit and push your code.
  3. Now in the /published folder click on the setup to install the application. This will connect the GitHub servers to download and install the required files on your computer in the directory C:\Users\vib28\AppData\Local\Apps\2.0.
  4. To publish an update for the application follow these steps
    1. Make the changes to your c# applicaiton.
    2. Publish the application again (to the same folder /published). The revision number should increase, and there should be a new folder added to the location /published/Application Files
    3. Commit and push your code to GitHub. Now the raw files have been updated. So whenever the client runs his application, it will automatically prompt for downloading the update.
vib2810
  • 51
  • 1
  • 2
  • You can even add a CI workflow to release the app automatically. I have written a blog post with details: https://janjones.me/posts/clickonce-installer-build-publish-github/ – Jan Joneš Nov 21 '22 at 20:20
  • This was so helpful - thank you. Once this is setup, I get a "Application Install - Security Warning" message saying that the publisher cannot be verified. I assume a paid for certificate might fix this. It also says the download URL or link is from "raw.githubusercontent.com". I'm assuming the answer is no - but is there anyway to change the above URL shown so it doesn't look as suspicious? – leonhart88 Mar 02 '23 at 00:32
2

When I set out trying to do this, this question with @VILIC's answer was one of the things that helped. Here is my blog post detailing how ClickOnce to GitHub pages has been automated -

http://flickrdownloadr.com/blogs/blog/2013/01/15/single-click-deployment-of-wpf-application-to-github-pages/

Hari Pachuveetil
  • 10,294
  • 3
  • 45
  • 68
2

All of these didn't work for me: rawgithub.com, raw.github.com, raw.githubusercontent.com.

RawGit did work, because it serves the proper application/x-ms-application Content-Type header.

Example:

https://cdn.rawgit.com/Microsoft/RESX-Unused-Finder/master/publish/ResxUnusedFinder.application

Also followed this guide and added a .gitattributes file:

*.manifest binary
*.application binary
*.deploy binary
RandomEngy
  • 14,931
  • 5
  • 70
  • 113
  • rawgit is not anymore a solution, it has reached the end of its life : https://rawgit.com/ GitHub recommend using GitHub Pages what I did and work well – bN_ Apr 03 '20 at 18:10
0

Most things served from raw.github.com have a text/plain content type and are served with an X-Content-Type-Options: nosniff header.

You can change your url to rawgithub.com from raw.github.com, which solves the problem in VILIC VANE's answer.

harttle
  • 88
  • 1
  • 12