Can't compile project in Visual Studio 2012 - c++

I am trying to compile a project and I am getting a weird error
error MSB6003: The specified task executable "CL.exe" could not be run. The process cannot
access the file 'C:\Program Files\Microsoft DKs\Windows\v7.1\Samples\multimedia\directshow\
filters\myparser\UnitTest\Debug\cl.read.1.tlog' because it is being used by another
process. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets
What might cause this and how can I solve it?

I reproduce this issue when different projects in the same solution were configured with the same "Intermediate Directory".
Suggestions:
disable parallel build. In Tools->Options->Projects and Solutions->Build and Run and set the maximum number of parallel project builds to 1.
be sure the "Intermediate Directory" (Project properties->General) is unique in the solution. i.e. "$(Configuration)\$(SolutionName)\$(ProjectName)\"

This possibly means you have two builds trying to run at once, or visual studio has locked itself by trying to parallelize the builds. Close all visual studios. Kill all compilers. Try again.

here are some suggestions:
you can download "unlocker" software and use it to determined what other process is using the file
read this:
http://social.msdn.microsoft.com/Forums/vstudio/en-US/d54374ff-1d17-4056-8144-eeb13ba7add4/the-specified-task-executable-clexe-could-not-be-run
according to that post outdated antivirus definition package may cause it. perhaps the antivirus scanned the file and that was the "other process"

Related

Visual studio compiling failed without any errors [duplicate]

