Error while compiling a C++ project with devenv using Coverity. (cov-build.exe) - msbuild

When running a Coverity build I get the following error:
Failed to locate msbuild.exe when handling devenv template configuration. Shutting down resident msbuild processes is impossible.
Can't find it in Google!
Does anyone know what this might mean?
How do I investigate this?
When I build from command line without Coverity it works fine.

When you start cov-build devenv one of the things it tries to do is kill off idle msbuild.exe processes because if they are not killed, devenv will pass the build directive to msbuild without cov-build being able to see it (and that's how it knows how to build your files).
There are a few ways you can resolve this - it depends on how you are invoking cov-build, how your compiler configuration is set up, etc. For example, you could call cov-build msbuild directly rather than going through devenv.
I would recommend opening a support case with Coverity (since you have support if you have a license for it). E-mail them at support#coverity.com and I'm sure they can suggest additional debugging steps.

Related

Is it possible to tell MSBuild in TeamCity to use multiple cores

Apparently the default number of cores MSBuild will use during compilation is 1.
In TeamCity I have tried adding /m:8 to the Command line parameters field in an MSBuild Runner type task to tell the MSBuild compiler to use up to 8 cores to compile the projects within the solution.
(I realise the amount it can do in parallel depends on the dependencies between the projects in the solution.)
However when I look in the build logs I don't see any mention of that parameter?
Is this the right way to do this? Does anyone know if TeamCity supports this?
Note: This is on TeamCity 8.1.5 (build 30240)
If you have access to the build agent, when the build is in progress, you could login and start task manager, to see if there are multiple msbuild.exe (s).
I don't think that the build logs will have any info about this. What kind of info are you looking for?

MSBuild fails due to error APPX0002: Task 'GenerateAppxPackageRecipe' failed. Value cannot be null

I'm attempting to do a command line package deploy for our Windows Store Application.
My command line instructions are:
msbuild /m /p:Configuration=Debug /p:Platform=x86 /target:Build
I'm using VS2013 Professional with Windows 8.1
I get the following error:
C:\Program Files
(x86)\MSBuild\Microsoft\VisualStudio\v12.0\AppxPackage\Microsoft.AppXPackage.Targets(1224,9):
error APPX0002: Task 'GenerateAppxPackageRecipe' failed. Value cannot
be null.\r [C:\Path\Project.csproj]
C:\Program Files
(x86)\MSBuild\Microsoft\VisualStudio\v12.0\AppxPackage\Microsoft.AppXPackage.Targets(1224,9):
error APPX0002: Parameter name: source\r [C:\Path\Project.csproj]
How should I resolve this?
This error was resolved by using the correct version of msbuild.exe
On a clean build server with VS2013 installed, there are (at least) two copies of msbuild.exe installed. In our case the install locations were:
C:\Program Files (x86)\MSBuild\12.0\Bin\msbuild.exe
and
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
The one in the .Net Framework folder was the one that gave us the errors. Using the version installed in the Program Files folder resolved the issue.
It's impossible to help you without having the code which can reproduce the error. I suspect some property does not resolve correctly when building outside VS(eg VisualStudioVersion) and needs to be passed from command line. VS also uses msbuild to build your projects, so comparing build logs from VS and CMD should help you track down the problem.
I suggest, that you set visual studio's build output verbosity to diagnostic, clean solution, than build and capture the build log.
Then clean solution and build from command line with verbosity set to diagnostic and /fl switch(log to file, because diagnostic build log is way too long to analyse in console window).
Compare command-line output to VS output. Look for the differences. With diagnostic level of verbosity, chances are, you'll find out what's missing (I had similar issues with database projects failing to build from cmd due to VisualStudioVersion variable not being resolved correctly, so I passed it from command line).
NB: diagnostic log is very verbose which makes analysis hard: I'd start from detailed verbosity level.
I have deleted all files/folders from "project"/bin folder, cleaned the solution and rebuild with success !
For those facing the issue on hybrid app (corodova in my case), delete the build folder manually and re-build from VS.
Standard clean solution didn't do the job.

Installshield Build Automation

I have seen many solutions for automating my InstallShield build, but I am having issues with each one. I am using InstallShield Professional 2013. Sorry for the lengthy question, but I am clueless on which direction to go to solve my issues.
1) IsCmdBld.exe - I have a script that runs and will build my installer. BUT, when the installer runs, I get an error message that says "The System Administrator has set policies to prevent this installation". I am not sure why this is happening, but I do not get the same error message if I build the installer through the designer. EDIT: Here is my command (%guid% is a Guid I generate to set the Product Code):
for /f %%i in ('"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\uuidgen.exe"') do set guid=%%i
"C:\Program Files (x86)\InstallShield\2013 SP1 SAB\System\ISCmdBld.exe" -p "MyInstaller.ism" -r SingleImage -y "1.0.0.13" -z ProductCode=%guid%
2) InstallShield Automation Interface - I have followed numerous examples and tutorials on this, but all end in the same result. When I call the following code:
var project = new ISWiAuto20.ISWiProject();
I get this error:
Unable to cast COM object of type 'System.__ComObject' to interface type
'ISWiAuto20.ISWiProject'. This operation failed because the QueryInterface call
on the COM component for the interface with IID '{872D23A7-C18D-468C-895D-1CF027E4FBB1}'
failed due to the following error: Library not registered.
(Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).
3) MsBuild.exe - Running MsBuild on my InstallShield project file yields this error:
error NSB4025: The project file could not be loaded. Invalid character in the
given encoding. Line 1, position 1
The choice between these approaches (when they all work) largely depends on the build system you are trying to integrate with. If you're using a batch or makefile approach, IsCmdBld.exe is probably the easiest starting point. If you're using Visual Studio and TFS or MSBuild, you'll probably have more luck there, as it will report errors in a way the build system can understand. (Other than that, they're fundamentally similar.) If you need to make tweaks to the project before you build it, the automation layer can either augment or replace the other approaches.
But in your case you say they all don't work. What have you done to diagnose why? Here are the first steps I'd take for each of those symptoms:
IsCmdBuild built setups yielding an error that the IDE-build ones do not. First identify what the problem really is. Look in a verbose log for more information. Build both ways with the .msi available and compare the results with MsiDiff. Make sure you've tested elevated. Depending on what you find, it may be something to address in the project, the build process, or a bug in InstallShield.
Automation Interface yields TYPE_E_LIBNOTREGISTERED. First off, if this is the IDE machine, consider repairing the installation. If it's a standalone-build machine, ditto. If it's a standalone-build machine that didn't use the installation, you should, or at least you should ensure the dependencies are present and that the automation interface is registered. Secondly, as Christopher Painter noted, InstallShield is a 32-bit product so it must be invoked from a 32-bit context. If you're calling, say, CScript to run a .vbs file, make sure you're using C:\Windows\SysWow64\CScript.exe.
MSBuild NSB4025. The comment from stijn is largely correct - you can't call MSBuild on the .ism file (while it can be xml instead of binary, it's not MSBuild-compatible). However you can create a .isproj file that can work correctly. Save the project in Visual Studio, or copy <InstallShield>\Support\0409\MSBuild.xml to (ProjectName).isproj and tweak its contents; call MSBuild on the resulting .isproj file. Odds are strong this will have approximately the same results as IsCmdBuild, as the build portion is largely shared.
Using MSBuild doesn't follow the exact order of the Project files specified in the solution .sln file.
The best option is to use devenv.exe
And sometimes, devenv doesn't return exact return status, so I kept an exe to scan the log file for the success code.
https://devopsdiaryblog.wordpress.com/2017/12/20/devenv-return-code-issue/
And for iscmdbuild.exe, better to use commandline as it is the suggested one from flexera.

