Question
Sun Life Financial
CA
Last activity: 23 Aug 2019 16:11 EDT
Use Relative Paths in Deployment Files
When deploying a project you have the option to include external files as part of your deployment. In the .osproj file, it looks something like this
<!-- Deployment -->
<DeploymentFiles>|Desktop|\Private\LocalData\TLS_Messages.xml</DeploymentFiles>
Is there a way to set up that path to be relative to the current project path?
There are a few environment variables that can be used (|Desktop|, |Application|, etc.) but there doesn't seem to be one for the current project path.
In another configuration item, ProjectReference, the path accepts '..' as a way to move up the chain of folders, I tried the same syntax for DeploymentFiles but it failed, is there another way to achieve this?
<ProjectReference Include="..\..\RA-Common\RA-Common\RA-Common.osproj">
When you attach a file to a deployment package it will be located in the deployment extract directory (assuming you have not updated the RuntimeConfig file to not extract to disk). This directory can be retrieved at Runtime by calling the Static method on the Toolbox under the Runtime tab named "GetProjectPath". This will actually give you the path to the project dll, but you can use a FileUtils to strip that off to get the directory. From there, you can combine that path with your file name to access it. I have attached an example solution that I created for the following (unrelated) post. At the beginning, you can see where I get the ProjectPath and manipulate it to locate the PDF used in the example.
https://collaborate.pega.com/question/sample-solutions-pdf-connector-extracting-text-pdf-and-updating-excel