If you have been following along with our Citrix Developer tools releases, you may have noticed that we’ve been increasing our release cadence for the Citrix Developer extension for Visual Studio Code. If you’re not familiar with the extension, it helps you get started building solutions that use the Citrix platform by providing an activity bar with embedded documents, Github projects and a section for community-based scripts. If you would like to jump to the getting started section, click here!
One of the areas we focused on in this release is up-leveling community-based scripts. As we looked more in-depth into this area, we saw “script sprawl” when it comes to the Citrix platform (we suffer from this, as well). Script sprawl comes in many forms: some developers use Github to store their scripts, some store their scripts within their enterprise storage, some store that quick script on a local device, some store scripts in a forum post, etc.
The central question here is: “How can you package up these scripts and be able to distribute them out to your team or make them available to the community?”
To help with this issue, we have released several items we believe will help the community take their existing scripts, package them up and make them available for download.
- Packaging tool (citrix-script-packager)
This global tool, which can be installed via npm, helps developers/admins get started packaging their scripts by creating a starter template, instructions for adding you own scripts, and the packaging system to package up your scripts into a .vsix file for use in the Citrix Developer Extension for Visual Studio Code.
- Citrix Developer Extension update (1.3.0)
This update to the tooling provides all the mechanisms to take a package that has been created with the packaging tool, install it into the extension, and surface it into the “Citrix Community Scripts” explorer view. There is a new command from the VS Code command palette called “Install Citrix Package” that will walk you through installing the package.
One of best things about these updates is that both the packaging tool and the Visual Studio Code extension are both open source. You can find them at the following links and, since we are using Github, please use the issue tracker to log issues or request features. We are building this in the open!
Now that we have an overview of what’s in this current release, let’s walk through a quick starter project to show how to package up your existing scripts and install them into the Citrix Developer extension.
Getting Started
Install the citrix-script-packager global tool (you will need to make sure you have node and npm installed for this global tool)
npm install -g citrix-script-packager
NOTE: For a list of command line arguments available, initiate the –help argument (citrix-script-packager –-help)
Once this tool is installed, let’s create a new directory on your system. Once you have created it, change into that directory.
Let’s have the tool create a base template for us to work from. Run the following command
citrix-script-packager –create
This will prompt you through a few items to help create the package. Fill them out with the values that pertain to you and/or your company.
Once completed, you will have a template and directory structure you will be able to use to package up any scripts you include in the friendly name folder. Is this example we said the friendly name of the package was going to be “testscripts”. You will want to updated the README.md file with documentation that is relevant to your scripts.
Next, let’s add some file into the template, so they will be included in the package. First, create a .ps1 file in the “testscripts” and add the following to it.
NOTE: You can just copy exisiting scripts into the directory and they can be any type of script (shell scripts, powershell scripts, batch files, etc)
# quick script to show the packaging system.
Get-ChildItem -Recurse
Now that we have the base complete, let’s package up the template. Run the following command and it will package up your template into a .vsix file for use within the Citrix Developer extension.
citrix-script-packager –package
Now we have a package that can installed into the Citrix Developer extension, let’s walk through how we can do that and make our script template available.
First make sure you have the Citrix Developer extension installed, you can get it either from the marketplace or from within Visual Studio Code using the extension manager.
Once you have the extension installed, you can execute the new command from the command palette “Install Citrix Package” via cmd+shift+p on mac org ctrl+shift+p on windows.
The command will prompt you to select your VISX package and then to extract the package into the Citrix Developer extension. Once you have the extension installed, you will see the script package listed in the “Citrix Community Script” explorer view. You can click on the README.md file to find out more about the scripts included in the package or click on the scripts to open it up in Visual Studio Code.
And that’s it! Once you have installed the script, it is available for you either run or start modifying.
Hopefully, this update will give the community and companies a consistent way to package up and deliver their scripts, whether they are proprietary to your company or scripts that you would like to make public. Either option is available to you.
For a video walk through check out this quick video that walks you through each step.
As always with my blog posts, please let me know what you think about the developer tools we are building for you. Please reach out to me on twitter (@johnmcbride) or leave a comment to give us feedback.