# Commandlet -rebuild option is not working properly

**URL:** https://qa.fmod.com/t/commandlet-rebuild-option-is-not-working-properly/19522
**Category:** Unreal Engine
**Created:** [November 14, 2022, 10:45am UTC](https://qa.fmod.com/t/commandlet-rebuild-option-is-not-working-properly/19522 "2022-11-14T10:45:38Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![alberto.barbati](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@alberto.barbati](https://qa.fmod.com/u/alberto.barbati)
#### Post date: [November 14, 2022, 10:45am UTC](https://qa.fmod.com/t/commandlet-rebuild-option-is-not-working-properly/19522/1 "2022-11-14T10:45:38Z")

</div>

I am using the FMOD plugin v2.02.07

According to the documentation the Unreal Engine commandlet FMODGenerateAssets supports a -rebuild option to clean up the FMOD assets before generating them. However the option doesn’t work as described, as it doesn’t delete any file. I traced the problem to line 43 of FMODGenerateAssetsCommandlet.cpp which is building the wrong pathname for the directories to be cleaned up.

---

<div class="post-metadata">

### Author: ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)
#### Post date: [November 21, 2022, 6:15am UTC](https://qa.fmod.com/t/commandlet-rebuild-option-is-not-working-properly/19522/2 "2022-11-21T06:15:45Z")

</div>

Unfortunately I haven’t been able to reproduce your issue. Given that line 43 of `FMODGenerateAssetsCommandlet.cpp` is generating the wrong path, the value that `Settings.ContentBrowserPrefix` is set to may be incorrect - you can check and change its value in the Unreal Editor by going to Project Settings → Plugins → FMOD Studio → Advanced. By default it should be set to `/Game/FMOD/`. Failing that, could you provide me with the path you’re expecting line 43 to generate, and the path that is actually being generated?

---

<div class="post-metadata">

### Author: ![alberto.barbati](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@alberto.barbati](https://qa.fmod.com/u/alberto.barbati)
#### Post date: [November 21, 2022, 9:10am UTC](https://qa.fmod.com/t/commandlet-rebuild-option-is-not-working-properly/19522/3 "2022-11-21T09:10:29Z")

</div>

I checked and `Settings.ContentBrowserPrefix` is actually set to `/Game/FMOD` without the trailing slash. I see that this is a problem, because the string is simply concatenated with the subfolder name. However, even adding the trailing slash, the code produces the wrong path. For example it produces paths like  
`../../../Projects/PROJECT/Content//Game/FMOD/Banks`, while the correct path should be `../../../Projects/PROJECT/Content/FMOD/Banks` (the double slash is not a problem, but having `Game` there is).

---

<div class="post-metadata">

### Author: ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)
#### Post date: [December 1, 2022, 12:05am UTC](https://qa.fmod.com/t/commandlet-rebuild-option-is-not-working-properly/19522/4 "2022-12-01T00:05:23Z")

</div>

Sorry for the late reply,

I’m still not able to replicate your issue unfortunately. `Settings.ContentBrowserPrefix` being set to `/Game/FMOD/` is causing no errors on my end - the produced paths are along the lines of `../../../Projects/PROJECT/Content//Game/FMOD/Banks` as they are for you, but the commandlet is working as expected.

Can you run me through how you’re using the commandlet? Additionally, Is there anything unconventional about your project structure?

---

<div class="post-metadata">

### Author: ![alberto.barbati](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@alberto.barbati](https://qa.fmod.com/u/alberto.barbati)
#### Post date: [May 31, 2023, 3:38pm UTC](https://qa.fmod.com/t/commandlet-rebuild-option-is-not-working-properly/19522/5 "2023-05-31T15:38:51Z")

</div>

Sorry to revive this thread after so long. You said that you get a path like `../../../Projects/PROJECT/Content//Game/FMOD/Banks` which is exactly what I have. However, I disagree that the commandlet is working as expected. The expected behaviour is that the folder `../../../Projects/PROJECT/Content/FMOD/Banks` (without “Game”) is to be deleted recursively, but that doesn’t happen. It’s true that the function FileManager.DeleteDirectoryRecursively returns success, but not because the folder has been deleted, but because it doesn’t exists at all, and that is because the path is wrong.

---

<div class="post-metadata">

### Author: ![alberto.barbati](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@alberto.barbati](https://qa.fmod.com/u/alberto.barbati)
#### Post date: [May 31, 2023, 4:04pm UTC](https://qa.fmod.com/t/commandlet-rebuild-option-is-not-working-properly/19522/6 "2023-05-31T16:04:20Z")

</div>

I fixed it by using the following code, borrowed from Engine\Source\Developer\SourceControl\Private\SourceControlHelpers.cpp (lines 1404-)

```auto
FString CorrectedPath = (Settings.ContentBrowserPrefix + folder).Replace(TEXT("/Game"), TEXT(""), ESearchCase::CaseSensitive);
FString FolderToDelete= FPaths::ProjectContentDir() / CorrectedPath;
FPaths::RemoveDuplicateSlashes(FolderToDelete);

```

---

<div class="post-metadata">

### Author: ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)
#### Post date: [June 1, 2023, 1:35am UTC](https://qa.fmod.com/t/commandlet-rebuild-option-is-not-working-properly/19522/7 "2023-06-01T01:35:59Z")

</div>

> [@alberto.barbati](#):
>
> Sorry to revive this thread after so long.

No problem!

> [@alberto.barbati](#):
>
> However, I disagree that the commandlet is working as expected. The expected behaviour is that the folder `../../../Projects/PROJECT/Content/FMOD/Banks` (without “Game”) is to be deleted recursively, but that doesn’t happen. It’s true that the function FileManager.DeleteDirectoryRecursively returns success, but not because the folder has been deleted, but because it doesn’t exists at all, and that is because the path is wrong.

I’ve done some more testing, and you do appear to be correct in that the deletion operation does return success, even when the path is wrong. Thanks for pointing this out - I’ve passed this and your solution along to the development team.
