Commandline baking not saving sublevels

Since moving from 4.19 to 4.21 I’ve had trouble using the commandline to bake static lighting in regards to sublevels. Previously in 4.19 it would save lightmaps to the referenced sublevels as well, now with 4.21 the information in the sublevels is definitely affecting the bake for the persistent level that I have chosen to bake, however none of the lightmaps are saving to the sublevels as well.

‘UE4Editor-Cmd.exe “C:ProjectPath\ProjectName.uproject” -run=resavepackages -buildlighting -allowcommandletrendering -map=Level.umap’

I’ve been using the above format to bake and have had no issues prior to 4.21, do I need to do something different to achieve the same results?

Been wondering the same. Just tried to use it today and the only level saved was the one in the command. All the other 10 sublevels were left intact.

Found and fixed the bug here on 4.20. Looks like it was a typo, comparing the wrong map name. Here’s a fix:

			// If everything is a success, resave the levels.
			if( bShouldProceedWithRebuild )
			{
				for (ULevelStreaming* NextStreamingLevel : World->GetStreamingLevels())
				{
					FString StreamingLevelPackageFilename;
					const FString StreamingLevelWorldAssetPackageName = NextStreamingLevel->GetWorldAssetPackageName();
					const bool bPackageExists = FPackageName::DoesPackageExist(StreamingLevelWorldAssetPackageName, NULL, &StreamingLevelPackageFilename);
					const bool bPackageIsSublevel = SublevelFilenames.Contains(StreamingLevelPackageFilename);
					if (bPackageExists && bPackageIsSublevel)

Note: the fix is to to compare SublevelFilenames for StreamingLevelPackageFilename not StreamingLevelWorldAssetPackageName