locked
Can't Compile Hello World Metro Application

    Question

  • So I decided to try my luck with a Metro Hello World app in Visual Studio 11. I copied the code from the documentation online and it looks good. But when I went to compile, I'm getting an odd error. 

     

    Error	1	The build stopped unexpectedly because of an internal failure.
    Microsoft.Build.Exceptions.BuildAbortedException: Build was canceled. Failed to successfully launch or connect to a child MSBuild.exe process. Verify that the MSBuild.exe "C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" launches successfully, and that it is loading the same microsoft.build.dll that the launching process loaded. If the location seems incorrect, try specifying the correct location in the BuildParameters object, or with the MSBUILD_EXE_PATH environment variable.
       at Microsoft.Build.BackEnd.NodeProviderOutOfProc.CreateNode(Int32 nodeId, INodePacketFactory factory, NodeConfiguration configuration)
       at Microsoft.Build.BackEnd.NodeManager.AttemptCreateNode(INodeProvider nodeProvider, NodeConfiguration nodeConfiguration)
       at Microsoft.Build.BackEnd.NodeManager.CreateNode(NodeConfiguration configuration, NodeAffinity nodeAffinity)
       at Microsoft.Build.Execution.BuildManager.PerformSchedulingActions(IEnumerable`1 responses)
       at Microsoft.Build.Execution.BuildManager.HandleNewRequest(Int32 node, BuildRequestBlocker blocker)
       at Microsoft.Build.Execution.BuildManager.IssueRequestToScheduler(BuildSubmission submission, Boolean allowMainThreadBuild, BuildRequestBlocker blocker)	C:\Users\bossman1086\Documents\Visual Studio 11\Projects\Hello World\Hello World\Hello World.csproj	Hello World
    


    I went and checked all the versions of MSBuild.exe on my machine and they all seem to be there and can run just fine. I'm at a loss as to why I can't get it to compile. It's a clean install of Win8 Preview (x64) with dev tools on its own partition on my machine. It shouldn't matter, but my specs are: 2.6 Ghz Intel Core i7, 6 GB DDR3 RAM, nVidia GeForce GTX 275 (Factory OC), 2 TB SATA II 7200rpm HDD.

    I'd really like to get started with some Metro/Win8 programming. I'd appreciate any help I can get. Thanks!

    Wednesday, September 14, 2011 8:19 AM

Answers

  • Hi,

     

    you probably already saw this in the email I sent but just wanted to share what we found to date

    So I can’t reproduce the original msbuild issue but I can reproduce the compilation errors.  It turns out there is a very subtle typo in project that doesn’t work

    In Mainpage.xaml, we have something  like

    <UserControl x:Class="HelloWorld.MainPage"

    If you change it to

    <UserControl x:Class="Hello_World.MainPage"

    Then we’ll avoid the errors

    ·         Error                                                             1       Cannot implicitly convert type 'Hello_World.MainPage' to 'Windows.UI.Xaml.UIElement'                                       C:\Users\bossman1086\Documents\Visual Studio 11\Projects\Hello World\Hello World\App.xaml.cs                                                 17      38      Hello World

    ·         Error                                                             2       The name 'InitializeComponent' does not exist in the current context                                                                  C:\Users\bossman1086\Documents\Visual Studio 11\Projects\Hello World\Hello World\MainPage.xaml.cs                                            16      13      Hello World

    If you make that change, does the BuildAbortedException CouldNotConnectoMsBuildExe error still repro?  E.g.

    ·         Error                                                               1       The build stopped unexpectedly because of an internal failure.

    ·         Microsoft.Build.Exceptions.BuildAbortedException: Build was canceled. Failed to successfully launch or connect to a child MSBuild.exe process. Verify that the MSBuild.exe "C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" launches successfully, and that it is loading the same microsoft.build.dll that the launching process loaded. If the location seems incorrect, try specifying the correct location in the BuildParameters object, or with the MSBUILD_EXE_PATH environment variable.

    Thanks!

    mike

    Wednesday, September 21, 2011 7:54 PM
    Moderator

All replies

  • To help narrow this down further, can you just create a blank application from the template in Visual Studio, complile and run it or is it only the code/project that you are using that is causing the problem?


    Jeff Sanders (MSFT)
    Wednesday, September 14, 2011 12:59 PM
    Moderator
  • It happens even with a blank application. I'm using a C# Metro Style App as the template.

     

    I just tested a C++ application from a template, and that works fine.

    Wednesday, September 14, 2011 4:23 PM
  • @Bossman1086:

    Could you try compiling a project with msbuild.exe, i.e. %windir%\microsoft.net\framework\v4.0.30319\msbuild.exe [your project]
     
    If that works, could you add a second project to the solution, and try %windir%\microsoft.net\framework\v4.0.30319\msbuild.exe [your project] /m.

    If this succeeds, could you open VS right after and see if build works thereafter in VS?

    Wednesday, September 14, 2011 4:44 PM
  • When I'm using msbuild.exe to build it and passing it my project, which file do I use as the argument? The sln? csproj?
    Wednesday, September 14, 2011 5:25 PM
  • The .csproj.
    Wednesday, September 14, 2011 5:38 PM
  • Hello Bossman1086,

     

    so if you launch a developer command prompt ( start | Search | Apps | Developer Command prompt), type in the command

     

    msbuild /nologo /nodemode:1 /nr

     

    Does that launch msbuild successfully or does it throw a similar error to the above?  Check task manager | Details tab.   Also, as another troubleshooting step (not meant to be your solution but to get more clues to what might be going on) could you right click on the computer, select advanced, properties, Advanced system settings, environment variables, add a system environment MSBUILD_EXE_PATH, the value should be set to

    c:\windows\microsoft.net\framework\v4.0.30319

    where c:\windows is the directory where Windows 8 is installed.

    What are the versions of msbuild.exe and microsoft.build.dll in that directory?  We are not required to specify the environment variable but it will be interesting to hear about the results as a troubleshooting step.

    Thanks!

    Mike Wong

    Microsoft Developer Support

     

    Wednesday, September 14, 2011 5:50 PM
    Moderator
  • Ugh. It's annoying I can't scroll through the task manager with my mouse scroll wheel.

    Anyway, when I do the "msbuild /nologo /nodemode:1 /nr"  it just sits there and doesn't respond at all. No error, but just a blinking cursor.

    I did not have the MSBUILD_EXE_PATH variable in my environment variables. I did add it.  After adding the variable, I don't get that error anymore, but I still can't compile even a blank project with C#. I get error messages about the automatically generated code.

    As for MSBuild.exe and the dll in that directory, the version number for msbuild.exe is 4.0.30319.17020 and the dll's version number is the same.

     

    After adding the evironment variable the errors I get are:

     

    Error	1	Cannot implicitly convert type 'Hello_World.MainPage' to 'Windows.UI.Xaml.UIElement'	C:\Users\bossman1086\Documents\Visual Studio 11\Projects\Hello World\Hello World\App.xaml.cs	17	38	Hello World
    
    
    Error	2	The name 'InitializeComponent' does not exist in the current context	C:\Users\bossman1086\Documents\Visual Studio 11\Projects\Hello World\Hello World\MainPage.xaml.cs	16	13	Hello World
    


    Wednesday, September 14, 2011 6:06 PM
  • @Bossman, did you get a chance to try this:

    Could you try compiling a project with msbuild.exe, i.e. %windir%\microsoft.net\framework\v4.0.30319\msbuild.exe [your project]

    If that works, could you add a second project to the solution, and try %windir%\microsoft.net\framework\v4.0.30319\msbuild.exe [your project] /m.

    If this succeeds, could you open VS right after and see if build works thereafter in VS?

    Wednesday, September 14, 2011 7:49 PM
  • @Bossman, did you get a chance to try this:

    Could you try compiling a project with msbuild.exe, i.e. %windir%\microsoft.net\framework\v4.0.30319\msbuild.exe [your project]

    If that works, could you add a second project to the solution, and try %windir%\microsoft.net\framework\v4.0.30319\msbuild.exe [your project] /m.

    If this succeeds, could you open VS right after and see if build works thereafter in VS?

    I went to try it, but I was unsure of how to handle spaces in the directory path that my project is in. When I tried it as is, it seemed to kick back thinking I was giving multiple arguments for my project.
    Wednesday, September 14, 2011 7:54 PM
  • What is the path to your project file and what did you enter into the command line?
    Wednesday, September 14, 2011 8:07 PM
  • The path is C:\Users\bossman1086\Documents\Visual Studio 11\Projects\Hello World\Hello World\Hello World.csproj

    I entered "%windir%\microsoft.net\framework\v4.0.30319\msbuild.exe  C:\Users\bossman1086\Documents\Visual Studio 11\Projects\Hello World\Hello World\Hello World.csproj"

    Obviously the spaces are causing an issue, though.

    Wednesday, September 14, 2011 9:03 PM
  • Try this:

    - start | Search | Apps | Developer Command prompt

    - msbuild "C:\Users\bossman1086\Documents\Visual Studio 11\Projects\Hello World\Hello World\Hello World.csproj"

    Wednesday, September 14, 2011 9:22 PM
  • Try this:

    - start | Search | Apps | Developer Command prompt

    - msbuild "C:\Users\bossman1086\Documents\Visual Studio 11\Projects\Hello World\Hello World\Hello World.csproj"

    I got MSBuild to run, but it says build failed - with the same errors I mentioned six posts up that I'm getting in Visual Studio itself.
    Wednesday, September 14, 2011 9:30 PM
  • Hi Bossman1086,

    could you use the command line

     msbuild "C:\Users\bossman1086\Documents\Visual Studio 11\Projects\Hello World\Hello World\Hello World.csproj" > withenvvariable.txt

     

    also get rid of the environment variable MSBUILD_EXE_PATH

     

    msbuild "C:\Users\bossman1086\Documents\Visual Studio 11\Projects\Hello World\Hello World\Hello World.csproj" > withoutenvvariable.txt

     

    Could you send the two txt files to me at mikewongnospam@microsoft.com? (get rid of the nospam)

    It seems like without the environment variable, it was pulling the microsoft.build.dll from somewhere else and with the environment variable we are seeing other reference errors possibly because it is pulling references in from another location.  With the text files, we'll see what references it is passing it in your setup during build time.

     

    thanks!

    mike

    Wednesday, September 14, 2011 10:02 PM
    Moderator
  • Could you set environment variable MSBUILDDEBUGCOMM=1, reproduce the problem, and then zip and send all %temp%\msbuild* files to richapnospam@microsoft.com (remove the nospam)?
    Wednesday, September 14, 2011 10:15 PM
  • Could you set environment variable MSBUILDDEBUGCOMM=1, reproduce the problem, and then zip and send all %temp%\msbuild* files to richapnospam@microsoft.com (remove the nospam)?
    I tried this, but there are no msbuild files in the temp folder.
    Thursday, September 15, 2011 12:12 AM
  • Okay, so I set up a brand new Hello World app in C# after removing the environment variable and it compiles now. The old one still has the same issues. The thing is, I don't really see any differences between the two. And I'm still not sure what the issue was in the first place.
    Thursday, September 15, 2011 12:21 AM
  • Interesting. So you don't see any msbuild* files under \users\[username]\AppData\Local\Temp\?
    Thursday, September 15, 2011 3:07 AM
  • Not in that directory, no.
    Thursday, September 15, 2011 5:01 AM
  • Hi,

     

    you probably already saw this in the email I sent but just wanted to share what we found to date

    So I can’t reproduce the original msbuild issue but I can reproduce the compilation errors.  It turns out there is a very subtle typo in project that doesn’t work

    In Mainpage.xaml, we have something  like

    <UserControl x:Class="HelloWorld.MainPage"

    If you change it to

    <UserControl x:Class="Hello_World.MainPage"

    Then we’ll avoid the errors

    ·         Error                                                             1       Cannot implicitly convert type 'Hello_World.MainPage' to 'Windows.UI.Xaml.UIElement'                                       C:\Users\bossman1086\Documents\Visual Studio 11\Projects\Hello World\Hello World\App.xaml.cs                                                 17      38      Hello World

    ·         Error                                                             2       The name 'InitializeComponent' does not exist in the current context                                                                  C:\Users\bossman1086\Documents\Visual Studio 11\Projects\Hello World\Hello World\MainPage.xaml.cs                                            16      13      Hello World

    If you make that change, does the BuildAbortedException CouldNotConnectoMsBuildExe error still repro?  E.g.

    ·         Error                                                               1       The build stopped unexpectedly because of an internal failure.

    ·         Microsoft.Build.Exceptions.BuildAbortedException: Build was canceled. Failed to successfully launch or connect to a child MSBuild.exe process. Verify that the MSBuild.exe "C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" launches successfully, and that it is loading the same microsoft.build.dll that the launching process loaded. If the location seems incorrect, try specifying the correct location in the BuildParameters object, or with the MSBUILD_EXE_PATH environment variable.

    Thanks!

    mike

    Wednesday, September 21, 2011 7:54 PM
    Moderator
  • Bossman1086, the error message for the typo in your project was probably not as helpful as you would've liked. If you agree, can you log the bug here:

    http://connect.microsoft.com/visualstudio

     

    Thanks!

    Monday, October 10, 2011 3:03 PM
  • Hello, I just wanted to let you know that I have hit the same issue on Windows 8 Consumer Preview and Visual Studio 11 Beta Ultimate, in a solution with a C# class library and a web application project. I just did build it using the Developer Command Prompt as suggested above and it worked thereafter in the Visual Studio. No other changes. Thanks for replying! Jan

    EDIT: However, the issue returns almost every build. Moreover, if the build from command prompt fails due to errors in the code, this workaround does not work.

    • Edited by Jan Kučera Saturday, March 3, 2012 3:45 PM
    Saturday, March 3, 2012 1:18 PM
  • I have the same problem with a C# Metro Class Library that I created using the Developer Preview.  It now will not build in the new Visual Studio 11 BETA:

    error MSB4014: The build stopped unexpectedly because of an internal failure.

    error MSB4014: Microsoft.Build.Exceptions.BuildAbortedException: Build was canceled. Failed to successfully launch or connect to a child MSBuild.exe process.

    Wednesday, March 7, 2012 3:15 PM
  • Firstly, I'm sorry that 3 of us are trying to help simultaneously. :-)

    Please make sure MSBUILD_EXE_PATH is cleared, so you get the bug back.

    Let's double check the environment variable is set correctly. Please kill any persistent msbuild.exe's and close any copies of VS.

    Then edit your system environment as follows

    Windows key, type "environment", click on Settings, click on "edit system environment", dialog appears, click on "Environment" button, click on "New" at the top, put in "MSBUILDDEBUGCOMM" without quotes as the name and "1" without quotes as the value, the OK out of all the dialogs.

    Now reopen VS and repro the problem.

    Then open a command prompt and type "cd /d %temp%" without quotes then "dir /s msbuild*" without quotes. Do you see anything? If so please zip, rename the extension, and send to msbuild@microsoft.com.

    Also, how many instances of msubild.exe do you see after the problem happens?

    Dan/dev/msbuild

    (Also, Jan, can you please try the same as well as Bossman?)
    • Edited by danmose Wednesday, March 7, 2012 8:08 PM
    Wednesday, March 7, 2012 6:47 PM
  • I had the same error. However, running as Administrator worked...

    ~Tony

    Saturday, June 2, 2012 10:37 PM
  • I have the same problem. Quit VS 2012RC and restart it solves the issue.
    • Edited by Leonard Tuesday, June 19, 2012 5:35 PM
    • Proposed as answer by anna12345 Monday, June 25, 2012 6:59 PM
    Tuesday, June 19, 2012 5:19 PM
  • Thanks Man Its Work :-)

    Monday, June 25, 2012 7:00 PM
  • Thanks, it works for me too! i had the same problem.
    Sunday, July 1, 2012 1:46 PM
  • Yes Leonard! It worked.. Microsoft - Only God Can Judge You!!

    Friday, September 21, 2012 10:09 AM
  • To build the project, pass it the .csproj. To build a whole solution, pass it the .sln.

    MSBuild is much smarter than VS when it comes to compiling .csproj files which have Project Dependencies on other projects. It will automatically build all projects the current project depends upon, whereas VS will only compile projects you have added to the current solution, forcing you to add all of your dependency projects to a solution before being able to get a successful compilation.

    Tuesday, February 12, 2013 6:46 PM