Omar Shahine's Clean Sources is a nifty little right-click app for .NET developers:
This application does one thing. It adds an explorer shell menu to folders that when selected will recursively delete the contents of the bin, obj and setup folders. If you have a .NET project that you wish to share with someone, this is useful to remove the unnecessary stuff from the folder before you zip it up and send it off.
There's one glaring omission here, though. The source control bindings aren't removed! And neither are the local user setting files. I finally had some time, so...
Presenting Clean Sources Plus. It adds a right-click menu to folders that does the following:
The result is a very clean, minimal set of .NET solution files, suitable for upload or sharing.
Updated to version 1.1 on 11/10/05 with the following new features:
I tested this with both C# and VB projects, but I'm not 100% sure it works for all other types of projects. It shouldn't break anything, but I may have missed some oddball project type (database? setup?) source bindings. And I only tested against the typical SourceSafe bindings. Anyway, test it out and let me know if there are any issues.*
You may also be interested in TreeTrim, which is based on this project.
* If this app deletes all your source code, then it's Omar's fault.
LOL!
Omar Shahine on August 21, 2005 11:26 AMis useful to remove the unnecessary stuff from the folder before you zip it up and send it off.
Now that I'm re-reading this, it seems logical that there should be an additional right click to do this as well.. why not cut out the middleman? eg
"Clean Sources"
"Clean Sources and Zip"
"Clean Sources, Zip and Email"
But what's the best way to ZIP the files without adding a bunch of dependencies to our solution? We could use the zip assembly.. or is there an easy-ish way to programmatically drive the "compressed folders" support in XP?
Jeff Atwood on August 21, 2005 11:37 AMThis sounds handy, but I wish VS.NET would have let me simply organize my sources the way I want in the first place. I prefer having all source separate from bin and obj directories, so that it is easier to perform these sorts of clerical tasks.
Ned Batchelder on August 22, 2005 3:46 AMGreat utility! Thanks for enhancing Omar's already slick tool, Clean Sources. This works great!
Brian Swiger on August 22, 2005 4:43 AMWhy not just skip the clean step and do "Zip Sources"? It can just omit all the files that would have been cleaned but doesn't touch your disk, except to write the new Zip file.
David Avraamides on August 22, 2005 8:35 AMVery nice! Removing source bindings by hand is pain, I've had to do it on a few occasions. Thanks!
SharpZipLib supports in memory compression, its in the FAQ. It's a very handy feature. http://wiki.sharpdevelop.net/default.aspx/SharpZipLib.FrequentlyAskedQuestions
Daniel F on August 22, 2005 10:16 AMGah, slapped that submit button a wee bit early. As I was about to say...
Should be relatively easy to edit the files in memory, zip them in memory, then save the zip somewhere for emailing. Not sure what the free options are for emailing without persisting the zip to disk, I've only ever used commercial email components. I probably should download the source and see how it's currently done, eh? :-)
Thanks again Jeff!
Daniel F on August 22, 2005 10:21 AMVery cool utility, Jeff.
One thing on the Zipping (which is a great idea)... there are still W2K users our here (yeah, yeah, I know), so please don't bind this utility to XP+, if possible.
David's got a great point... A "Safe Zip Sources" option, in addition to the others, that didn't touch original files would be pretty cool too.
The hard part would be the source control binding removal... Maybe backup/rename existing file, remove bindings and save as original file name, zip, copy old/original file over the cleaned version, delete backup.. etc, etc...
LOL, easy for me to say... Since I have the source maybe I should shut-up and just do it!!! ;)
Damn open source... LOL
Greg on August 22, 2005 11:55 AMNice, thanks.
One possible (and easy) improvement:
Can you also try to delete _svn folders? They are created by a special version of Subversion compatible with VS.NET web projects.
Thanks.
Tomas
Thanks Jeff. Just what I was looking for.
I made a small change to store the Directory, File and Binding pattern in a .config file so it's easy to change when you find new directories. I use Vault which has an _sgbak folder to remove.
Works great!
Richard
Richard Edwards on September 6, 2005 10:48 AMI updated the project to version 1.1 incorporating some of the features in the comments here. The details are in the post, but to summarize:
- "Clean and Zip Sources" menu item
- file and folder deletion regex patterns are set in .config file
I couldn't figure out a way to (easily) automatically spawn an email with an attachment. Using a mailto: URL with an attachment param definitely doesn't work..
I didn't implement the "safe" no-touch zip option yet. Maybe for version 1.2.
I'd also like the context menu to be a submenu, since we may have 3-4 options in it once the "safe" options are online. That's pushing it a bit for a right-click menu on every folder. But I couldn't figure out how to set up the registry to achieve that. Hints??
Jeff Atwood on November 10, 2005 5:35 AMThanks Jeff, v. useful.
I quickly knocked up a MAPI class, so you can now create the emails. You can find it here.
a href="http://www.vbusers.com/codecsharp/codeget.asp?ThreadID=71PostID=1"http://www.vbusers.com/codecsharp/codeget.asp?ThreadID=71PostID=1/a
thanks
andrew
Great tool! I've done a similar tool that finds orphaned items, i.e. items that are on disk but not specified as part of a project. The link is on my blog. I can't post the url of my blog for some reason. Anyway, google for "steve dunn" blog. Cheers, Steve Dunn.
Steve Dunn on October 22, 2006 3:01 AMHi Jeff, thanks for the useful utility. While trying to set the configuration file to be able to delete .svn directories, I've incurred into the problem that the Directory.Delete method fails if the directory contains readonly files, so I've slightly edited your code to first navigate all the directory subtree and remove all the readonly attributes from the files. Your DeletePath method becomes:
Private Sub DeletePath(ByVal path As String)
Try
If IsDirectory(path) Then
SetAllFilesReadWrite(path) ' added this call
Directory.Delete(path, True)
Else
If GetFileReadOnly(path) Then
SetFileReadOnly(path, False)
End If
File.Delete(path)
End If
Catch ex As Exception
DumpException(ex, "delete file or path", path)
End Try
End Sub
And the body of the SetAllFilesReadWrite method is as following:
Private Sub SetAllFilesReadWrite(ByVal path As String)
Dim di As New DirectoryInfo(path)
For Each file As FileInfo In di.GetFiles()
If GetFileReadOnly(file.FullName) Then
SetFileReadOnly(file.FullName, False)
End If
Next
For Each dir As DirectoryInfo In di.GetDirectories()
SetAllFilesReadWrite(dir.FullName)
Next
End Sub
Could you update it for VS2008?
It's turning the SLN files into "unknown VS version" on the VS version selector, and upon opening the cleaned solutions, a SCC message mentioning "Visual Studio 6.0" appears :S
Thanks!
Daniel Cazzulino on December 30, 2007 11:34 AMDo you happen to have an update to .NET 2.0 or 3.5 by any chance? Possibly with a nice visual configuration dialog? :-)
Marc Scheuner on February 29, 2008 12:41 PMHere is another request for a VS2008 update.
Alexey Romanov on March 16, 2008 2:43 AMHow about a custom MSBuild task that will do this? I'm thinking about giving it a try.
Another request for vs2008 update.
Bryan on April 11, 2008 9:52 AMWould also love to see an update to 2008, and the "no touch" version which creates the nice zip file with touching the original source.
Daniel McPherson on May 15, 2008 4:23 AMHere is to VS2008!
Steve on June 12, 2008 1:20 PMSo, will there be a 2008 version?
Dave on June 16, 2008 9:01 AMI've created a tool that will allow you to right-click on a project or solution in Windows Explorer and zip it up. It can also attach the zip file to an email using the users email client.
If you are interested, the project is called VS Project Zipper (source code is available). You can get more information about it from...
http://www.redwerb.com/files/folders/tools/entry118.aspx
Brian Brewder on July 7, 2008 1:36 PMare you still maintaining this?
Double K on August 28, 2008 1:25 PMHi,
I've been working on a tool that extends CleanSourcesPlus. It's called TreeTrim and has most of the features discussed here (working copy or 'no touch').
Please feel free to take a look and spread the word at http://code.google.com/p/treetrim/
Cheers,
Steve
Steve Dunn on April 13, 2009 5:14 AMHi,
Is there a tool to clean up unused methods/functions from the .net solution??
Please let me know ASAP
Thanks in advance
Meera
Meera, resharper cleans unused methods.
Nocopy on June 23, 2009 5:34 AMPerfect! You read my mind with the app.config regex setup. Good show!
Jon Galloway on February 6, 2010 9:29 PMI get the same Visual Studio 6.0 message as Daniel. Any ideas as to why?
Also, I've removed the source binding files from the config but it still unbinds me from TFS.
By the way, great tool, really useful, so thanks! :) I use it to take code home...get from TFS, zip, take home, back to work, rebind, "tfpt uu" + "tfpt online". Easy! (tfpt = Team Foundation Power Tools)
Sean Kearon on February 6, 2010 9:29 PMDownload link seems to be down?
www.google.com/accounts/o8/id?id=AItOawlMts8PMT-vwGXb0fPU9g5Ewi9Tr4gjBhk on February 28, 2010 11:16 AMConfirmed, both download links are broken. Is there any way you can repost them?
Thank you very much in advance!
-Ian
The comments to this entry are closed.
|
|
Traffic Stats |