When I do this I go in and manually set the urls and/or modify the existing page and update it with my custom web part that I wrote via the object model inside a feature receiver. You can write a new one or use the existing one.
//In this case I have a custom web part that I want to use on both the new and edit form
private void SetNewAndEditForm(Microsoft.SharePoint.SPList list, SPWeb web)
{
SPContentType ct = list.ContentTypes[contentTypeName];
//I'll be using the edit form for both item creation and updating so I build the edit form url (This specific set of strings is for a documentLibrary
string fileUrl = web.Url + "/" + documentLibraryName + "/Forms/EditForm.aspx";
SPFile page = web.GetFile(fileUrl);
//This is how the form URLs get set
ct.NewFormUrl = page.ServerRelativeUrl;
ct.EditFormUrl = page.ServerRelativeUrl;
web.AllowUnsafeUpdates = true;
ct.Update();
list.Update();
using (SPLimitedWebPartManager wpartman = page.GetLimitedWebPartManager(PersonalizationScope.Shared))
{
//Loop through and hide the existing web parts
//You could also remove them but this causes some weirdness in SharePoint designer so only hide them if you need to work with attachments is my recommendation
for (int i = wpartman.WebParts.Count - 1; i >=0; i--)
{
System.Web.UI.WebControls.WebParts.WebPart wp = wpartman.WebParts[i];
wp.Hidden = true;
wpartman.SaveChanges(wp);
}
//Add your web part to the page and set its properties
MyWebPart webpart = new MyWebPart();
webpart.ChromeState = PartChromeState.Normal;
webpart.ChromeType = PartChromeType.None;
wpartman.AddWebPart(webpart, "Main", 1);
page.Update();
}
web.Update();
web.AllowUnsafeUpdates = false;
}