Revision: 25056
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 18, 2010 15:33 by deepsoul
Initial Code
#!/usr/bin/perl -w use strict; my $targetver= 9; my %veryear= ( 8 => 2003, 9 => 2005, 10 => 2008 ); my $year= $veryear{$targetver}; my $projver= $targetver - 1; sub downsln { my ($fname)= @_; if( ! open IN, "<$fname" ) { print STDERR "Could not open $fname: $!\n"; return; } local $/; my $data= <IN>; close IN; print "Downgrading $fname...\n"; $data =~ s/((?:^|\n).*\bVisual Studio\b.*\bFormat Version\b.*?)\d+\.\d+/$1$tar getver.00/ or print STDERR "Could not replace version number in $fname\n"; $data =~ s/\n\#\s+Visual .*20\d\d/\n\# Visual Studio $year/ or print STDERR "Could not replace release year in $fname\n"; if( rename($fname, "$fname.down") && open(OUT, ">$fname") ) { print OUT $data; close OUT; } else { print STDERR "Could not rename / write $fname.\n"; } my @projs= $data =~ /\nProject.*?=.*?,\s*\"([^"]+)\"/g; my $basedir= $fname; $basedir =~ s![^/]*$!!; for (@projs) { downproj($basedir . $_, $fname); } } sub downproj { my ($fname, $slnname)= @_; if( ! open IN, "<$fname" ) { print STDERR "Could not open $fname: $!\n"; return; } local $/; my $data= <IN>; close IN; print "Downgrading $fname...\n"; $data =~ s/\n(\s*Version\s*=\s*\")\d+([,.])\d+\"/\n$1$projver${2}00\"/ or print STDERR "Could not replace version number in $fname\n"; if( rename($fname, "$fname.down") && open(OUT, ">$fname") ) { print OUT $data; close OUT; } else { print STDERR "Could not rename / write $fname.\n"; } } for my $arg (@ARGV) { $arg =~ s/\\/\//g; $arg =~ s/^([a-z]):\//\/cygdrive\/$1\//i; if( $arg =~ /\.sln$/ ) { downsln($arg); } else { downproj($arg); } }
Initial URL
Initial Description
Some (all?) Visual Studio projects can be opened with older versions without problems once their version numbers have been reduced. The following Perl script does this; it also recurses over the projects contained in a project folder (.sln) file. It saves you upgrading all your installations.
Initial Title
Downgrade Visual Studio project
Initial Tags
Initial Language
Perl