Installing code to Orchard directly from GitHub
I recently had a question land in the comments on my post about making the PJS.Bootstrap theme work with Orchard 1.10.x, where Abner asked:
I am new to orchard development so please mind the noob question.
I was wondering how to integrate the code hosted on Github into my application, I am familiar with installing themes using the Dashboard, however not sure what to do when i download the code from Github.
Rather than just drop a reply in the comments / by email, I thought instead I'd put together a short post to show this instead. As it turns out, Abner, what you're asking isn't much more difficult than installing a theme/module via the Dashboard!
Running up a local copy of Orchard to install a module into
I'm using the module I wrote as an example, which you can find here (RW.Orchard.Conditions, it's also in the gallery), because as long as my website exists my GitHub repositories should too! The first thing to do is to use GitHub Desktop or your Git interface of choice to download the source for both Orchard and the component from GitHub you want to use.
Next up, load the Orchard solution from the \src folder into Visual Studio, once it's finished loading select Orchard.Web in Solution Explorer and hit CTRL-F5 to run it up without the debugger attached (this is quicker, so it's worth doing it this way!). You'll be prompted to configure your Orchard instance, the quickest and easiest thing to do here is to set it up to use SQL Server CE which means that the \Orchard.Web\App_Data folder basically becomes the entirety of the Orchard instance, both settings and data. Once you've confirmed that your instance is up and running, the next step is dropping the module code in and seeing it light up.
So, from the homepage of your test instance, navigate to the /Admin area and then to the Modules area, just to have a quick look and confirm it's all working nicely. Searching for "RW" on the Installed Modules tab will show nothing matching:
That's nice, but how do I get the module code working?
Before I cover this, it's probably not a terrible idea to give a very brief outline of how modules from the Orchard Gallery work. Modules in the Orchard gallery are "just" NuGet packages. NuGet packages are "just" ZIP files (with the file extention .nupkg) that contain some metadata to describe the package, what it depends on and the files it contains. Of course, it also contains the files that make up the component that the NuGet package is responsible for. So, when you install a module, or theme, from the gallery your installation of Orchard downloads it, parses it and extracts the content into the ~/Modules/ or ~/Themes/ directory. Take a moment to have a quick look at the folders inside one of those folders, for example ~/Modules/Orchard.Tags (which on my PC is found at D:\GitHub\Orchard\src\Orchard.Web\Modules\Orchard.Tags). What you'll notice is that there's no opaque set of DLLs and perhaps a config file or two, instead what's present is the entirety of the source for the module.
So - two guesses how you take code from GitHub and install it?
Go to the folder that you retrieved the source for RW.Orchard.Conditions into (on my PC this is D:\GitHub\RW.Orchard.Conditions), drop down into the "src" folder, take a copy of the RW.Orchard.Conditions folder (the one that contains the .csproj file) and paste it into the ~/Modules/ folder, i.e. the same folder that contains the Orchard.Tags modules we looked at earlier. Now, take a trip back to the Installed Modules tab and repeat the search for 'RW'. As if by magic, the module is now present.
It's basically that simple - copy and paste the code into the ~/Modules or ~/Themes folder. If there are any issues, don't forget to look in ~/App_Data/Logs to see if there's any stack trace or detail to assist in resolving it there.
My skillset has matured somewhat since then, which you'll probably see from the posts here. You can read a bit more about me on the about page of the site, or check out some of the other posts on my areas of interest.