简体   繁体   中英

Generate Solution File From List of CSProj

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 an automatic way to build a solution file. Manually adding all the projects just isn't feasible.

我现在更新了我的实用程序(如上所述)以支持创建解决方案文件夹: http//bloggingabout.net/blogs/vagif/archive/2009/12/03/utility-to-generate-solution-files-can-现在创建的解决方案,folders.aspx

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

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

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 }

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.

创建一个空的解决方案,然后立即将所有项目拖放到其中?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM