The Asset Manager integrated into the Xbase++ Workbench provides an easy interface for viewing, (de-) installing and updating the assets being used in your projects. Behind the scene, the Asset Manager in conjunction with the Workbench, performs the following tasks for you:
- Manage asset dependencies for each target in your project
- Install/uninstall asset files required for using assets and for building your project
- Copying required binaries/dlls to the target directory, allowing targets to be run/executed for debugging
- Allow assets to be updated if a newer version exists
Step 1: Create a dummy project for handling assets
The following steps create a dummy project for adding/removing/updating assets to/from/in your project directory. The dummy project allows these tasks to be performed without having to load your regular project file into the Workbench.- Start the Xbase++ Workbench, either via the Start menu or by typing "xwb.exe" on the commandline
- Use File -> Close All to make sure no project is open
- Select File -> New... and switch to the "Windows Target" tab
- Enter the path to your project directory into the "Location" box, or use the browse icon for selecting this directory
- Click into the "Name" box and type "dummy-target"
- Click on the icon for "Console Application" to select this as the target type
- Click OK
- Close the Workbench
- We recommend renaming the dummy project to "asset-management.xpj" or something similar to better reflect its purpose. Note that if your regular application's project file is named "project.xpj", the dummy project will have been named "project1.xpj"!
Step 2: Adding an asset to the project directory
In this step, we'll use the XbpHTMLViewer2 asset as an example for adding an asset to your project directory. To do this, you'll have to perform the following steps.- Load the dummy project into the Workbench by double-clicking the project file or by starting the Workbench and using File -> Open ...
- Right-click on "dummy-target.exe" in the Project Manager pane on the left
- Select "Manage Assets ..." to open the Asset Manager
- Type "htmlview" into the search box at the top right
- Select the "XbpHTMLViewer2 Control" asset in the list
- Click Add
- Click Close to close the Asset Manager
The above steps add the XbpHTMLViewer2 asset to the dummy project and also copy the asset's files into your project folder. You can verify this by checking the "Dependencies" node in Project Manager.
When adding an asset to the project, the documentation of the asset which comes in the form of a readme file will also be loaded into the editor to give you a chance to familiarize yourself. Most assets also come with an example which can be imported into the project. We recommend doing this as a reference for the asset's usage and for verifying everything is working correctly. Simply click the "Add example to project" link in the readme file. This adds a new target with the example to the dummy project.
Use File -> Save All to save any changes once you're done. Press F9 to build and run the example.
Note: the same procedure can be used to uninstall an asset and to remove the asset's files from your project folder. Click "Remove" in the Asset Manager to do this.
Step 3: Adding a dependency to an asset to your application project
The third and last step is adding a dependency on the asset to your application project. This allows the Project Builder pbuild.exe to automatically locate asset files which are required for linking, and to copy dlls which are required for execution to the target directory .This step is normally performed automatically for you by the Asset Manager. When not using the Workbench, the dependency must be added manually for ensuring the corresponding target can be built and executed successfully.
The following is an example of the steps which must be performed.
- Use the Workbench or your favorite editor for opening the dummy project (asset-management.xpj)
- Locate the dummy target to which the XbpHTMLViewer2 asset was added earlier (dummy-target.exe)
- Find the DEPENDS_ON= directive in the target's definition section. It will look like this:
DEPENDS_ON = $(ASSETS_PATH)\xbphtmlviewer2 - Copy this line to clipboard
- Open your regular project file in the Workbench or some other editor
- Paste the line with the DEPENDS_ON= directive into the definition section of the target in which you want to use the XbpHTMLViewer2 asset. If this is the .EXE target of an application named "test", for example, the line must be pasted into the section following the [test.exe] node.
Once this step has been completed, you should be able to compile and execute your project/target. pbuild.exe should automatically locate the asset's .lib files for linking, and it should copy the required .dll files to your target directory for execution.
Further reading: