Sorry if this is a stupid question, but I actually could not find any references to this. In fact, my needs are pretty simple. I need a way to create source code distributions, to my open source web operating system. Binary releases I already take care of myself, by allowing the user to conditionally _"clone"_ his own system, with whatever modules he wants to distribute. So the system has the ability to _"clone"_ itself, which takes care of all binary releases.
However, since GitHub does not support adding _submodules_ to the main .zip files my source code users would download, I am left with either going back to nAnt (which hasn't been updated for a decade), or find some other tooling that supports my needs ...
So basically, what would be the simplest way to create a source code distribution, kind of the same way nAnt used to be able to do it in the _"old days"_. And is this even possible with Cake ...?
Sorry if my question is ridiculously simple, and there is some sort of FAQ answering it already, but I couldn't find a single reference to such a simple task as _"copy a bunch of files conditionally, and zip these into a zip file"_ - Which is arguably everything I need ...
I don't need compilers, running Unit Tests, or any of the advanced bells and whistles from Cake. I simply need to be able to create a simple zip file, containing some (but not all) files from my own folder, excluding stuff such as "/bin/"_ folders, etc ...
If Cake is not the right tool, I would appreciate some advice on where to go. I'll need preferably something that is cross platform, and it _must_ be Open Sauce ...
I know about nAnt, but since it hasn't been maintained for a decade or something, I would rather prefer something slightly _"fresher"_ ...
Hello @polterguy,
Yes, this is possible to do with Cake. Since Cake is C#, you can do anything you can do with C# in a Cake script. For the operations you want to do, there is even built in script alias methods in Cake to make things easier.
Below are some examples of the things you want to do. You can read more about the available script alias methods at https://cakebuild.net/dsl/.
Create a folder
https://cakebuild.net/api/Cake.Common.IO/DirectoryAliases/102BADB6
CreateDirectory("./mydestination");
Copy files to folder
https://cakebuild.net/api/Cake.Common.IO/FileAliases/CEEEBF72
CopyFiles("./src/**/*", "./mydestination");
Zip folder
https://cakebuild.net/api/Cake.Common.IO/ZipAliases/B6C83EAE
Zip("./mydestination", "./src.zip");
Awesome, I started fiddling with NAnt, while waiting for your response, and I ran into a whole dimension of problems. Thx, you're a champ :)
OK, so now I feel really stupid here, but how do I install Cake ...?
The only reference I find is to install it through NuGet. I obviously don't want to add it as a reference in my projects, I simply want to consume it myself, to create my own source code release ...?
(Mac OS X)
@polterguy if you want a machine installation of Cake, you can install it through homebrew.
Typically, you would have Cake within a project, and you would use our bootstrapper file, the build.sh file, to download and run Cake.
Never mind, figured out the _"bootstrapper build.sh"_ script ...
Sorry ... (blush!)
Thx again ... :)
There is an overview of Cake and how it works here:
There's some guidance on getting stated at:
https://cakebuild.net/docs/tutorials/setting-up-a-new-project
OK, that was surprisingly easily done, a couple of hours of fiddling around with it, and VOILA!. Najs work BTW, love its simplicity and syntax ... :)
In case somebody else have this question, I thought I'd post my results here.
__Windows__ - Invoke-WebRequest https://cakebuild.net/download/bootstrapper/windows -OutFile build.ps1
__Linux__ - curl -Lsfo build.sh https://cakebuild.net/download/bootstrapper/linux
__OS X__ - curl -Lsfo build.sh https://cakebuild.net/download/bootstrapper/osx
This downloads the _"build.sh/ps1"_ bootstrapper script for you, into your current folder.
Then create a simple _"build.cake"_ script, mine looks like the following.
/*
* Creating root source code distribution folder, that
* will later be zipped, after copying of all files is done.
*/
CreateDirectory("./phosphorusfive-8-1");
/*
* Copying all source code file.
*
* We copy Hyperlambda files, C# files, and all (relevant) ASP.NET files.
*/
var files = GetFiles ("./**/*.cs$|*.hl$|*.md$|*.aspx$|*.ascx$|*.sh$|*.cake$|*.sln$|*.csproj$|*.asax$|*.ico$||*.css$|*.js$|*.png$|*.jpg$|*.jpeg$|*.gif$|*.svg$|LICENSE$|*.nupkg$|*.config$|*.targets$|*.txt$");
CopyFiles (files, "phosphorusfive-8-1", true);
files = GetFiles ("./packages/**/*");
CopyFiles (files, "phosphorusfive-8-1/packages/", true);
/*
* Deleting "auth.hl" file.
*/
DeleteFile ("./phosphorusfive-8-1/core/p5.webapp/auth.hl");
/*
* Deleting "/db/" folder.
*/
var directoriesToDelete = new DirectoryPath [] { Directory("./phosphorusfive-8-1/core/p5.webapp/db/")};
DeleteDirectories (directoriesToDelete, new DeleteDirectorySettings {Recursive = true, Force = true});
/*
* Deleting "common" folder.
*/
directoriesToDelete = new DirectoryPath [] { Directory("./phosphorusfive-8-1/core/p5.webapp/common/")};
DeleteDirectories (directoriesToDelete, new DeleteDirectorySettings {Recursive = true, Force = true});
/*
* Deleting "users" folders.
*/
directoriesToDelete = new DirectoryPath [] { Directory("./phosphorusfive-8-1/core/p5.webapp/users/")};
DeleteDirectories (directoriesToDelete, new DeleteDirectorySettings {Recursive = true, Force = true});
/*
* Then re-creating the "/common/" folder that were removed above.
*
* This is done to avoid copying temporary files, created during usage of system.
*/
CreateDirectory ("./phosphorusfive-8-1/core/p5.webapp/common/");
CreateDirectory ("./phosphorusfive-8-1/core/p5.webapp/common/documents/");
CreateDirectory ("./phosphorusfive-8-1/core/p5.webapp/common/documents/private/");
CreateDirectory ("./phosphorusfive-8-1/core/p5.webapp/common/documents/public/");
CreateDirectory ("./phosphorusfive-8-1/core/p5.webapp/common/temp/");
files = GetFiles ("./core/p5.webapp/common/README.md");
CopyFiles (files, "./phosphorusfive-8-1/core/p5.webapp/common/");
files = GetFiles ("./core/p5.webapp/common/documents/private/README.md");
CopyFiles (files, "./phosphorusfive-8-1/core/p5.webapp/common/documents/private/");
files = GetFiles ("./core/p5.webapp/common/documents/public/README.md");
CopyFiles (files, "./phosphorusfive-8-1/core/p5.webapp/common/documents/public/");
files = GetFiles ("./core/p5.webapp/common/temp/README.md");
CopyFiles (files, "./phosphorusfive-8-1/core/p5.webapp/common/temp/");
/*
* Then re-creating the "/users/root/" folder that were removed above.
*
* This is done to avoid copying temporary files, created during usage of system.
*/
CreateDirectory ("./phosphorusfive-8-1/core/p5.webapp/users/root/");
CreateDirectory ("./phosphorusfive-8-1/core/p5.webapp/users/root/documents/");
CreateDirectory ("./phosphorusfive-8-1/core/p5.webapp/users/root/documents/private/");
CreateDirectory ("./phosphorusfive-8-1/core/p5.webapp/users/root/documents/public/");
CreateDirectory ("./phosphorusfive-8-1/core/p5.webapp/users/root/temp/");
files = GetFiles ("./core/p5.webapp/users/README.md");
CopyFiles (files, "./phosphorusfive-8-1/core/p5.webapp/users/");
files = GetFiles ("./core/p5.webapp/users/root/documents/private/README.md");
CopyFiles (files, "./phosphorusfive-8-1/core/p5.webapp/users/root/documents/private/");
files = GetFiles ("./core/p5.webapp/users/root/documents/public/README.md");
CopyFiles (files, "./phosphorusfive-8-1/core/p5.webapp/users/root/documents/public/");
files = GetFiles ("./core/p5.webapp/users/root/temp/README.md");
CopyFiles (files, "./phosphorusfive-8-1/core/p5.webapp/users/root/temp/");
/*
* Zipping folder, to create our actual distribution.
*/
Zip ("./phosphorusfive-8-1", "./Source-Complete-With-Submodules.zip");
/*
* Deleting temporary folder.
*/
directoriesToDelete = new DirectoryPath [] { Directory("./phosphorusfive-8-1/")};
DeleteDirectories (directoriesToDelete, new DeleteDirectorySettings {Recursive = true, Force = true});
From a terminal afterwards, (if on Linux/OS X) make sure your _"build.sh"_ script becomes an executable by executing the following command.
chmod +x build.sh
Then execute your build script (on Linux) with the following command.
./build.sh
This simple process allowed me to create a source code distribution for a fully fledged web operating system in roughly 2 hours, doing all the heavy lifting automatically for me :)
PS!
If I were to come with _"constructive criticism"_, you'll need to emphasise _"tutorial style documentation"_ on your web site, since actually getting started, seemed slightly more painful than what it should have been. And a 50 minutes long YouTube video is WAAAAY to long, regardless of its quality. This is especially true when you're about to create a release, and you're probably drowning in other things to do from before ... ;)
However, all in all, a little piece of brilliance indeed folks :)
@polterguy we are glad to hear that you got it working, and thank you for the valuable feedback.
If you can, can you elaborate on what you mean by "tutorial style documentation"? Would you mind creating an issue about it here:
https://github.com/cake-build/website
Perhaps with some suggestions? Thanks!
Sure, I'll provide a ticket ... :)
Most helpful comment
There's some guidance on getting stated at:
https://cakebuild.net/docs/tutorials/setting-up-a-new-project