Generate Solution File From List of CSProj

前端 未结 7 1487
长情又很酷
长情又很酷 2020-12-15 09:25

I\'ve got alot of projects and I don\'t have a master solution with everything in it. The reason I want one is for refactoring.

So I was wondering if anybody knew a

相关标签:
7条回答
  • 2020-12-15 09:54

    Check out nAnt, the .NET port of Ant. It has the ability to do stuff like this, or to build without it.

    0 讨论(0)
  • 2020-12-15 09:56

    I've programmatically using text manipulation created solution files for .vcproj files (but cs/vb would work just the same). It isn't really hard to figure out how to do it if you open up a solution file in notepad or whatever.

    Unfortunately I cannot provide the code as it is proprietary.

    0 讨论(0)
  • 2020-12-15 09:57

    You can try this (the code below comes from this site, of all sites..)

    But if it doesn't work and it would take too much time to debug, I would suggest going for the pain of adding them manually once. Just put some good music and go for it... :)

    @oefe I don't think VS.NET allows you to D&D projects into solutions, I've tried that once.

    Imports EnvDTE
    Imports EnvDTE80
    -----------------------------------------------------------------------------------
        Private Shared Sub DoStuff()
    
            Dim filePath As String = "c:\temp"
    
            Dim fileName As String = "bld_TestApp.sln"
    
            Dim fullName As String = Path.Combine(filePath, fileName)
    
            Dim objType As Type
    
            Dim objDTE As EnvDTE.DTE
    
            objType = Type.GetTypeFromProgID("VisualStudio.DTE.8.0")
    
            objDTE = DirectCast(System.Activator.CreateInstance(objType), EnvDTE.DTE)
    
            Console.WriteLine(objDTE.Name + ":" + objDTE.Version)
    
    
            objDTE.Solution.Create(filePath, fileName)
    
            objDTE.Solution.AddFromFile("C:\Common.vbproj")
    
            objDTE.Solution.SaveAs(fullName)
    
    
        End Sub
    
    0 讨论(0)
  • 2020-12-15 09:59

    Vagif Abilov wrote a wonderful utility that will generate a solution file from project files. It is amazing if you are working for people who don't "believe" in solution files. ugh.

    GenerateSolutionFile.exe

    Usage: GenerateSolutionFile /p /s [/i includeFilter] [/e excludeFilter]

    http://bloggingabout.net/blogs/vagif/archive/2009/08/04/utility-to-generate-visual-studio-solution-file-for-a-group-of-projects.aspx

    0 讨论(0)
  • 2020-12-15 10:01

    In 2018, you can use dotnet sln command to add project to an existing solution and dotnet new sln to create a new one.

    To add all projects from current folder use these commands in PowerShell

    dotnet new sln
    Get-ChildItem -Recurse *.csproj | ForEach { dotnet sln add $_.FullName }
    
    0 讨论(0)
  • 2020-12-15 10:17

    Create an empty solution, then drag & drop all your projects into it at once?

    0 讨论(0)
提交回复
热议问题