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

Running MSBuild based build task hangs forever #35752

Closed
plbpietrz opened this issue Oct 6, 2017 · 11 comments
Closed

Running MSBuild based build task hangs forever #35752

plbpietrz opened this issue Oct 6, 2017 · 11 comments
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s) tasks Task system issues
Milestone

Comments

@plbpietrz
Copy link

VSCode gets stuck when trying to build a simple C++ project (Visual C++ template console app) using the default build task (generated by the editor) with the terminal showing that it tries to execute MSBuild. The editor indicates that the command is running but the process explorer shows only one new code.exe process instance spawned and one of the existing earlier code.exe processes spinning excessively on Code.exe!IsSandboxedProcess, nothing else. Now I can't run any more build tasks and cannot stop the 'executing' one. To reset the situation I have to restart the editor.

  • VSCode Version: 1.16
  • OS Version: Windows 10 Professional x64

Steps to Reproduce:

  1. Create dummy C++ console app project in Visual C++
  2. Open solution folder with code . (from visual studio developer prompt but no difference if normal cmd.exe is used)
  3. Create default MSBuild build task in tasks.json
  4. Execute build task (ctrl + shift + b)
  5. Wait...

Reproduces without extensions: Yes

@vscodebot vscodebot bot added the tasks Task system issues label Oct 6, 2017
@dbaeumer dbaeumer added this to the October 2017 milestone Oct 6, 2017
@Identifier
Copy link

I'm having the exact same issue with a C# project (trying to use msbuild task to generate an .exe with .NET 4.7 -- not using .NET Core). The build task just hangs forever (shows a spinning icon in the bottom-left statusbar) and killing VS Code is the only way to terminate it. I'm attaching the sample project here.

HangsVSCode.zip

@dbaeumer
Copy link
Member

dbaeumer commented Oct 12, 2017

I was able to reproduce this. It is independent of the .Net version. I haven't found out yet why this is broken right now (it used to work before), but an easy workaround is to change the type from process to shell.

{
	// See https://go.microsoft.com/fwlink/?LinkId=733558
	// for the documentation about the tasks.json format
	"version": "2.0.0",
	"tasks": [
		{
			"taskName": "build",
			"type": "shell",
			"command": "msbuild",
			"args": [
				// Ask msbuild to generate full paths for file names.
				"/property:GenerateFullPaths=true",
				"/t:build"
			],
                        "group": {
                            "kind": "build",
                            "isDefault": true
                        },
 			"presentation": {
				// Reveal the output only if unrecognized errors occur.
				"reveal": "silent"
			},
			// Use the standard MS compiler pattern to detect errors, warnings and infos
			"problemMatcher": "$msCompile"
		}
	]
}

@dbaeumer
Copy link
Member

@Tyriar to execute a process in the terminal I basically uses it as the executable to be started. The command line for the msbuild process looks like this:

capture

For some reason that fails but I get no feedback why. All I see is that the node process started as --type=terminal is still around but has no sub processes. If it try to execute a task like this

        {
            "taskName": "node",
            "type": "process",
            "command": "node",
            "args": [
                "hello.js"
            ]
        }

it works fine. So this is not a principal issue. I guess somehow the command line for msbuild gets messed up. Is there a way I can debug this?

@dbaeumer
Copy link
Member

@Tyriar I found #31301 which is very likely the cause of this.

@Identifier
Copy link

@dbaemer thanks, setting type from process to shell definitely got past the hanging build task problem. Now it's on to the next issue for me:

> Executing task: msbuild /property:GenerateFullPaths=true /t:build <

'msbuild' is not recognized as an internal or external command,
operable program or batch file.
The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.

I will look for a separate bug for that. Thanks!

@plbpietrz
Copy link
Author

@Identifier is MSBuild on your %PATH%? I used to run code from a developer prompt provided by the Visual Studio installation so the directory containing msbuild was already on the search path. It's not set globally by default.

@Identifier
Copy link

@plbpietrz Nope, I purposefully haven't installed Visual Studio on this machine yet - I wanted to see how easy it was to create a simple console application (.exe, not .NET Core) with just VSCode on a clean machine. I was hoping that the version of MSBuild that comes with OmniSharp would have been sufficient but unfortunately it's not. Even if you add it to the path (or fully specify the full path in the "command" parameter in tasks.json) it fails for some other reason:

> Executing task: C:\Users\User\.vscode\extensions\ms-vscode.csharp-1.12.1\.omnisharp\msbuild\MSBuild.exe /property:GenerateFullPaths=true /t:build <


Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Build.Framework, Version=15.1.0.0,
 Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
   at Microsoft.Build.CommandLine.MSBuildApp.Execute(String commandLine)
   at Microsoft.Build.CommandLine.MSBuildApp.Main()
The terminal process terminated with exit code: 3762504530

Terminal will be reused by tasks, press any key to close it.

I finally got it to build on the clean machine by pointing to a version of MSBuild at C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe which must have been installed sometime else. But none of this would have been even possible without @dbaemer's suggestion of changing the type from process to shell. Thanks again @dbaeumer

@Tyriar
Copy link
Member

Tyriar commented Oct 12, 2017

@dbaeumer yeah I was reminded of #31301, let's leave this open until we close that so we can get this verified independently.

@dbaeumer
Copy link
Member

@Identifier good to hear that it works for you as a shell task. I will make this the default for msbuild since it makes more sense anyways. Keeping this open since we need to fix the underlying issue as well.

@dbaeumer dbaeumer modified the milestones: October 2017, On Deck Oct 13, 2017
@alexjamesbrown
Copy link

changing from process to shell worked for me too.

@dbaeumer dbaeumer added the bug Issue identified by VS Code Team member as probable bug label Nov 8, 2017
@dbaeumer
Copy link
Member

OK. #31301 got addressed. I will close this issue since it will now correctly result in an error if msbuild can't be found.

@dbaeumer dbaeumer added *duplicate Issue identified as a duplicate of another issue(s) and removed bug Issue identified by VS Code Team member as probable bug labels Sep 24, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s) tasks Task system issues
Projects
None yet
Development

No branches or pull requests

5 participants