Choco: external program failed (msbuild.exe)

Created on 21 Apr 2016  路  26Comments  路  Source: chocolatey/choco

I fetched latest choco, ran build.bat and got a build failure. See the log below.
My machine installed .net 4.5.1
Anyone can help?
Thanks in advance.

= = = = = = = = = = = = = = = = = = = =
[echo] Setting compile variables
[echo] Finding and restoring all packages (C:\chocolatey.0.9.9.12\choco\lib\NuGet\NuGet.exe restore 'C:\chocolatey.0.9.9.12\choco\src\chocolatey.sln')
[exec] Unable to find version '1.1.86' of package 'coveralls.io'.
[exec] C:\chocolatey.0.9.9.12\choco.build\compile.step(66,6):
[exec] External Program Failed: C:\chocolatey.0.9.9.12\choco\lib\NuGet\NuGet.exe (return code was 1)
[echo] Compiling C:\chocolatey.0.9.9.12\choco\src\chocolatey.sln.
[echo] Building on 4.0

    C:\chocolatey.0.9.9.12\choco\.build\compile.step(173,14):
    Failed to start MSBuild.
        C:\chocolatey.0.9.9.12\choco\.build\compile.step(173,14):
        External Program Failed: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe (return code was 1)
Invalid / Not Issue / No repro / Not Implementing

Most helpful comment

I was able to reproduce this error on my machine, as well as a friend's laptop, with coveralls.io and NUnit not being able to be restored.

The fix was to replace /lib/NuGet/NuGet.exe with the latest release of NuGet from Microsoft. After this, the NuGet packages restored correctly and the build.bat completed successfully.

As for why, I'm not sure - I haven't looked into it; just thought I'd post just in case anybody else comes along with the same issue (or for other people to look into).

All 26 comments

Go to the build_output folder and find the build logs there. You will get a more complete picture of what happened.

OK, I installed a missing package. now I get different errors.
src\chocolatey\chocolatey.csproj can't find the assembly exists on disk.
log4net,
Microsoft.Web.XmlTrasform,
SimpleInjector,
System.Reactive.Core,
System.Reactive.Interfaces,
System.Reactive.Linq

Where can those assemblies be found?

@hjungG those all sound like NuGet packages, which would be restored as part of the NuGet Package restore process.

Build.bat should work first time. Once you figure out what it is you are missing, I'd love to know so we can correct it or document it.

src\chocolatey\chocolatey.csproj has some references to ..\packages\
Probably I set NugetMachineInstallRoot to another location
I think we need to set local nuget package folder to src\packages\ in the build.bat

How you guys normally set those environment variables?

@hjungG the build should set that.

Call this build.bat -v

Then take a look at

  • build_output\build.log
  • build_output\build_artifacts\compile\msbuild-net-4.0-results.xml

If you could gist up these two files for me and paste that link here, that would be great!

https://gist.github.com/hjungG/a99018e25dde0ce995d10603a6377fad

I wiped out my repo and start over with build.bat -v

https://gist.github.com/hjungG/a99018e25dde0ce995d10603a6377fad#file-build-log-L224-L226

    restore_packages:

                 [echo] Finding and restoring all packages (C:\rdnext\OSS\chocolatey_latest\choco\lib\NuGet\NuGet.exe restore 'C:\rdnext\OSS\chocolatey_latest\choco\src\chocolatey.sln')
                 [exec] All packages listed in packages.config are already installed.
                 [exec] All packages listed in packages.config are already installed.

Where are these packages found on your system?

I found those packages in my local cache folder c:\cxche

Where are you running build from?

You need to cd to C:\rdnext\OSS\chocolatey_latest\choco and then run build.bat.

yes I ran from C:\rdnext\OSS\chocolatey_latest\choco folder

do you expect those packages are installed in src\packages?

Yes, why is it not on your system? Perhaps you can explain in a little more detail...

My machine already set the environment variable NugetMachineInstallRoot=C:\CxCache, so visual studio install nuget pkgs to that place

@hjungG ah, now it's starting to make sense. Clearly that is not going to work.

may i just set NugetMachineInstallRoot=src\packages before run build.bat?

I think we can add the following to the build.bat

@echo off

::Project UppercuT - http://uppercut.googlecode.com
::No edits to this file are required - http://uppercut.pbwiki.com

if '%1' == '/?' goto usage
if '%1' == '-?' goto usage
if '%1' == '?' goto usage
if '%1' == '/help' goto usage

SETLOCAL

SET NugetMachineInstallRoot=

SET DIR=%cd%
SET BUILD_DIR=%~d0%~p0%
SET NANT="%BUILD_DIR%lib\Nant\nant.exe"
SET build.config.settings="%DIR%\.uppercut"

%NANT% /logger:"NAnt.Core.DefaultLogger" /quiet /nologo /f:"%BUILD_DIR%.build\default.build" -D:build.config.settings=%build.config.settings% %*

if %ERRORLEVEL% NEQ 0 goto errors

call %DIR%\documentscenarios.bat

goto finish

:usage
echo.
echo Usage: build.bat
echo.
goto finish

:errors
ENDLOCAL
EXIT /B %ERRORLEVEL%

:finish

ENDLOCAL

Do you want to give that a shot and then we can make the change if it works?

I updated the script with what the full thing should look like.

i tried that but still have same result.. not found the references

I re-create choco repo in new location out of my other repos.
set NugetMachineInstallRoot="" and ran build.bat

https://gist.github.com/hjungG/3efa6fbcc4a444a4c1e70da81ff245de

I'll just throw this out there, you understand this is something local to your environment right?

We build this on Travis (non-Windows), on AppVeyor, and on TeamCity. It's passing currently https://github.com/chocolatey/choco#build-status

Once you've figured out what it is, I'm curious to know what you've determined, and whether it is something we need to change to make things smoother.

I told you wrong!

SET NugetMachineInstallRoot= without the quotes. Let me know if that works. http://ss64.com/nt/set.html

That resolved the issue.

But strange thing was the variable without the quotes or opening new cmd windows did not take affect right away. After I rebooted my pc, the problem went away for some reason.

Anyway, thanks for the help

Hmmm - strange. Not really reproducable at this time

I was able to reproduce this error on my machine, as well as a friend's laptop, with coveralls.io and NUnit not being able to be restored.

The fix was to replace /lib/NuGet/NuGet.exe with the latest release of NuGet from Microsoft. After this, the NuGet packages restored correctly and the build.bat completed successfully.

As for why, I'm not sure - I haven't looked into it; just thought I'd post just in case anybody else comes along with the same issue (or for other people to look into).

I get this with VS2017 and latest nuget

Was this page helpful?
0 / 5 - 0 ratings