Note: Forums will be making significant UX changes to address key usability improvements surrounding search, discoverability and navigation. To learn more about these changes please visit the announcement which can be found HERE.

Answered Can't Compile Hello World Metro Application

  • miércoles, 14 de septiembre de 2011 8:19
     
      Tiene código

    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!

Todas las respuestas

  • miércoles, 14 de septiembre de 2011 12:59
    Moderador
     
     

    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)
  • miércoles, 14 de septiembre de 2011 16:23
     
     

    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.

  • miércoles, 14 de septiembre de 2011 16:44
     
     

    @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?

  • miércoles, 14 de septiembre de 2011 17:25
     
     
    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?
  • miércoles, 14 de septiembre de 2011 17:38
     
     
    The .csproj.
  • miércoles, 14 de septiembre de 2011 17:50
    Moderador
     
     

    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

     

  • miércoles, 14 de septiembre de 2011 18:06
     
      Tiene código

    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
    


  • miércoles, 14 de septiembre de 2011 19:49
     
     

    @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?

  • miércoles, 14 de septiembre de 2011 19:54
     
     

    @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.
  • miércoles, 14 de septiembre de 2011 20:07
     
     
    What is the path to your project file and what did you enter into the command line?
  • miércoles, 14 de septiembre de 2011 21:03
     
     

    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.

  • miércoles, 14 de septiembre de 2011 21:22
     
     

    Try this:

    - start | Search | Apps | Developer Command prompt

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

  • miércoles, 14 de septiembre de 2011 21:30
     
     

    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.
  • miércoles, 14 de septiembre de 2011 22:02
    Moderador
     
     

    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

  • miércoles, 14 de septiembre de 2011 22:15
     
     
    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)?
  • jueves, 15 de septiembre de 2011 0:12
     
     
    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.
  • jueves, 15 de septiembre de 2011 0:21
     
     
    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.
  • jueves, 15 de septiembre de 2011 3:07
     
     
    Interesting. So you don't see any msbuild* files under \users\[username]\AppData\Local\Temp\?
  • jueves, 15 de septiembre de 2011 5:01
     
     
    Not in that directory, no.
  • miércoles, 21 de septiembre de 2011 19:54
    Moderador
     
     Respondida

    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

  • lunes, 10 de octubre de 2011 15:03
    Moderador
     
     

    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!

  • sábado, 03 de marzo de 2012 13:18
     
     

    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.

    • Editado Jan Kučera sábado, 03 de marzo de 2012 15:45
    •  
  • miércoles, 07 de marzo de 2012 15:15
     
     

    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.

  • miércoles, 07 de marzo de 2012 18:47
     
     

    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?)
    • Editado danmose miércoles, 07 de marzo de 2012 20:08
    •  
  • sábado, 02 de junio de 2012 22:37
     
     
    I had the same error. However, running as Administrator worked...

    ~Tony

  • martes, 19 de junio de 2012 17:19
     
     Respuesta propuesta
    I have the same problem. Quit VS 2012RC and restart it solves the issue.
    • Editado Leonard martes, 19 de junio de 2012 17:35
    • Propuesto como respuesta anna12345 lunes, 25 de junio de 2012 18:59
    •  
  • lunes, 25 de junio de 2012 19:00
     
     

    Thanks Man Its Work :-)

  • domingo, 01 de julio de 2012 13:46
     
     
    Thanks, it works for me too! i had the same problem.
  • viernes, 21 de septiembre de 2012 10:09
     
     

    Yes Leonard! It worked.. Microsoft - Only God Can Judge You!!

  • martes, 12 de febrero de 2013 18:46
     
     

    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.