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

vsxmake: Launch console programs the same way VS does #1164

Closed
SirLynix opened this issue Dec 25, 2020 · 4 comments
Closed

vsxmake: Launch console programs the same way VS does #1164

SirLynix opened this issue Dec 25, 2020 · 4 comments

Comments

@SirLynix
Copy link
Member

SirLynix commented Dec 25, 2020

Is your feature request related to a problem? Please describe.

When starting the executable from a vsxmake project (instead of a regular vs one), it will be run directly, and will directly close on exit, instead of leaving a console with the program output. This is useful in case of error.

Describe the solution you'd like

That running a program using a vsxmake project (using F5 or Ctrl+F5) runs it the same way VS does.

Describe alternatives you've considered

Adding a std::getchar() call to the executable, but that is intrusive and don't work with crashes.

Additional context

It seems Visual Studio use VsDebugConsole.exe internally.

Here's the process tree of a program launched from a regular VS project:
image

Here's the process tree of a program launched from a vsxmake project:
image

This feature seems to be related to Tools->Options->Debugging->Automatically close the console when debugging stops (has to be unchecked) in regular VS projects, and requires /subsystem:console.

@SirLynix
Copy link
Member Author

Okay so this was not as complicated as I expected.

Setting the subsystem to "Console (/SUBSYSTEM:CONSOLE)" in the Visual Studio project did restore this behavior (this setting belongs to the project -> linker -> system -> subsystem).

This changes introduced an ItemDefinitionGroup in the vcxproj which sets this in the vcxproj file:

  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='debug|x64'">
    <Link>
      <SubSystem>Console</SubSystem>
    </Link>
  </ItemDefinitionGroup>

A simple way to fix this would be to do the same as vs project and generates a SubSystem entry which will be set to Console or Windows (even though xmake handles the build, this setting is used by VS to run the project).

@waruqi waruqi added this to the v2.5.1 milestone Dec 26, 2020
@waruqi
Copy link
Member

waruqi commented Dec 26, 2020

Ok, I will look at it.

@waruqi
Copy link
Member

waruqi commented Dec 27, 2020

I have supported it on dev branch.

@SirLynix
Copy link
Member Author

SirLynix commented Dec 27, 2020

I have tested it and it works well 👍 thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants