简体   繁体   中英

Create a Visual Studio 2010 Solution with multiple projects from a text editor

I'm using a template based tool which will essentially generate me 3 folders which will contain a "project" in each one eg

  1. BusinessObjects - Business and Database Layers
  2. WebsiteA - An ASP.NET WebForms based application which will need to use classes from the BusinessObjects project
  3. WebsiteB - An ASP.NET MVC based application which will need to use classes from the BusinessObjects project

I've successfully generated the actual files needed for each "project" but now I need to be able to automatically create a Visual Studio 2010 Solution which contains all three projects complete with references to each one.

I think I need to create a .sln file in the root directory, along with .vbproj files in each folder, however I don't know exactly what they will need to contain, or how they will be linked together. I've looked at some existing .sln/.vbproj files and they all seem to have a GUID in them but is this something that VS needs to create?

eg This is a basic .sln file, but can I make the GUID's up?

    Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "WebApplication1", "WebApplication1\WebApplication1.vbproj", "{84EF3C82-FD86-41D0-8EBE-8D887DA10742}"
EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ClassLibrary1", "ClassLibrary1\ClassLibrary1.vbproj", "{A975CCB0-F694-4C51-B7FF-515D523E56CD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvcApplication1", "MvcApplication1\MvcApplication1.csproj", "{2BF02F04-B408-43B0-A7F7-81F13FF3EAFF}"
EndProject
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
        Debug|Any CPU = Debug|Any CPU
        Release|Any CPU = Release|Any CPU
    EndGlobalSection
    GlobalSection(ProjectConfigurationPlatforms) = postSolution
        {84EF3C82-FD86-41D0-8EBE-8D887DA10742}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {84EF3C82-FD86-41D0-8EBE-8D887DA10742}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {84EF3C82-FD86-41D0-8EBE-8D887DA10742}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {84EF3C82-FD86-41D0-8EBE-8D887DA10742}.Release|Any CPU.Build.0 = Release|Any CPU
        {A975CCB0-F694-4C51-B7FF-515D523E56CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {A975CCB0-F694-4C51-B7FF-515D523E56CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {A975CCB0-F694-4C51-B7FF-515D523E56CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {A975CCB0-F694-4C51-B7FF-515D523E56CD}.Release|Any CPU.Build.0 = Release|Any CPU
        {2BF02F04-B408-43B0-A7F7-81F13FF3EAFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {2BF02F04-B408-43B0-A7F7-81F13FF3EAFF}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {2BF02F04-B408-43B0-A7F7-81F13FF3EAFF}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {2BF02F04-B408-43B0-A7F7-81F13FF3EAFF}.Release|Any CPU.Build.0 = Release|Any CPU
    EndGlobalSection
    GlobalSection(SolutionProperties) = preSolution
        HideSolutionNode = FALSE
    EndGlobalSection
EndGlobal

Does anyone know if this is possible, or have a simple example of the minimum each .sln and .vbproj file wouldneed to contain in order to automatically create a solution?

Thanks, Mark

It's not easy to generate the solution file. For the beginning, you could analyze a handcrafted solution file with all three projects. Or with just one project to make it simple.

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