Cleaning up assets / Reverse Migrate

I’m looking into developing a plugin that removes all unused content - effectively a reverse migrate on a level.

I’m first trying to see if it’s even needed since I know that UDK | CommandletList Commandlet exists.

Question though - the above documentation indicates that you can specify levels you want to test for in ‘WrangleContent.ini’ - but where does this file exist and what should it look like?

I wasn’t able to locate where this file should be placed, nor what content it should contain to list maps that we want to keep. But debugging through the C++ code I figured it out.

Unfortunately I also get the following when running the WrangleConents commandlet, and I am left only with a Wrangle.bin file and a broken CSV file (it’s not fully written):



[2018.10.12-07.18.10:672]  0]LogContentCommandlet: Warning: Saving unreferenced objects [2729 packages]:
[2018.10.12-07.18.16:864]  0]LogWindows: Error: === Critical error: ===
[2018.10.12-07.18.16:866]  0]LogWindows: Error:
[2018.10.12-07.18.16:867]  0]LogWindows: Error: Assertion failed: MovedPackage [File:D:\Build\++UE4\Sync\Engine\Source\Editor\UnrealEd\Private\Commandlets\ContentCommandlets.cpp] [Line: 2510]
[2018.10.12-07.18.16:871]  0]LogWindows: Error:
[2018.10.12-07.18.16:872]  0]LogWindows: Error:
[2018.10.12-07.18.16:875]  0]LogWindows: Error:
[2018.10.12-07.18.16:877]  0]LogWindows: Error: [Callstack] 0x00007fff8296a388 KERNELBASE.dll!UnknownFunction ]
[2018.10.12-07.18.16:879]  0]LogWindows: Error: [Callstack] 0x00007fff5ba66850 UE4Editor-ApplicationCore.dll!FWindowsErrorOutputDevice::Serialize() [d:\build\++ue4\sync\engine\source\runtime\applicationcore\private\windows\windowserroroutputdevice.cpp:65]
[2018.10.12-07.18.16:886]  0]LogWindows: Error: [Callstack] 0x00007fff35f062fc UE4Editor-Core.dll!FOutputDevice::LogfImpl() [d:\build\++ue4\sync\engine\source\runtime\core\private\misc\outputdevice.cpp:70]
[2018.10.12-07.18.16:890]  0]LogWindows: Error: [Callstack] 0x00007fff35e951db UE4Editor-Core.dll!FDebug::AssertFailed() [d:\build\++ue4\sync\engine\source\runtime\core\private\misc\assertionmacros.cpp:425]
[2018.10.12-07.18.16:894]  0]LogWindows: Error: [Callstack] 0x00007fff31577d6f UE4Editor-UnrealEd.dll!UWrangleContentCommandlet::Main() [d:\build\++ue4\sync\engine\source\editor\unrealed\private\commandlets\contentcommandlets.cpp:2513]
[2018.10.12-07.18.16:901]  0]LogWindows: Error: [Callstack] 0x00007ff7cd21e9c2 UE4Editor-Cmd.exe!FEngineLoop::PreInit() [d:\build\++ue4\sync\engine\source\runtime\launch\private\launchengineloop.cpp:2322]
[2018.10.12-07.18.16:905]  0]LogWindows: Error: [Callstack] 0x00007ff7cd215968 UE4Editor-Cmd.exe!GuardedMain() [d:\build\++ue4\sync\engine\source\runtime\launch\private\launch.cpp:127]
[2018.10.12-07.18.16:911]  0]LogWindows: Error: [Callstack] 0x00007ff7cd215bba UE4Editor-Cmd.exe!GuardedMainWrapper() [d:\build\++ue4\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:144]
[2018.10.12-07.18.16:915]  0]LogWindows: Error: [Callstack] 0x00007ff7cd223dac UE4Editor-Cmd.exe!WinMain() [d:\build\++ue4\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:223]
[2018.10.12-07.18.16:921]  0]LogWindows: Error: [Callstack] 0x00007ff7cd224ce6 UE4Editor-Cmd.exe!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:283]
[2018.10.12-07.18.16:924]  0]LogWindows: Error: [Callstack] 0x00007fff84973034 KERNEL32.DLL!UnknownFunction ]
[2018.10.12-07.18.16:929]  0]LogWindows: Error: [Callstack] 0x00007fff86401461 ntdll.dll!UnknownFunction ]
[2018.10.12-07.18.16:931]  0]LogWindows: Error:


Running it with the debugger I find that the package it cannot rename is:



PackagePath = L"../../../Engine/Content/ArtTools/RenderToTexture/Blueprints/PhysMesh.uasset"


And since this only happenes because it wants to rename to this NFS-package I tried with the flag: -nosaveunreferenced which didn’t work at first - it seems you have to make a “space” at the end of the list of arguments to have it accept it. I also found out how to write the Config/WrangleContent.ini file:



[WrangleContent.PackagesToFullyLoad]
Package=/Game/Levels/MyPersistentLevelName


When debugging through the code I learned that the CSV-files are saved as Saved/Logs/UnreferencedObjects-YYYY.MM.DD-HH.MM.SS.csv