adapting replace prefab example

Hello,

I’m currently working on a custom importer and facing some problems on prefab creation.
Due to this problems I’m facing back on the very beginning of prefab creation to make my import pipeline a little less complex.

I was looking on the code example provided on the EditorUtility.ReplacePrefab documentation page.

The example works in a way for me when using the menu item generated with the example.
But adapting the example to a AssetPostprocessor.OnPostprocessAllAssets(…) method to create an GameObject (with some simple components like MeshRenderer and MeshFilter) and use this instead of the “Selection” stuff from the example. The scripts runs fine but the prefab is never been replaced with the GameObject.

`
// it’s C# code, instead of the variables you might use static string values:

// string _impAssetDirBase = "Assets/";    
// string _impAssetName = "MyPrefabName/";
// string _extPrefab = ".prefab";

GameObject goInstance = new GameObject(_impAssetDirBase + _impAssetName);
goInstance.AddComponent<MeshFilter>();
goInstance.AddComponent<MeshRenderer>();

string localPath = _impAssetDirBase + _impAssetName + _extPrefab;
UnityEngine.Object prefab = EditorUtility.CreateEmptyPrefab(localPath);
EditorUtility.ReplacePrefab(goInstance, prefab);
AssetDatabase.Refresh();

UnityEngine.Object.DestroyImmediate(goInstance);
GameObject clone = (GameObject)EditorUtility.InstantiatePrefab(prefab);

`

Except of the GameObject I create at the beginning the code is the same as in the linked example inside the documentation. But it does not work =(.
Are there any limitations on prefab creation or the ReplacePrefab method which I’m not aware of?

I hope anyone can give me a hint to solve this problem.
Thanks in advance

Kind regards
Tobias

It might be that “/” at the end of _impAssetName…