How to package up files with OpenWrap

Tags: packaging, walkthrough, howto, build, package, openwrap

OpenWrap can be easily used to package up .Net projects, but it can also be used to package up any files that you want it to. I tried to do this for  testing purposes, but it's useful as a general file distribution process – i.e. how many computers can be kept up-to-date with the same versions of a set of files, be they a web app made of .html, .css and js files, a desktop application made from .exe and .dll files, or whatever.

I spent a few hours working out how to do this, resorting finally to reading the documentation. Here are the step-by-step details of what I came up with.

Note this example assumes that you have, for the sake of example, a folder called C:\Code\ORTest\Content containing the content files that you want to publish, in this case a file HelloWorld.txt containing the traditional text "Hello, world." and that you wish to make a repository at C:\Code\ORTest\Repo. If you wanted to get these files to several machines, you would make this repository on a \\server\share folder, but a local folder will do for testing.

This also assumes that you have OpenWrap installed, and o.exe is available at a command prompt.

First create the empty repository and connect to it. We'll call it 'LocalRepo' On the command-line, enter:
o add-remote localRepo file:\\\C:\Code\ORTest\Repo

Then get openwrap to create the necessary files in the content folder:
cd C:\Code\ORTest\Content
o init-wrap

There should now be a file called C:\Code\ORTest\Content\Content.wrapdesc. and also one called version. Omitting the init-wrap step causes the cryptic error message "Noun not found" to occur later. The file Content.wrapdesc describes what to package and how, and it needs a bit of updating from the default. Edit Content.wrapdesc to read:

  name: HelloWorld
description: HelloWorld test wrap
depends: openwrap anchored content
build: files; file=Content -> HelloWorld.txt

In summary: change the name to something better, add a description, and specify the content file to be included in the wrap

I am not sure what the depends line does for this particular package, since it doesn't refrence any other packages. A minimal version that still works is "depends: openwrap". Take that away and the error message "Noun not found" occurs.

The build line tells OpenWrap that this is a file-based not a .Net build, and which files to include. Note that the file parameter order is file=outputfolder -> inputfile, not inputfile -> outputfolder as you might expect. Also, files must be put into a folder inside the wrap. I don't know of a way to keep them in the root folder.

If there's more than one file to add to the wrap, use a command like
build: files; file=Content -> HelloWorld.txt; file=Content -> file2.txt

Now you can build the wrap:
o build-wrap -Name HelloWorld
Which will generate a .wrap file. If you want, you can look into the contents by renaming it to a .zip and opening it. You should see a file called "Content\HelloWorld.txt"

Then publish the wrap
o publish-wrap -Name HelloWorld -remote localrepo
You can check for the wrap's existence in the repository by just looking at the repo folder, or with:
o list-wrap -remote localrepo

You can regenerate the wrap and publish again by repeating the build-wrap and publish-wrap steps. The version number is automatically incremented each time.

You can install the wrap on the current system (potentially on another machine) with:
o add-wrap HelloWorld
You'll find it installed under C:\Users\Me\AppData\Local\openwrap\wraps

When you're done testing, remove the lot with:


o remove-wrap HelloWorld
o remove-remote localRepo

 

Add a Comment