Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSVS: Generated solution file with both MSVSSolution and MSVSProject auto_build_solution may be erroneous #4613

Closed
jcbrill opened this issue Oct 12, 2024 · 2 comments · Fixed by #4610
Labels
MSVC Microsoft Visual C++ Support

Comments

@jcbrill
Copy link
Contributor

jcbrill commented Oct 12, 2024

When passing the results of MSVSProject calls that auto build the solution files (i.e., auto_build_solution=1), the auto-generated solution files are included in the MSVSSolution generated solution file as Projects due to the contents of the returned values from MSVSProject.

I don't believe that solution files are valid Project files but I don't know for sure.

Test configuration:

  • Layout

    806 B Test-Folder
    806 B └─ SConstruct
    
    1 file
    
  • SConstruct File

    env=Environment(
        tools=['msvs'],
        MSVS_VERSION='14.3',
        HOST_ARCH='amd64',
    )
    
    p1 = env.MSVSProject(
        target = 'Test1.vcxproj',
        srcs = ['test1.cpp', 'test2.cpp'],
        incs = [r'sdk_dir\\sdk.h'],
        localincs = ['test.h'],
        resources = ['test.rc'],
        misc = ['readme.txt'],
        buildtarget = 'Test1.exe',
        variant = 'Release',
        auto_build_solution=1,
    )
    
    p2 = env.MSVSProject(
        target = 'Test2.vcxproj',
        srcs = ['test1.cpp', 'test2.cpp'],
        incs = [r'sdk_dir\\sdk.h'],
        localincs = ['test.h'],
        resources = ['test.rc'],
        misc = ['readme.txt'],
        buildtarget = 'Test2.exe',
        variant = 'Release',
        auto_build_solution=1,
    )
    
    env.MSVSSolution(
        target = 'Test.sln',
        projects = [p1, p2],
        variant = 'Release',
    )
    

Test results:

  • Output Layout

    18370 B Test-I2-P1S1A-M
      806 B ├─ SConstruct
     1710 B ├─ Test.sln
      820 B ├─ Test1.sln
     5393 B ├─ Test1.vcxproj
     1714 B ├─ Test1.vcxproj.filters
      820 B ├─ Test2.sln
     5393 B ├─ Test2.vcxproj
     1714 B └─ Test2.vcxproj.filters
    
    8 files
    
  • Build\Test.sln Fragment:

    # Visual Studio 17
    Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test1.vcxproj", "Test1.vcxproj", "{7A34FCB5-D229-56C1-949C-B631EEF1A199}"
    EndProject
    Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test1.sln", "Test1.sln", "{514B41F4-D961-5536-A064-0E1F7BB8C6CB}"
    EndProject
    Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test2.vcxproj", "Test2.vcxproj", "{CD7B5EA4-C079-57F3-BA37-C83ED1D7466D}"
    EndProject
    Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test2.sln", "Test2.sln", "{3542A23A-C6C3-5619-9C25-5FFC91F61566}"
    EndProject
    Global
    

Possibly invalid project definitions:

  • Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test1.sln", "Test1.sln", "{514B41F4-D961-5536-A064-0E1F7BB8C6CB}"
  • Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test2.sln", "Test2.sln", "{3542A23A-C6C3-5619-9C25-5FFC91F61566}"

All solution files likely should be filtered from the projects list when generating the solution file.

Required information:

  • Link to SCons Users thread discussing your issue.
    n/a
  • Version of SCons
    4.8.1 Master (SHA-1: fc36781)
  • Version of Python
    3.11.4
  • Which python distribution if applicable (python.org, cygwin, anaconda, macports, brew,etc)
    WinPython
  • How you installed SCons
    filesystem git repository master branch
  • What Platform are you on? (Linux/Windows and which version)
    Win 10
  • How to reproduce your issue? Please include a small self contained reproducer. Likely a SConstruct should do for most issues.
    See above and below
  • How you invoke scons (The command line you're using "scons --flags some_arguments")
    python PathToSconsRoot/scripts/scons.py from test folder root
@jcbrill
Copy link
Contributor Author

jcbrill commented Oct 12, 2024

PR #4610 assumes that solution files are invalid as Project definitions and filters the solution files from the projects list prior to generating solution files.

Tests results:

  • Output Layout:

    17750 B Test-I2-P1S1A-B
      806 B ├─ SConstruct
     1106 B ├─ Test.sln
      812 B ├─ Test1.sln
     5393 B ├─ Test1.vcxproj
     1714 B ├─ Test1.vcxproj.filters
      812 B ├─ Test2.sln
     5393 B ├─ Test2.vcxproj
     1714 B └─ Test2.vcxproj.filters
    
    8 files
    
  • Build\Test.sln Fragment:

    # Visual Studio 17
    Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test1", "Test1.vcxproj", "{7A34FCB5-D229-56C1-949C-B631EEF1A199}"
    EndProject
    Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test2", "Test2.vcxproj", "{CD7B5EA4-C079-57F3-BA37-C83ED1D7466D}"
    EndProject
    Global
    

If this is not the correct behavior, these changes to 4610 will need to be backed out.

@jcbrill
Copy link
Contributor Author

jcbrill commented Oct 14, 2024

Test: one MSVSProject auto_build_project (Test1.vcxproj and Test1.sln) and one MSVSSolution (Test.sln: Project Test1.vcxproj, Project Test1.sln).

When opening Test.sln, the VS IDE complains the Test1.sln Project is either not supported or needs to be modified and offers a one-way upgrade.

When attempting a one-way upgrade, a warning pops up indicating that the file Test1.vcxproj already exists on disk. Do you want to ovewrite the project and its imported property sheets? Yes or No.

Yes:

  • Popup: the solution already contains an item named Test1.sln
  • Migration log with errors
  • The solution appears to "work" after loaded.

No:

  • Popup: The project Test1.sln cannot be added to the solution because a project with the same project filename already exists in the solution.
  • Migration log with on warning
  • The solution appears to "work" after loaded.

There does not appear to be any benefit, nor new information, by including the auto-generated MSVSProject solution file in the MSVSSolution generated file.

#4610 automatically filters nodes with a sln extension. While this might not be correct in the general case, it should be for the SCons implementation.

Any thoughts?

@mwichmann mwichmann added the MSVC Microsoft Visual C++ Support label Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MSVC Microsoft Visual C++ Support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants