Share via


“Pasting” attachments to work items in Visual Studio

Today I deleted my CodePlex project TfsPasteAttachment

It was (up until today) located @ https://tfspasteattachment.codeplex.com/

Since the functionality had been removed from the product during Whidbey, the codeplex project was an add-in that added it back for people still using Visual Studio (more specifically, Team Explorer) 2005.  However, since the functionality went back in with Orcas (TFS 2008) and that’s been out so long, there’s not much reason to keep that project around any longer.

I had added it back during the Whidbey development cycle to scratch my own itch – I was filing lots of bugs during our bug bashes, but I got sick of how much time it took me to get screenshots or logs attached to the bugs I was filing (bugs filed without logs/screenshots/etc make me quite sad).  Back then you didn’t bug bash on your own machine (mainly due to the 2.0 CLR being still a work in progress at the time and the logistics around that – this was before Hyper-V :), but TS’d into a remote machine (very remote for those of us in North Carolina! :) – since it was remote, I even noticed people that didn’t know about mstsc’s clipboard-transfer capabilities saving files on the remote machine then copying them to their desktop machine to attach to the new bug (ouch!)

Getting the data I wanted to attach to the bug into the clipboard was pretty simple:

During my existing bug filing, I found I would either paste the file(s) to my desktop and attach them from there or for text or image data I’d open notepad or mspaint, respectively, paste it in, save it to a file on my desktop, and then attach that file (then delete the file after I had saved the attachment to the work item).  Lots of manual work, unfortunately, and if I forgot to delete them, random temp files laying around my desktop.

So the question was then “How do I get this data from the clipboard into an attachment on the work item with less steps?”

The clipboard part ended up being ridiculously easy thanks to the great static methods available in the BCL’s Clipboard class.

The other part, getting it onto the work items, was pretty straightforward as well thanks to the Attachments property off of WorkItem.  The rest of the code (hooking into the attachments UI control, for instance) was also straightforward thanks to help from Jason Prickett who was on the Work Item team at the time (and right down the hall!).

To use

As you’d expect, the user interaction is that of “pasting” (control-v by default) into the attachment control.  You can do this with files (1 or more), text, or image data in your clipboard and it’ll attach it to the work item.  In addition, for the particular case of files you can drag-drop them as well.

Adding files (this via control-v of files that I control-c’d in Explorer)

image

Adding text (this via control-v of text that I control-c’d in notepad)

image

Adding screen shots (this via control-v of an image that I captured via Win+S with OneNote – incidentally, that’s also how I make the screen captures for blog posts)

image

Comments