Project Order in Visual Studio Solution

后端 未结 6 1060
我在风中等你
我在风中等你 2021-02-01 01:13

In Visual Studio 2008, what determines the order in which projects appear within a solution folder? It\'s not alphabetical order, nor is it build order.

I cannot find an

6条回答
  •  难免孤独
    2021-02-01 01:19

    Hacky alternative: Copy out the section with these lines into a text file.

    Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "etc..."
    EndProject
    

    Use this F# script to sort it alphabetically (changing file path as required):

    open System.IO
    
    let readlines p = File.ReadAllLines(p)
    let writelines p lines = File.WriteAllLines(p, lines)
    
    let startpos = @"Project(""{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"") = """.Length
    let getProj (s:string) = s.Substring(startpos, s.IndexOf('"', startpos) - startpos)
    
    let path = @"C:\Temp\sln.txt"
    path |> readlines
        |> Array.filter (fun s -> s.StartsWith("Project"))
        |> Array.map (fun s -> (getProj(s), s))
        |> Array.sortBy fst
        |> Array.map snd
        |> Array.collect (fun s -> [|s;"EndProject"|])
        |> writelines path
    

    (If you've only got a few projects, just sort it by hand)

提交回复
热议问题