Visual Studio 2012 Command Line Building - Detecting Build Failures - visual-studio-2012

I'm setting up a build server for a Visual Studio 2012 project and I'm trying to add detection for failed builds so the server can properly recover after a build failure and notify users of the failure and the error message.
I'm using devenv.exe with the "/Build" and "/Out" switches, however for building, the "/Out" switch captures all build output and stores in the specified file, and I only want it to capture build errors.
Does anyone have any suggestions on how I can only have build errors written to the file, or better ways of detecting a build failure?
Thank you in advance!

If you just need a pass/fail, you could use ERRORLEVEL in a batch/cmd script. It's primitive, but would probably work for most cases. Something like this:
#devenv Solution.sln /Build
#if ERRORLEVEL 1 echo Build Failed
You could also use MSBuild, which has options for console output (i.e. /clp:ErrorsOnly) as well as file output. Something like this:
msbuild /p:Configuration=Debug /t:Rebuild /clp:ErrorsOnly Solution.sln

Related

Opening the code generated from CMake

I am trying to build Assimp to use in visual studio 2012.
Following the instructions on their website: http://assimp.sourceforge.net/lib_html/cmake_build.htm I have tried to build assimp, however I am stuck on the last step "Open the generated solution/project files and have fun"
This is the build folder which was created by CMake - http://puu.sh/fq8kp/cc16e985c3.png
Following the advice of another tutorial I opened this in the terminal and tried to type "make" and launch it. However there isnt a make file so this didnt work. I also typed "install" as there is an install file, however this also did not work.
The tutorial goes as follows:
Type "make" and launch it; you should see the build progressing without issues
When the build is finished, type "sudo make install"; it will ask for your password and install the library!
Any help would be much appreciated!
the 'generated solution/project' in your case (windows) would be the Assimp.sln file. You generated a visual studio solution, so you have to use Visual Studio to build the application.
According to your screenshot, the Assimp.sln file is the 9 KB sized file underneath the one with size 45,120 KB

Visual Studio Post Build Run Exe not running

I have a exe that creates/alters a file in the same directory as the exe. I can run this manually and it works. But i cannot get it to run as part of a post build event in visual studio.
Below is what is in the Post Build event box:
"$(ProjectDir)\WebSiteVersion\Versioner.exe"
I dont get any errors or exceptions but the file is never created in the directory.
Can anyone help?
Verify that the copy/create you are issuing through the exe has absolute path rather than relative for starters. Also check if the exe actually runs as a post build event by either seeing the logs or procmon.
Verific the path of your exe
in my project i added notepad.exe i it still work
maybe you are forgeting something in post-build event
well here my commands
copy "$(TargetDir)XXXXXX.exe" "$(SolutionDir)Deploy\"
notepad.exe
exit 0

MSB4019 from VS2012 solution when building on Jenkins

I'm setting up our build server. I've installed Jenkins on a Windows 7 machine and am running into problems when building the 64 bit version of our solution.
We're using Visual Studio 2012 Express for Windows Desktop. Jenkins uses the MSBuild plugin and is targeting the 64 bit MSbuild exe at
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe
However, when it runs msbuild an evironment variable is not being parsed properly. VCTargetsPath.
If I leave everything as-is then the output of MSBuild is this
error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
I played around a bit with the VCTargetsPath variables in the registry, Windwos Environment Variables and as Jenkins Eviornment Variables too. I noticed this behavior.
If I set VCTargetsPath to be "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110" then the output of msbuild is the same as above. However, if I set it to "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0" then the output changes to this.
error MSB4019: The imported project "C:\progra~2\MSBuild\Microsoft.Cpp\v4.0\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
The tile Microsoft.Cpp.Default.props is found in "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110" I checked the limits on environment variable length and it's supposed to be 2048 characters. Am I missing something obvious here? I've found some info that basically says I am going to have to reinstall everything in a specific order, which is quite annoying (but also very Microsofty).
I fixed this by adding
/p:VCTargetsPath="C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V120"
or the more elegant
/p:VisualStudioVersion=12.0
into
Build > Build a Visual Studio project or solution using MSBuild > Command Line Arguments
Your first round of fix-it attempts for a build server.
Install the appropriate SDK on the build machine.
http://www.microsoft.com/en-us/download/details.aspx?id=8279
If that doesn't work, report back.
EDIT:
/p:VisualStudioVersion=11.0
Add that to your command line...as a parameter for msbuild.exe
EDIT:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe
I have a 64 bit version of msbuild.exe there.
Which isn't what you show.
I'm throwing a guess out, nothing concrete, FYI.
Try passing : /p:PlatformTarget=x86 as one of the arguments to MSBuild.

Coverity Set Up (Cygwin Warning)?

I am currently trying to run Coverity Prevent and I believe I have everything set up appropriately on my windows 7 build machine. I have run it with AnthillPro and when my code finishes and gets to Coverity it says that everything was built fine and the only error I get is:
Warning: Cygwin pathname conversion ignored; no applicable
'bash'/'mount', 'cygpath', or registry keys found.
I have even tried to install Cygwin to see if this could rectify the problem and I still end up with the same error.
I am currently using AnthillPro 3.7 and Coverity 5.5.3. The build log says that I have warnings but no errors and that it hasn't emitted anything. I have tried to run a script directly from the machine (not server) itself and I have the same error as I do using the Coverity Prevent in Anthill
This is the only information I get at the bottom of the build log.
Run from AnthillPro:
Build time (cov-build overall): 00:00:17.753597
[WARNING] No files were emitted. This may be due to a problem with your configuration
or because no files were actually compiled by your build command.
Please make sure you have configured the compilers actually used in the compilation.
For more details, please look at:
d:\Coverity\Intermediate\AllToolsProjects.sln_pc_vs2010\build-log.txt
Run from Script:
The cov-build FAILED.
This may be because less than 90 percent of units were successfully compiled
Check for errors here:
D:\\Coverity\Scripts\build_AllToolsProjects.sln_pc_vs2010.bat
D:\\Coverity\Intermediate\AllToolsProjects.sln_pc_vs2010\build-log.txt
D:\\Coverity\Configuration\pc_vs2010
It sounds like you haven't configured the compiler - that's when you tell your Coverity Analysis installation which compiler you are using. devenv is not a compiler, cl.exe is.
Run the following command:
coverity-analysis-dir/bin/cov-configure --msvc
This will say that you are using the cl.exe compiler and it's of type msvc no matter where it's installed.
Then rerun your Coverity build and see if it captures more of your compilations.

fatal error C1083: Cannot open include file: 'Windows.h': and scons

Today is officially my first day with C++ :P
I've downloaded Visual C++ 2005 Express Edition and Microsoft Platform SDK for Windows Server 2003 SP1, because I want to get my hands on the open source Enso Project.
So, after installing scons I went to the console and tried to compile it using scons, but I got this error:
C:\oreyes\apps\enso\enso-read-only\src\platform\win32\Include\WinSdk.h(64) : fatal error C1083: Cannot open include file: 'Windows.h': No such file or directory
scons: *** [src\platform\win32\InputManager\AsyncEventProcessorRegistry.obj] Error 2
scons: building terminated because of errors.
After checking these links:
VS ans PSDK
Include tiffi.h
Wndows.h
I've managed to configure my installation like this:
And even run this script
And I managed to compile the file below in the IDE.
// Test.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <Windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
But I still get that exception in the console. Does anyone have scons experience?
EDIT
Actually (and I forgot to tell you this) I started the command prompt with the link "Visual Studio 2005 Command Prompt".
I assume this will include the paths in environment variables. Well after printing them I find that it didn't:
echo %INCLUDE%
echo %LIB%
echo %PATH%
And they were not present, so I created this .bat file:
set PATH=%PATH%;"C:\Program Files\Microsoft Platform SDK\Bin"
set INCLUDE=%INCLUDE%;"C:\ Program Files\Microsoft Platform SDK\Include"
set LIB=%LIB%;"C:\ Program Files\Microsoft Platform SDK\Lib"
Still, scons seeems not to take the vars... :(
Using the above recommendations will not work with scons: scons does not import the user environment (PATH and other variables). The fundamental problem is that scons does not handle recent versions of SDKs/VS .
I am an occasional contributor to scons, and am working on this feature ATM. Hopefully, it will be included soon in scons, but the feature is much harder to implement reliably than I first expected, partly because every sdk/compiler combination is different (and sometimes even MS does not get it right, some of their .bat files are broken), so I can't give you a date. I hope it will be included in 1.2 (to be released in approximatively one month).
You need to set the include file path (and possibly other things). At the command line this is typically done using a batch file that Visual Studio installs called vsvars32.bat (or vcvars32.bat for compatibility with VC6).
I'm not familiar with scons so I don't know the best way to get these settings configured for that tool, but for standard makefiles there's usually a line in the makefile which sets a macro variable with the include directory path and that macro is used as part of a command line parameter in the command that invokes the compiler.
Another possibility might be to have the scons process invoke vsvars32.bat or run the scons script from a command line that has been configured with the batch file.
In short you need to get the things that vsvars32.bat configures into the scons configuration somehow.
There will be a batch file similar to this one (for MSVC 2005) that sets up the environment variables:
c:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat
Step 1: Find a similar file in the Express installation folders
Step 2: Create a shortcut on the desktop with these target details and a suitably modified path:
cmd.exe /K "c:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat"
Step 3: Open the DOS prompt via this shortcut
The command line build should now work from within this console window.
You show us how you configured Visual Studio for compilations within Visual Studio but you didn't show us what command line environment you tried. Sorry I haven't tried Express versions so I don't know if they create additional Start menu shortcuts like Pro and above do. If you open a suitable command prompt with its environment variables already set then you can compile on the command line. Otherwise you have to set variables yourself or execute a batch script to set them, each time you open a command prompt.
It'll be nice when scons does this automatically. For now, I use this (run from an SDK command prompt, not sure if there is a difference if run after vsvars32.bat):
import os
env = Environment(ENV={'PATH': os.environ['PATH']})
env['ENV']['TMP'] = os.environ['TMP']
env.AppendUnique(CPPPATH=os.environ['INCLUDE'].split(';'))
env.AppendUnique(LIBPATH=os.environ['LIB'].split(';'))
This works for me while compiling wxwidgets with Visual C++ 2005 Express using the command line prompt:
REM Fix Error error C1083 'windows.h'
(Use /useenv option when compiling.)
set PDSKWIN=C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2
(Change to the right one.)
set INCLUDE=%PDSKWIN%\Include;%INCLUDE%
set LIB=%PDSKWIN%\Lib;%LIB%
Then I use this line when compiling. I believe just add /useenv to your lines and everything should work fine:
vcbuild /useenv /nohtmllog /nologo name.proj (or any file to compile)

Resources