eyepopslikeamosquito has asked for the wisdom of the Perl Monks concerning the following question:

I'd like to convert proprietary Visual Studio .NET .sln files I get from others into something I can build with a free build tool.

Googling uncovered this thread where dave stated he may write a Perl CPAN module to do it. I also found SLiNgshoT (in NAnt.Contrib.Tasks) which seems like it should be able to do the job.

Anyone done this before or know of a tool (preferably Perl) to do the conversion?

  • Comment on Converting .NET .sln files to nmake/nant format

Replies are listed 'Best First'.
Re: Converting .NET .sln files to nmake/nant format
by EverLast (Scribe) on Nov 08, 2004 at 08:10 UTC
    I would recommend rolling your own converter.

    First off, you should target your efforts towards the '.vcproj' files - as they are holding the actual files in the project. Refer to Microsoft for the full XML schema. (Hey, they actually documented this!).

    Then use XML::Simple or whatever our preference is to parse, rinse, stir and output to a nmake/gmake/whatnot file.

    The '.sln' file is not XML, but a pretty straight-forward text-file, most notably linking to the '.vcproj' files.

    I haven't converted in this direction, but rather generated .vcproj files from other input.

    Following code should get you started (assumes '.sln' file(s) as args):

    use strict; use warnings; use XML::Simple; use Data::Dumper; my(%projs); while(<>) { # Extract project files linked into solution if(/^Project\(.+\)\s+=\s+\"([^"]+)\",\s+\"([^"]+)\"/) { $projs{$1} = $2; # Got one! } } # Process the project files - XML format my $xs = new XML::Simple(); for my $p (keys(%projs)) { my $file = $projs{$p}; print "Parsing $p, file $file\n"; my $ref = $xs->XMLin($file); # Print parsed XML - or output in another format? print Dumper($ref); }

    Cheers,

    ---Lars

    Update: Added code snippet

Re: Converting .NET .sln files to nmake/nant format
by gellyfish (Monsignor) on Nov 08, 2004 at 10:29 UTC

    If you have a working .NET environment of some sort you might be interested in Prj2Make-SHarp which will create nmake or gnu make compatible makefiles from the .sln files. Of course it isn't Perl but does work very well.

    /J\