# Canonicalize Path

**URL:** https://www.finalbuilder.com/forums/t/canonicalize-path/6748
**Category:** Discussion
**Created:** [March 23, 2020, 8:06pm UTC](https://www.finalbuilder.com/forums/t/canonicalize-path/6748 "2020-03-23T20:06:31Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![sa\_thomaslohrum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@sa\_thomaslohrum](https://www.finalbuilder.com/forums/u/sa_thomaslohrum)
#### Post date: [March 23, 2020, 8:06pm UTC](https://www.finalbuilder.com/forums/t/canonicalize-path/6748/1 "2020-03-23T20:06:31Z")

</div>

Hi,

is there an action that implements the Windows API “PathCanonicalize”?

Use case:  
My FinalBuilder Project is located in a subfolder “Buildsystem”, whereas the source is located in a subfolder “source”. For the FinalBuilder Script to work properly i configure a variable that looks similar to “%FBPROJECTDIR%\…\Source”.

This works fine. Canonicalizing the path will make the log easier to read, though.

Thomas

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [March 24, 2020, 4:50am UTC](https://www.finalbuilder.com/forums/t/canonicalize-path/6748/2 "2020-03-24T04:50:12Z")

</div>

Hi Thomas

There wasn’t, but now there is

[https://downloads.finalbuilder.com/downloads/finalbuilder/800/FB800\_2814.exe](https://downloads.finalbuilder.com/downloads/finalbuilder/800/FB800_2814.exe)

 ![CanonicalizePath](https://www.finalbuilder.com/forums/uploads/default/original/2X/c/c8174dc4c2f7211c284435baab6d228d5c490cd1.png)

Note that I did not use the windows api call, as that is only supported on Windows 8 or higher and FB8 still supports Windows 7 (we will drop windows 7 support in FB9).

---

<div class="post-metadata">

### Author: ![sa\_thomaslohrum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@sa\_thomaslohrum](https://www.finalbuilder.com/forums/u/sa_thomaslohrum)
#### Post date: [March 24, 2020, 7:42am UTC](https://www.finalbuilder.com/forums/t/canonicalize-path/6748/3 "2020-03-24T07:42:55Z")

</div>

Hi Vincent, very nice. Thanks a lot.

---

<div class="post-metadata">

### Author: ![sa\_thomaslohrum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@sa\_thomaslohrum](https://www.finalbuilder.com/forums/u/sa_thomaslohrum)
#### Post date: [May 11, 2020, 2:15pm UTC](https://www.finalbuilder.com/forums/t/canonicalize-path/6748/4 "2020-05-11T14:15:24Z")

</div>

Hi Vincent,

i am in the process of using the feature “Canonicalize Path” with more projects. As nice as the feature is, it is rather hard to use for me. I set up about 10 project variables for each project, that represent a path. To canonicalize them, i need to setup 10 actions - one by one for each variable, trying not to forget one of them as i need to check the list of project variables. As a side effect the project file grows about 10 KB.

Any ideas on how to avoid these drawbacks?

Thanks!

Thomas

---

<div class="post-metadata">

### Author: ![sa\_thomaslohrum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@sa\_thomaslohrum](https://www.finalbuilder.com/forums/u/sa_thomaslohrum)
#### Post date: [May 12, 2020, 10:50am UTC](https://www.finalbuilder.com/forums/t/canonicalize-path/6748/5 "2020-05-12T10:50:39Z")

</div>

Hi Vincent,

a possible solution is to canonicalize the one path variable, which all others depend on and set the macro flag for the others. This reduced the file size by 9 KB (52 downto 43). Execution was a second slower, but that is within tolerance of measurement anyway. Setting up the configuration is also easier. The drawback i see, is the unnecessary variable expansion caused by each access to them.

To better understand my configuration here is an abstract of my variables:  
ProjectPath=%FBPROJECTDIR%\…\…  
ProjectLibs=%ProjectPath%\Libs

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [May 12, 2020, 10:57pm UTC](https://www.finalbuilder.com/forums/t/canonicalize-path/6748/6 "2020-05-12T22:57:07Z")

</div>

Hi Thomas

I always recommend building up path variables using macro variables. It makes it so much simpler in the long run, change 1 variable and 10 other automatically update.

I’m going to give this some thought, but it might be possible for us to automatically cannonicalize variables… if we know they are paths. Not promising anything, just something for me to investigate.

---

<div class="post-metadata">

### Author: ![sa\_thomaslohrum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@sa\_thomaslohrum](https://www.finalbuilder.com/forums/u/sa_thomaslohrum)
#### Post date: [May 13, 2020, 9:54am UTC](https://www.finalbuilder.com/forums/t/canonicalize-path/6748/7 "2020-05-13T09:54:20Z")

</div>

Hi Vincent,

> [@Vincent](#):
>
> I always recommend building up path variables using macro variables.

Thanks for your confirmation on using macros as “best practices”.

> [@Vincent](#):
>
> if we know they are paths. Not promising anything, just something for me to investigate.

Without any expectations a summary of my use cases for variables:

- Constants  
A default value is assigned and not changed at runtime. For example Scriptname “D:\Tools\Sometool.exe” or Reportname “MyReport.xml”
- Arguments  
Passed by ContinuaCI, for example “BuildBranch”, usually not modified at runtime
- Dependencies  
Loaded from a configuration file. Directories (no filename) and paths (directory including a filename), usually not modified at runtime
- Directories  
Directories derived by other directories (Root is FBPROJECTDIR), usually not modified after initial assignment
- Values  
Variables, for example holding version information

I group my variables, according to the above use cases. Maybe the group name can be extended to specify properties that affect the usage of properties belonging to that group.

**For example:**  
 constant  
 is path/filename  
 value retrieved from Continua (arguments)

But maybe it is more flexible to add such properties aside the already known, such as “macro”.

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [May 13, 2020, 10:56pm UTC](https://www.finalbuilder.com/forums/t/canonicalize-path/6748/8 "2020-05-13T22:56:10Z")

</div>

Thanks for the info.

I do want to avoid optionitis - there are already a lot of options on variables - but will give it some thought.

---

<div class="post-metadata">

### Author: ![sa\_thomaslohrum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@sa\_thomaslohrum](https://www.finalbuilder.com/forums/u/sa_thomaslohrum)
#### Post date: [May 14, 2020, 7:11am UTC](https://www.finalbuilder.com/forums/t/canonicalize-path/6748/9 "2020-05-14T07:11:47Z")

</div>

Path/Filename is the only relevant. The others might offer enhancements, such as runtime optimization for constant values.

An algorithm can check, whether a value represents a path/filename, so that even this option is not mandatory. But unless this can be done reliably i’d prefer an option.

---

<div class="post-metadata">

### Author: ![sa\_thomaslohrum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@sa\_thomaslohrum](https://www.finalbuilder.com/forums/u/sa_thomaslohrum)
#### Post date: [August 27, 2020, 5:21am UTC](https://www.finalbuilder.com/forums/t/canonicalize-path/6748/10 "2020-08-27T05:21:14Z")

</div>

Hi Vincent,

with FinalBuilder 8.0.0.2915 the following feature got added:  
Enhancement - Addded Canonicalize Path option to String variable types.

Thanks a lot!

I noticed, that i have to set the var type to string, rather than the default variant.

Do i also have to check the macro expansion option to use canonicalize?

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [August 27, 2020, 5:28am UTC](https://www.finalbuilder.com/forums/t/canonicalize-path/6748/11 "2020-08-27T05:28:58Z")

</div>

No, but I’m looking into a UI bug which keeps resetting that option to false. Not sure why it is happening.

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [August 27, 2020, 5:47am UTC](https://www.finalbuilder.com/forums/t/canonicalize-path/6748/12 "2020-08-27T05:47:01Z")

</div>

I will upload another update shortly.

So it turns out there was 2 similarly named identical functions, one was used, the other not, and I updated the wrong one - no idea why there 2 functions but after updating the correct one (and deleting the unused one) it now works correctly.

Canonicalize will be applied when the variable is reset to it’s default value, or when the variable value is set (either by the Set Variable Action or by scripting). For macro variables, this is applied each time the value is read (which forces a reset to calculate the value).

---

<div class="post-metadata">

### Author: ![sa\_thomaslohrum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@sa\_thomaslohrum](https://www.finalbuilder.com/forums/u/sa_thomaslohrum)
#### Post date: [August 27, 2020, 5:54am UTC](https://www.finalbuilder.com/forums/t/canonicalize-path/6748/13 "2020-08-27T05:54:20Z")

</div>

I load the variables from an INI file. Do i have to take further action?

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [August 27, 2020, 6:03am UTC](https://www.finalbuilder.com/forums/t/canonicalize-path/6748/14 "2020-08-27T06:03:31Z")

</div>

No, it calls through the same api as the Set Variable action, so it will do the same thing.

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [August 27, 2020, 6:21am UTC](https://www.finalbuilder.com/forums/t/canonicalize-path/6748/15 "2020-08-27T06:21:15Z")

</div>

New update is on the website now, 8.0.0.2917.

---

<div class="post-metadata">

### Author: ![sa\_thomaslohrum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@sa\_thomaslohrum](https://www.finalbuilder.com/forums/u/sa_thomaslohrum)
#### Post date: [August 27, 2020, 6:30am UTC](https://www.finalbuilder.com/forums/t/canonicalize-path/6748/16 "2020-08-27T06:30:27Z")

</div>

I downloaded the file from [finalbuilder.com](http://finalbuilder.com). Thanks Vincent!  
Please note, that on [finalbuilder.com/forums/](http://finalbuilder.com/forums/) the file is not listed yet.

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [August 27, 2020, 7:05am UTC](https://www.finalbuilder.com/forums/t/canonicalize-path/6748/17 "2020-08-27T07:05:27Z")

</div>

Discourse sometimes takes it’s time updating the Categories view, it’s showing for me now.

---

<div class="post-metadata">

### Author: ![sa\_thomaslohrum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@sa\_thomaslohrum](https://www.finalbuilder.com/forums/u/sa_thomaslohrum)
#### Post date: [August 27, 2020, 7:12am UTC](https://www.finalbuilder.com/forums/t/canonicalize-path/6748/18 "2020-08-27T07:12:55Z")

</div>

Understood. Thanks. It’s showing for me now, too.

I have installed the build. I’ll send feedback to you, as soon as i have run a test.

---

<div class="post-metadata">

### Author: ![sa\_thomaslohrum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@sa\_thomaslohrum](https://www.finalbuilder.com/forums/u/sa_thomaslohrum)
#### Post date: [August 28, 2020, 6:30am UTC](https://www.finalbuilder.com/forums/t/canonicalize-path/6748/19 "2020-08-28T06:30:14Z")

</div>

Hi Vincent,

as promised here is my feedback. First of all: the feature is awesome. I like it a lot. It took me two clicks, that’s all. The log is much more readable now, as i usually download and read the plain log. As a side effect the log size got reduced by more than 10%.

I hit a small bug though. To enable the “[] Canonicalize” checkbox, you must not only set the var type to string. You also must close and reopen the variables dialog. This bug got introduced with build 2917.

Other than that i only had to configure my root variable on which all other variables depend on. The change is really small, but the impact is huge.

Hint: As for the project file itself, “canonicalizepath = false” gets added to existing entries. I suppose that’s the way to upgrade the file.

Thomas

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [August 28, 2020, 6:37am UTC](https://www.finalbuilder.com/forums/t/canonicalize-path/6748/20 "2020-08-28T06:37:18Z")

</div>

> [@sa\_thomaslohrum](#):
>
> I hit a small bug though. To enable the “ Canonicalize” checkbox, you must not only set the var type to string. You also must close and reopen the variables dialog. This bug got introduced with build 2917.

I just tried the reproduce that here and could not. Can you provide the exact steps for this?

> [@sa\_thomaslohrum](#):
>
> Hint: As for the project file itself, “canonicalizepath = false” gets added to existing entries. I suppose that’s the way to upgrade the file.

That will be gone in the next update, the default is false so no need to write it out to the file.

[Next page](https://www.finalbuilder.com/forums/t/canonicalize-path/6748.md?page=2)
