Rebuild fails where Clean/Build succeeds in Visual Studio 2010 - visual-studio-2010

I've created two projects in a solution, a static library called vm and a console application called vmx. I use the new approach of Framework and References to create the dependency of vm for vmx. I also added x64 platforms to both projects.
Now, when I select Rebuild Solution, I get this output:
1>------ Rebuild All started: Project: vm, Configuration: Debug Win32 ------
1> vm.c
1> vm.vcxproj -> D:\Shared\Dynos\Build\Visual Studio 2010\Solutions\..\..\..\Lib\Win32\Debug\vm.lib
2>------ Rebuild All started: Project: vmx, Configuration: Debug Win32 ------
2> main.c
2>LINK : fatal error LNK1104: cannot open file 'D:\Shared\Dynos\Lib\Win32\Debug\vm.lib'
========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========
It as if vm.lib is deleted after being built before vmx is compiled.
If I select Clean Solution, then Build Solution, I get this output:
1>------ Build started: Project: vm, Configuration: Debug Win32 ------
1> vm.c
1> vm.vcxproj -> D:\Shared\Dynos\Build\Visual Studio 2010\Solutions\..\..\..\Lib\Win32\Debug\vm.lib
2>------ Build started: Project: vmx, Configuration: Debug Win32 ------
2> main.c
2> vmx.vcxproj -> D:\Shared\Dynos\Build\Visual Studio 2010\Solutions\..\..\..\Lib\Win32\Debug\vmx.exe
========== Build: 2 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
Everything is OK.
Could someone explain to me what is happening here?
Thanks

I ran into this problem recently as well, and after much head banging, I realized that the output directory was the same on several of the projects. So project A would get rebuilt fine, however when project B was "rebuilt" it would clean out the output directory including projectA's .lib and .dll files, and subsequent project rebuilds would fail.
Our fix for the moment for our auto build was to do a clean, then a build on the solution, instead of doing rebuild or clean/rebuild. Obviously the alternative would be to change the projects to each have their own output directory.
Hope that helps someone!

I found the solution to my problem. The solution is to not to use the Frameworks and References feature in project settings and JUST use the old Project Dependencies system. I removed my reference and clicked the checkbox in the Project Dependencies dialog box and it all works now. Weird!
I huess Frameworks and References is just for C# projects and should be avoided for C++ ones.

For me it was the intermediate directory that has been cleaned before the next project got built. This was really confusing, as I didn't knew what exactly will be separated into that directory and my solution and project files are all in the directory.
If you have the solution file *.sln and the referenced project files *.vcxproj all in one directory, then add $(TargetName)\ to the value of Project Properties > Configuration Properties > General > Intermediate Directory or replace it with $(Configuration)\Int\$(ProjectName)\.
This is needed for me, as I use the project in other solutions, too.

I have encountered similar problems. Certain versions of Visual Studio have this problem (see reference). I was using Visual Studio Community 2022 (64-bit) Version 17.2.6, and switched to different versions (Microsoft Visual Studio Community 2019 Version 16.11.18 and Microsoft Visual Studio Community 2022 RC (64-bit) Version 17.0.0 RC2), which fixed the problem.

1)Might be some dependency issue
OR
2)Some old intermediate files might be remaining during rebuild which
get deleted during clean & are replaced by new, correct ones during fresh build.

Related

MSBuild failing to find assembly following upgrade to VS2015

We have a build script which uses MSBuild to build our solution. It has worked fine for VS2013, but it has broken since we installed VS2015 and upgraded. Initially, it failed with this error:
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Platform.targets(64,5): error MSB8020: The build tools for v140
(Platform Toolset = 'v140') cannot be found. To build using the v140 build tools, please install v140 build tools. Alternatively, yo
u may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Upgra
de Solution...". [C:\Users\user\Documents\GitHub[snipped]Api.vcxproj]
So it was failing to build a C++ project since is seemed to default to using version 12 of MSBuild, even though it was a VS2015 project. So I added:
/tv:14.0
To the invocation of MSBuild to force it to use the right tools version. Now it fails with this:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(219,5): error MSB4175: The ta
sk factory "CodeTaskFactory" could not be loaded from the assembly "C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Build.Tasks.v12
.0.dll". Could not load file or assembly 'file:///C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Build.Tasks.v12.0.dll' or one of
its dependencies. The system cannot find the file specified. [C:\Users\user\Documents\GitHub[snip].Api.vcxproj]
Now it's looking for a v12 assembly in the v14 folder. How do I fix this? I can't see any obvious place to make this change.
Note: The C++ project itself might be a red herring, the solution is mostly C# and this might just be the place where it loads in the tasks.

Non-Concurrent builds using DevEnv.exe

