I'm often in a situation where I need to quickly build new web parts, this could be because I want to do some testing or because I'm working on a "Proof of Concept" for a customer. In these scenarios time is the most important factor in the development process. **
I have come up with some simple steps that I think streamlines the Web Part creation process, ensuring you are up and running with a debuggable/deployable web part as quickly as possible:
1) Install the Web Part template for Visual Studio:http://www.microsoft.com/downloads/details.aspx?FamilyId=CAC3E0D2-BEC1-494C-A74E-75936B88E3B5&displaylang=en
Install the Web Part template for Visual Studio:http://www.microsoft.com/downloads/details.aspx?FamilyId=CAC3E0D2-BEC1-494C-A74E-75936B88E3B5&displaylang=en
2) Create a new project in Visual Studio using the Web Part project template, I find it useful to create it as part of a solution, as you will see later, when you do the deployment piece you will need to add an additional Visual Studio project.
3) "Setup" the project for your web part. This involves setting the correct class names, namespaces, etc. to something appropriate to your web part.
4) Set the build path to the \bin directory of the Virtual Server where the portal where you will be running the web part is located. If there isn't one already, create it.
5) Build the project. This will give you a web part that simply displays the value of a property, it's what the template installed in step one gives you. The important thing is that you have now built a Web Part .DLL in the Portal sites \bin directory from Visual Studio. By doing this you have "debug enabled" the web part project.
6) Install the new web part into your portal using the great "InstallAssemblies" tool written by Maurice Prather here: http://www.bluedoglimited.com/SharePointThoughts/ViewPost.aspx?id=13 and give it a quick test.
The reason I use this tool is laziness, it automatically does two things that often cause Web Part developers the most trouble:
Creates a valid "Safe Control Entry"
Creates a valid Web Part .DWP file
7) Take the .DWP file that InstallAssemblies creates, either by using the button on the tool UI, or looking inside the Portal Virtual server \wpcatalog directory and add it to your project. This replaces the one created as part of the original Visual Studio Template. Update the Manifest file so that it can now find this new .DWP file, and then take the SafeControlEntry from your Portals Web.Config file and replace the one already in the Manifest file.
At this point you are ready to start debugging the Web Part. Place some break points, do a build, then attach to the W3WP process on the Portal server. Drop the web part onto a page and bingo, you are debugging.
Take this a little further by applying polish.
8) When you have finished your web part we can build the deployment package called a "Web Part Package". Create a new Deployment Project (.CAB) inside the existing solution and populate it with the output from the Web Part project. When complete build the new project.
9) Finally, remove the version of the web part you added using InstallAssemblies (this is also a feature of the tool) then replace it with your new packaged version using STSADM.EXE.
At the end of all this you have an easily debuggable/deployable (and pretty) web part in under 10 minutes.
This is all very "Quick and Dirty", so for further reading I would check out the following:
Best Practices for Developing Web Parts for SharePoint Product and Technologies
The definitive "Hello World" Web Part Tutorial
Packaging and Deploying Web Part for Windows SharePoint Services
Let me know if you have any other tips or tricks!
** Note these steps do not document how to create a "Production Quality" web part.