I have a WebApplication which contains reference to WCF services.
While building using Visual Studio 2010, Build fails without any error or warning. However building the .csproj using MsBuild is successful.
Can't figure out what should I try in Visual Studio, to resolve / diagnose the issue. Can you please help out?
I find out that the build has been failing,
From text displayed in status Bar.
From output window:
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
The output tab includes configuration details.
------ Build started: Project: <projectName here> Configuration: Debug Any CPU
I noticed that if "Build + Intellisense" is selected in the Error List, it causes the error messages to be swallowed.
Change this option to "Build Only", and all error messages will be displayed:
I don't know if this is a bug in Visual Studio or what, but it certainly revealed hidden error messages that were the key to pinpointing the failure for me.
Some, like Richard J Foster, have suggested increasing the "MSBuild project build output verbosity" setting to "Diagnostic" (the highest possible option), but this didn't solve the problem for me, as Visual Studio appeared to be suppressing the error message(s) themselves.
As an alternative, you may try to use the raw output messages from the "Output" tab, which haven't been filtered by Visual Studio. Either do an in-place search for the strings "error" and/or "failed", or copy all of the output to your favorite text editor and do a search there.
To ensure that the Output window appears each time you do a build, you can go to Tools → Options → Projects and Solutions → General, and ensure that the option "Show Output Window when build starts" is checked.
As an additional troubleshooting step, it is also possible to build the project from the PowerShell command line by running dotnet build. This will show you the complete build output, including any errors that Visual Studio may be hiding.
I just ran into a similar situation. In my case, a custom action (from the MSBuildVersioning package available on Nuget.org - http://www.nuget.org/packages/MSBuildVersioning/) which appeared in the csproj file's BeforeBuild target was failing without triggering any error message in the normal place.
I was able to determine this by setting the "MSBuild project build output verbosity" (in the latest Visual Studio's Tools tab [Path: Tools > Options > Build and Run]) to "Diagnostic" as shown below. This then showed that the custom action (in my case HgVersionFile) was what had failed.
Here are some things that you can try:
If your solution contains more than one project, try building each project one at a time. (You may even want to try opening each project independently of the solution.)
If applicable, ensure that all of your projects (including dependencies and tests) target the same version of the .NET Framework. (Thanks to user764754 for this suggestion!)
Tip: Check Tools → Extension and Updates to ensure that your packages are up-to-date.
Ensure that all dependency projects are built to target the same platform as your main project.
Try restarting Visual Studio.
As suggested by Bill Yang, try running Visual Studio as Administrator, if you aren't already. (If you are already running Visual Studio as Administrator, perhaps try the opposite?)
Try restarting your computer.
Try "Rebuild All".
Run "Clean Solution", then remove your *vspscc* and *vssscc* files, restart Visual Studio, and then "Rebuild All".
As suggested by Andy, close Visual Studio, delete the .suo file, and restart Visual Studio.
As suggested by Arun Prasad E S, close Visual Studio, delete the .vs folder in your solution directory, and then re-open Visual Studio. (This folder is auto-generated by Visual Studio and contains cache, configuration settings, and more. More details can be found in these questions: Visual Studio - Deleting .vs folder and https://stackoverflow.com/q/48897191.)
As suggested by MrMalith, close Visual Studio, delete the obj folder in your solution directory, clear your temporary folder, and then re-open Visual Studio.
Delete the hidden .vs folder & restart Visual Studio. That worked for me.
I want to expand on Sasse's answer. I had to target the correct version of .NET to resolve the problem.
One project was giving me an error:
"The type or namespace name 'SomeNamespace' does not exist in the namespace 'BeforeSomeNamespace' (are you missing an assembly reference?)".
There was no error in the Error List window but the assembly had a yellow warning sign under "References".
I then saw that the referencing project targeted 4.5.1 and the referenced project 4.6.1. Changing 4.6.1 to 4.5.1 allowed the overall build to succeed.
Nothing was working for me so I deleted the .suo file, restarted VS, cleaned the projected, and then the build would work.
I tried many things like restarting Visual Studio, cleaning and rebuilding the solution, restarting the PC, etc., but none of them worked for me. I was finally able to solve the problem by doing the following:
First of all, make sure all the projects in your solution (including tests) are targeting the same .NET version. Then:
Save pending changes in the project and close Visual Studio
Find the exact location from file explorer and find "obj" file and open it,
Then, delete all the included files (some files won't remove, it doesn't matter, just skip them).
Use run command (by pressing Windows Key + R) and type "%temp%" and press enter to find temporary files.
Finally, delete them all.
On other possibility is that Visual Studio needs to run as Administrator, this might be related to deploying to local IIS server or other deployment need.
Just for the sake of completion and maybe helping someone encountering the same error again in the future, I was using Mahapps metro interface and changed the XAML of one window, but forgot to change the partial class in the code-behind. In that case, the build failed without an error or warning, and I was able to find it out by increasing the verbosity of the output from the settings:
In my case (VS 2019 v16.11.20), disabling Text Editor->C#->Advanced->Enable 'pull' diagnostics in the options solved the issue.
Double check for _underscore.aspx pages in your project.
I had a page and code-behind:
`myPage.aspx` and `myPage.aspx.vb`
when building the project, I'd get errors on the .aspx.vb page stating that properties defined on the .aspx page didn't exist, even though the page itself would build fine and there were NO OTHER ERRORS showing in the output (even with diagnostic level build output).
I then came across a page in the project that was named the same thing but with an underscore: _myPage.aspx - not sure where it came from, I deleted it, and the solution built fine.

TRACKER : error TRK0002: Failed to execute command

I got this error while trying to build my project on a buildAgent running as a service, does anyone have a solution for it?
TRACKER : error TRK0002: Failed to execute command: ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\CL.exe" #C:\BuildAgent\temp\buildTmp\tmpfde187c5fd8a42299ab4d18e25e0c9fe.rsp". The operation identifier is not valid.
i tried a solution to a similar issue when building the project in command line (using "_IsNativeEnvironment" variable ) but it didn't work for me, also i need the solution to work on my local computer permanently.
This error will happen with multiple tools when launching MSBuild from the command line:
CL.exe
cvtres.exe
Lib.exe
link.exe
adding them to the exclusion list of the active antivirus can fix some of the issues, but will not be enough with a modern antivirus.
An alternative is to deactivate Tracker.exe which is a tool that enable incremental builds. As it's not something you generally want on a build server, I found it safe to deactivate.
You can deactivate it by passing this parameter to msbuild: /p:TrackFileAccess=false
Windows Logs\Application in Windows Event Viewer may have clues about that.
In my case, it produce an event like
Activation context generation failed for "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\CL.exe".Error in manifest or policy file "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\CL.exe.Config" on line 0. Invalid Xml syntax.
I simply remove that .config file and it works.
This happens me when the aggressive virus scanner in my org secretly detects these files as malicious and removes them in the background.
In my case, changing the rules of the virus scanner resolves this problem.
This happened to me because I was sending the wrong "/p:VisualStudioVersion" to msbuild.
I upgrated to a newer version of vs but I didn't update the command line script that was building my project.
Changing the "/p:VisualStudioVersion" to the major version of vs that was actually installed on my machine fixed the problem.
I had this troublesome error.
I deleted my local TEMP folder completely and rebooted.
C:\Users\ [USER]\AppData\Local\Temp

The file MSVCP100D.dll is missing from the computer

What I'm having is that this error is displayed when I wanted to copy a exe debug project that I have created (which works witout any problems) to another machine (the error message is displayed).
According to the question posted previously, the best solution to get rid of the error message is to make a release and not a debug in the Configuration Manager.
Doing that, and when rebuilding the project with the RELEASE one, I'm having new errors in my project which were not included when doing the DEBUG.
For instance, one of them is :
Error 2 error C1083: Cannot open include file: 'opencv\highgui.h': No such file or directory c:\...\projects\...\ex\opencv.h 4
23 IntelliSense: identifier "IplImage" is undefined c:\...\ex.cpp 80
Any feedbacks?
You've probably added include paths for OpenCV to your project file. Unfortunately, Visual Studio by default makes such changes ONLY to the active configuration, which in your case was debug.
This rarely makes sense. Adding a logging library would be such a rare case, but you probably needs OpenCV in both debug and release builds.
MSVCP100.dll is part of the Microsoft Visual Studio 10 runtime. MSVCP100d.dll is the debug build of the same dll - useful for running your program in debug mode.
http://www.microsoft.com/en-us/download/details.aspx?id=5555
Basically it is a relatively new package and is not guaranteed to be on all systems, especially Windows XP, so you can distribute the required DLL files or the entire runtime with your program. EDIT: Keep in mind that debug builds are not meant to be distributed, so your program should not contain debug dll-s either such as MSVCP100d.dll.
Try downloading it, and then see what happens.
Also check out this question.
MSVCP100D.dll and MSVCP100.dll is part of the Microsoft Visual Studio 10 runtime, so if someone compile her/his programs with this package, then uninstall the package and install another one for example Microsoft Visual Studio 12 (2013).
When trying to run her/his programs , then her/his will get the message that 'so and so... try to reinstalling the program to fix this problem'. this means you have to reinstall Microsoft Visual Studio 10.
the other way is to recompile your programs under the new package!

Unable to start VS2012 Profiler

I'm trying to start a performance profiling session in Visual Studio 2012 RTM on Windows 8 PRO 64-bit for a console program (ANALYZE / Start Performance Analysis).
I get a popup message informing me
Could not load file or assembly 'Microsoft.VisualStudio.PerformanceTools.CounterInfo.dll' or one of its dependencies. The Specified module could not be found.
Apparently this can happen under VS2010 after KB2645410 is installed. I carefully followed the procedure given for this issue with the same error message:
Visual Studio 2010 SP1, KB2645410 and Add-Ins
However, that does not resolve the issue.
I have tried running VS2012 as Administrator as well.
How can I get the profiler working?
UPDATE
I can actually attach to a running instance of the project from the command line using the steps here:
Walkthrough: Command-Line Profiling Using Sampling
However, Visual Studio does not open the resulting .vspx file (it just does nothing after I open it with File / Open File).
UPDATE 2
Fuslogvw reports two binding errors when I attempt to start the profiler:
VS 2012 Profiler Binding Errors - Pastebin
Adding the following to the system path resolved the issue for me permanently.
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Performance Tools
Some other answers may be appropriate to other situations.
Note that you probably will need to run Visual Studio as Administrator for profiling to work correctly.
I also struggled with that issue.
I found a working solution for me:
I opende the XXX.sln file using notepad.
There i found several parts in the Project and Global Section looking something like this:
ProjectSection(SolutionItems) = preProject
Performance1.psess = Performance1.psess
EndProjectSection
I removed all of them and that made my Analyzer work again.
I delete the .suo file and everythings works correctly now.
The same question exists here:
http://social.msdn.microsoft.com/Forums/en-US/a6487155-980c-4bc8-82de-2fe588fdf37f/windows-update-kb2645410-and-performance-tools-error
The following are suggested workarounds:
Remove windows update KB2645410
Only run one instance of Visual Studio
If you are the administrator on your development PC you can add the permission to Everyone to read and execute all the content in the folder "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Performance Tools" and subfolders/files.
"I backed everything up and did a complete repair of Visual Studio using the original disk from Microsoft. That allowed the computer to shut down normally. Then I tried the patch again. It hung again, but after a few reboots we got a message about deleting corrupt files and finally everything seems OK."
My issue was resolved when I realized that my user access control was set too high. Once that was turned off, I rebooted and it all worked great.
Once I uninstalled re-sharper my issue was resolved.

Why is msbuild and link.exe "hanging" during a build?

We have a few C++ solutions and we run some build scripts using batch files that call msbuild.exe for each of the configurations in the solutions.
This had been working fine on 3 developer machines and one build machine, but then one of the projects started to hang when linking. This only happens on the newest machine which is a quad core, 2.8ghz I think. It runs on Windows Server 2003 and the others are on XP or Vista.
This happens consistently even if I change the order of builds in the bat file.
If I run the build from the IDE on that machine it does not hang.
Any ideas about what could possibly be causing this?
I am using Visual Studio 2008.
Edit:
I see now that when it is hung the following are running:
link.exe (2 instances) One with large memory usage and one with a small amount of memory usage.
vcbuild.exe
msbuild.exe
vcbuildhelper.exe
mspdbsrv.exe
Edit:
The exe file exists and so does the pdb file.
The exe file is locked by some process, and I can't delete it or move it. I can delete the pdb file though.
I also have the problem if I just use VCBuild.exe.
I decided to try debugging the 2 link.exe processes and the mspdbsrv.exe processes.
When I attached the debugger/MSdev IDE to them I got a message box saying that the application was deadlocked and/or that "all threads have exited".
I guess I will have to check for a service pack for that msdev install on that machine.
Edit:
In the debug.htm output file I get all sorts of stuff output after the link.exe command is generated.
However, for the release buildlog.htm the linke.exe line is the last line.
This is clearly a hang in the linker. Definitely a Microsoft bug.
I am now trying to figure out what the .rsp (linker response) file is.
When I issue:
link.exe #c:\\Release\RSP00000535202392.rsp /NOLOGO /ERRORREPORT:QUEUE
That is the last line in the release build log. The debug one has lots more information after that.
Reinstalling a different version of Visual Studio did not solve the problem.
I will open an issue/ticket with Microsoft. I will post an answer if I can.
Whole-program optimization (/GL and /LTCG) and /MP don't mix -- the linker hangs. I raised this on Connect.
The upshot is that it's a confirmed bug in VS2008; contact PSS if you want a hotfix; and the fix is included in VS2010.
If you can't wait that long, turn off /MP (slower compiles) or /LTCG (slower code).
Are you using xcopy in your scripts? This suggests wrapping xcopy with cmd /c " .. " as a solution.
If that wasn't it, I'd recommend to narrow things down by only letting one cpu work (i.e. removing /maxcpucount) This would rule out any form of race condition between compilation processes.
I had a similar problem, but with Visual Studio 2010.
This is a project that had worked fine on another computer, but just not my new one.
The symptoms described matched the original Visual Studio 2008 Issue.
I was able to resolve the issue by installing the Visual Studio 2010 Service Pack 1 (SP1)
http://www.microsoft.com/download/en/confirmation.aspx?id=23691
- or just go to microsoft and search for "Visual Studio 2010 Service Pack 1"
I had run my windows "check for updates" and had thought I had installed all service packs, but apparently, I had not installed any Visual Studio Service Packs.
After installing the VS2010 SP1, I no longer had this issue.
I confirmed that I had installed VS2010 and the Service Pack 1 on other older computer with the working project a while back.
You could try this: Open the build dialog via
Menu -> Tools -> Options -> Projects and Solutions -> Build and Run
Here you can set "MSBuild project build output verbosity" to
"Diagnostic". Maybe this will deliver more information on what is
going wrong.
In the same dialog you can set "Maximum number of parallel project
builds" to 1. Maybe this works around the link.exe "hang".
mspdbsrv.exe is used to combine all debug info into one pdb file. The VS2005 version of mspdbsrv.exe is buggy, it might be that the VS2005 version has some of the same issues. Killing it before building is making a difference for some people. We're going to add it to our builds as well since we're regularly suffering from unknown PDB errors.
Have you tried disabling incremental linking, or alternatively, always forcing a Rebuild All?