I have a requirement to use devenv.exe to build our VS2010 projects. I need the projects to build 1 at a time since running multiple builds concurrently causes issues. I have set the number of concurrent builds to 1 in Tools -> Options -> Projects & Solutions -> Build and Run. When I execute the build directly from VS2010 everything works ask expected.
------ Rebuild started: Project: project1, Configuration: Release Win32 ------
.
Compile Output
.
------ Rebuild started: Project: project2, Configuration: Release Win32 ------
.
Compile Output
.
But when I run it from the command line
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" C:\Users\Me\project\MySolution.sln /rebuild "Release|win32" /project C:\Users\Me\project\MyProject.vcxproj /out C:\DevEnv.log
It starts to the build the projects in parallel.
Microsoft (R) Visual Studio Version 10.0.30319.1.
Copyright (C) Microsoft Corp. All rights reserved.
1>------ Rebuild All started: Project: project1, Configuration: Release Win32 ------
2>------ Rebuild All started: Project: project2, Configuration: Release Win32 ------
3>------ Rebuild All started: Project: project3, Configuration: Release Win32 ------
4>------ Rebuild All started: Project: project4, Configuration: Release Win32 ------
Is there a flag or setting that I am missing to get these builds to run 1 at a time when using the command line?
Edit: It should be noted that I am running this build in Jenkins. When running the above command in a command prompt it seems to work fine. But running the command in Jenkins causes the build to execute in parallel. Perhaps there is some environment variable that needs to be set?
I have never seen anyone try to build a solution from the command line using devenv.exe. I think that's because devenv.exe is Visual Studio. You're probably better off using MSBuild instead. Anything VS does MSBuild should be able to do because VS uses MSBuild under the hood. And it should be able to build your solution and/or project files without modification.
Since you say you're using Jenkins for CI, check out this MSBuild plugin for Jenkins.
https://wiki.jenkins-ci.org/display/JENKINS/MSBuild+Plugin

Failed to locate: "CL.exe", Opencv with Visual studio c++ 2010 express program error

I have tried a lot of tutorials regarding configuring opencv 2.2 or 2.3 with MVS 2010 express C++, I tried also uninstall and reinstall my MVS 2010 to sure that it is working. Moreover I also configured it with opencv, like creating property sheets (DEBUG & RELEASE) and then set the Additional dependencies, libraries,includes, etc.
But when trying to run a simple program (Like displayin a video), I get this error:
1>------ Build started: Project: wew, Configuration: Debug Win32 ------
1>TRACKER : error TRK0005: Failed to locate: "CL.exe". The system cannot find the file specified.
1>
1>
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Has anybody experienced the same problem and solved it?
I encountered this while installing React Native via npm. I solved it by following the advice in this post: Visual studio doesn't have cl.exe
Visual Studio 2015 doesn't install C++ by default. You have to rerun
the setup, select Modify and then check Programming Language -> C++
I assume it would work for older versions of Visual Studio as well.
I encountered this error today and my problem was that I had accidentally overwritten the "executable directories" part of the project's property pages. I.e. I overwrote the (common properties->VC++ Directories->Executable directories) entry.

Visual Studio 2010 says it built DLL but didn't

I'm attempting to build both a .DLL and a .lib for the latest SQLite3 release. I created a new project in Visual Studio 2010, chose Visual C++ / Win 32 / Win 32 Project, and chose the DLL option. (Although it has ".NET Framework 4" as a pop-up menu selected. Is this an issue? I don't want to require the .NET framework.)
When I build the project, it seems to work:
1>------ Build started: Project: SQLite3, Configuration: Release Win32 ------
1> shell.c
1> sqlite3.c
1> Generating code
1> Finished generating code
1> SQLite3.vcxproj -> c:\users\jensenv\documents\visual studio 2010\Projects\SQLite3\Release\SQLite3.dll
But there is no SQLite3.dll in that directory. There are a lot of log files, plus shell.obj, sqlite3.obj, SQLite3.og, and vc100.pdb. Why does it say it created a .dll when there is none there?
And is there anything I need to do to get it to create a matching .lib (exports symbols) too?
Are you sure you are looking in:
c:\users\jensenv\documents\visual studio 2010\Projects\SQLite3\Release
And not in:
c:\users\jensenv\documents\visual studio 2010\Projects\SQLite3\SQLite3\Release
The first one contains final DLLs/EXEs, while the second one contains intermediate files like .obj files.

Visual Studio 2010 cannot build projects

I have a weird problem.
I just installed visual studio 2010 RTM on windows 7 Ultimate. I have two problems!
1) File->New Project returns empty templates. Cannot create a project. But if I open a solution I can add project in the solution.
2) I cannot build the project! No matter what I tried build project returns only
------ Build started: Project: WindowsFormsApplication1, Configuration: Release Any CPU -----
========= Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
It only creates *vhost.exe files but not the exe. I tried to set detailed output in build but the same message appears. Even Cleaning the project does the same thing
I installed and reinstalled VS2010 several times. I installed it as Administrator and I also put "Everyone" to be allowed in the VS2010 install folder. My other co-workers installed it correctly from the same DVD.
can someone help me?
thanks
so the only solution was to format my system and re-install windows 7 :(

Resources