There seems to be a bug in the Unreal Engine 5.0 Preview.
When creating new assets at runtime and saving them on disk, they do actually get saved correctly, but ObjectLibaries can’t find these assets.
First create an asset:
UObject* MyAsset = NewObject<UMyAsset>(...);
UPackage::Save(MyAsset, ...);
Then try to load the freshly created asset (its FAssetData) using an ObjectLibrary:
UObjectLibrary* ObjectLibrary = UObjectLibrary::CreateLibrary(UMyAsset::StaticClass(), false, false);
ObjectLibrary->AddToRoot();
ObjectLibrary->LoadAssetDataFromPath(AssetDirectory);
ObjectLibrary->GetAssetDataList(AssetArray);
I tested this on UE5.0 Preview 1 in the editor and the AssetDataList is emtpy. When I stop the game and start it again, the AssetDataList does contain the asset. So it seems like the assets that you create at runtime are not recognized by the engine anymore after starting the game (so probably after cooking).