5

Using: VisualSVN Server, TortoiseSVN, AnkhSVN

I used TortoiseSVN to make an initial repository load for all my .NEt projects AND supporting sources / resources that i want to keep.

I am planning to use tortoiseSVN for all general source control actions and AnkhSVN for within Visual Studio solutions.

My problem is that my repository now has the developer/machine specific files/directories that i dont need.

I know Ankhsvn by using the SCC API from Microsoft does not include them if you add the solution to the repository from within Visual Studio.

So what i need now is to go and batch delete the necessary files/directories from the svn repository.

These include (but i may add more):

thumbs.db Thumbs.db *.bak *.class *.exe *.dll *.mine *.obj *.ncb *.lib *.log *.idb *.pdb *.ilk *.msi* .res *.pch *.suo *.exp *.*~ *.~* ~*.* cvs CVS .CVS .cvs release Release debug Debug ignore Ignore bin Bin obj Obj Generated Logs *.csproj.user *.user

How can i do it without of course going one by one?

Additional Info:

One idea is what Micha has proposed HERE but that must occur before moving to the repository.

Community
  • 1
  • 1
e4rthdog
  • 5,103
  • 4
  • 40
  • 89

2 Answers2

4

I always recommend to developers to use AnkhSVN and not to use TortoiseSVN when using VisualStudio projects. AnkhSVN will not allow you to check in private user files into your VIsualStudio project.

To get rid of these files, you will have to checkout the repositories in order to delete individual files. There's now way to get around that. Sorry...

First you need a list of the VisualStudio files that shouldn't be in your Subversion repository.

Then, you should get a Windows command line version of the Subversion client. You can get this from SlikSVN. A command line based Subverison client will allow you to programatically remove the unwanted files without going after them one at a time.

For example, if you use Cygwin which provides a GNU/Linux-like environment on your Windows system, you could do something like this:

$ svn checkout $repo-project $workdir
$ find $workdir \( -name "*.suo" -o -name "*.csproj.user" \) -exec svn delete {} \;
$ svn commit -m"Removing all VisualStudio private files from repo" $workdir

Or you can write a short Perl, Python, or even PowerShell program to do this for you.

If you don't know PowerShell, it might be a nice first project to do in PowerShell. All versions of Windows since XP come with PowerShelL. PowerShell is a very powerful scripting language -- vastly more powerful than Windows Batch, and even more powerful than Bash shell scripting. Heck, it's the equivalent of Python or Perl in scripting prowess. I simply don't understand why it's so rarely used in Windows-based development sites. However, if you do learn it, you'll find it a powerful tool for all sorts of Windowy stuff. PowerShell integrates with Windows registry, IIS, and all sorts of System Services.

Once you've deleted all of these user files, you can use this Subversion pre-commit to keep them out of your Subversion repository forever. The control file entry would be something like this:

[FILE You cannot add private user files into a VisualStudio project]
match = VSproject/.*/\.(suo|user|webinfo|dll|exe)$
access = no-add
users = @ALL
Community
  • 1
  • 1
David W.
  • 105,218
  • 39
  • 216
  • 337
  • Thanks! Powershell is indeed misunderstood for its powers! One question. What about nugget packages dir? I would like to put them also in repository, so excluding them (*.dll, *.exe) doesnt fit for me . Is it too bad? – e4rthdog Mar 20 '14 at 16:29
  • You can specify on a per-user basis that one user can add them while others cannot. The `no-add` allows them to be updated and deleted -- just not added. You can also specify that these are permitted in _nugget packages_ directories. The `match` is a regular expression match on the directory/file pattern. Plus, the order of the rules go from top to bottom. One rule can take away rights and a rule further down can add them back in. You could create a blanket rule, then add rules later on in the file to make the exceptions. – David W. Mar 20 '14 at 17:48
  • 1
    I am shocked at so few people who know PowerShell. I spend 90% of my time in the non-MS world. Tomcat and JBoss and not .NET. However, I've occasionally worked in a Windows environment, and piddled around in Powershell to get something done. I'm no PS expert, but I can see it's very powerful. I'm shocked at the number of people who live their entire lives in MSWorld who don't even know Powershell exists. Look at the difference between Powershell tags and Perl tags on Stackoverflow. I can't believe PS is so little used. – David W. Mar 20 '14 at 17:56
0

Best way is to do a clean up in VS before import to SVN.

If the files are still in repository I would recommend to do two checkouts. In one of them open VS an make a clean up, then make a file/directory-based compare of the two checkouts (and deleted the diff).

Micha
  • 5,117
  • 8
  • 34
  • 47
  • Although this does not address the issue if the files are already in the repo, its a good idea. Anotherway is to update the ignore specification of tortoiseSVN before adding to the repo and it will come clean.Export all-alter ignore-import again – e4rthdog Mar 20 '14 at 14:42
  • Second Part address the issue or do I ignore facts? Your idea sounds interesting. – Micha Mar 20 '14 at 19:06
  • I used that..I updated the ignore tortoisesvn settings, deleted the .svn directory and the folder from repo and re-import it...It worked just fine. – e4rthdog Mar 20 '14 at 19:15