What is your commandline for the cook? I think you are using -iterate, but want to confirm.
-iterate has been around for 10+ years. It has some flaws (e.g. it does not detect changes in the binary and does not recook packages based on the classes they are using changing in layout).
It also has the property that it cooks the previously cooked packages even if not requested in the currentcook:
Engine\Source\Editor\UnrealEd\Private\CookOnTheFlyServer.cpp
... void UCookOnTheFlyServer::PopulateCookedPackages(TArrayView<const ITargetPlatform* const> TargetPlatforms) ... // *) Cook all modified packages even if the requested cook packages don't reference them ... // cook on the fly will queue packages when it needs them, but for cook by the book we force cook the modified files // so that the output set of packages is up to date (even if the user is currently cooking only a subset) WorkerRequests->AddStartCookByTheBookRequest(FFilePlatformRequest(PackageData->GetFileName(), EInstigator::LegacyIterativeCook, TConstArrayView<const ITargetPlatform*>{ TargetPlatform }));
Possibly you could modify code locally to turn off that behavior.
In 5.6, we have published as an experimental feature the new version of iterative cooking that we have been working on, incremental cooking. It is at least as robust in 5.6 as it iterative cooking is in 5.6, but it requires enabling ZenServer as well. Incremental cook does not have that property of forcing the cook of previously cooked packages. It might be an option for you if turning off the behavior in -iterate is not. ZenServer and IncrementalCook are enabled via
`// ZenStore enabled in Game.ini:
[/Script/UnrealEd.ProjectPackagingSettings]
bUseZenStore=True
// CookIncremental enabled in commandline argument:
-cookincremental
-cookincremental -forcerecook // Forces a recook despite cookincremental being on
// The configuration to enable CookIncremental will change in 5.7`
I don’t know whether this property of -iterate is the cause of your problem; it would only manifest if you do a cook with all of your packages followed by a narrower -iterate cook of only your requested packages. If the problem occurs even without that earlier, wider cook, then you might instead have a case where even in non-iterative cooks the packages are getting pulled in. If that is the case, then you can find out what is pulling them into the cook by running the cookcommandlet with showinstigators on (via commandline argument -dpcvars=cook.displaymode=4):
UnrealEditor.exe <ProjectName> -run=cook -targetplatform=<PlatformName> -dpcvars=cook.displaymode=4
When that display mode is on, the cooker will log an instigator message for each cooked package:
LogCook: Display: Cooking /Game/PackageName, Instigator: { AssetManagerModifyCook }