Why does TFS2012 report build as successful if Code Contracts rewriter did not run?

I build my solution but CC tools are not installed on build server.
So no rewrite was done.
Now I'm curios why msbuild reports build as successfull if not all tasks were finished?
P.S. I'm completely unexperienced in msbuild so if my question sounds stupid I beg you pardon, guys.
Update
Well, I installed locally Code Contracts extension which created additional tab for project options.Then I enabled code contracts checking at run time and added at the very begining of the Main method the following line:
// test for Code Contracts rewrite
// exception is thrown if no rewrite
Contract.Requires<Exception>(true);
I commited changes to TFS and started the build and it completed succesfully without any warnings. No rewrite was done and my application throws exception.
I've read about Microsoft.CodeContracts.targets file ad found it in CC installation dir but I see no refernces to it inside project file. Only elements like <CodeContractsAssemblyMode>1</CodeContractsAssemblyMode>.
I don't understand where msbuild gets the knowledge about CC and how to apply them.
Update 2
Eventually we installed Code Contracts on Build Server and assembly instrumentation is performed.
Yet it's still not clear what settings are changed during CC installation.
You need to install the tools on the build server as well. The design of the contract tools are such that unless you use Contract.Requires< Exception >(...) one can build and release bits without the use of our tools. If you use Contract.Requires< Exception >(...) however, then you must use the rewriter as the documentation states. Thus, in order for your project to be successfully built, you need to install the tools.
MsBuild and VS and C# know nothing of the contract tools and thus cannot warn you about this lack of tool installation.
Hope this helps.

Setting build configuration to staging

Simple question. How do I set the build configuration to something other than Debug?
Setting /P:Configuration=Staging in the Command line parameters box, leads to this error:
TeamCity says to use "Build Parameters" instead of "/property:" in an MSBuild step. What does that mean?
So how is it done? I need to build MSDeploy packages for all configurations, I can get the packages to build but everything is Debug.
The way you're doing it is fine -- although perhaps use a lowercase /p:. Our team does it this way too. TeamCity isn't throwing an error, it's just trying to provide some helpful information.
JetBrains provides some documentation for its preferred method at the bottom of the page under Using System Properties in Build Scripts.