Visual Studio project is placing object files in unrelated project directory. help - visual-studio

I have a visual studio solution that contains a project that builds a joystick handling library. Unfortunately, the output .lib file is placed in an unrelated folder on the drive. It is placed in another project. I noticed that $(TargetDir) is expanding to the unrelated project's path and not the current solutions path. How do I change this? I searched the visual studio project files for any matching path text and nothing turns up so I can't see how it is pointing to the wrong directory.

Ok, I screwed up. The project was pointing to the wrong directory (obviously) :-)

Related

How do I extract source code files from Visual Studio pollution?

In a directory where source code resides, there are also Visual Studio related files, like *.user, *.vcxproj. And Debug and Release folders.
I would like to change project directory layout so it looks like this:
For example, the project is named ProjectX.
In the ProjectX main folder, there would be only two subfolders:
ProjectX/Source
ProjectX/Build
In ProjectX/Source there would be all source code files, but nothing else.
In ProjectX/Build there would be all Visual Studio-related files.
How can I do it?
To move the vcxproj into the build directory, move the vcxproj into the build directory.
To move your source files under a source directory, move your source files under a source directory.
After either or both of the above steps, you'll need to re-add the files to Visual Studio, but I'm sure you knew that. Visual Studio isn't psychic and can't guess where your files are if you move everything around.
The SDF file can be moved by asking Stack Overflow how to move the SDF file: How to change ipch path in Visual Studio 2010
Visual Studio 2015 should not be creating .user files any more. Perhaps you're not fully updated?
At this point you have everything you wanted, even though it's weird. Except for portable projects, people aren't generally moving their vcxproj files. The vcxproj file is typically considered the root of the project, just like a makefile would be; under it is build and source.
Now let me give you advice. Don't do all of that. Do this instead:
Move your source files in a source directory. Now in Visual Studio, go to project properties and change Output Directory and Intermediate Directory to $(ProjectDir)Build\$(Platform)\$(Configuration)\
Now you have one Build directory instead of a Debug and Release directory. That means a lot to some people. It means more to people with more build configurations.

TFS: Check In after renaming a project

I've renamed one of the projects in a Visual Studio solution. Renaming the project involved renaming its directory and as a result the paths to some files have changed. The solution is under TFS source control. When trying to check in I get a "file not found" error displaying the old path of one of the files. How do I check in the changes?
As I know, when you rename the project, underlying source folder path keeps unchanged (maybe it depends of Visual Studio version).
Try this:
Rename the project folder from Source Control Explorer.
If you have errors with old path, try to unload the project from Solution Exproler, open proj file for edit, and replace old path entries with a new one.
Don't forget to update references from other projects.

Visual Studio Makefile Project makes extraneous 'obj' folder

I'm using a Makefile project in Visual Studio 2012 express just fine. However, regardless of the Build Command specified, Visual Studio always makes an 'obj' folder containing empty subfolders obj\Win32\Debug and obj\Win32\Release.
To reproduce the problem, simply create a "Visual C++ - General - Makefile Project" and use a DOS command like 'dir' in the Build Command Line. As soon as you build, the empty obj\Win32\Debug folder will show up.
I can simply skip these in my Mercurial ignore file but it'd be nice to find a fix. Anyone know how to make Visual Studio not generate these empty folders?
Found a trick: to set the intermediate output directory on an existing directory. I modified the project file by hand and added this:
<IntermediateOutputPath>$(ProjectDir)</IntermediateOutputPath>
inside the configuration PropertyGroup. I used the project directory, which obviously already exists. No more useless obj directory!
The obj folder represents VS' own metadata about your project for intellisense support and designer support (for WF/WPF apps). For the most part you can ignore the folder completely without issue.
On occasion though this data can become corrupt and cause VS to show invalid Intellisense options and the workflow/WPF designer can cause errors. Closing VS and deleting the obj folder will quickly resolve this though.

VC++ Visual Studio added .hpp files in subdirectory but get "Error: cannot open source file ..."

This is driving me nuts - I've added a number of .hpp files in subdirectories in the root of an existing VC++ projects source directory.
Visual Studio complains "Error: cannot open source file ..." but if I right click on the and select open document, VS can display it.
I've tried:
"Rescan solution" which appears to do nothing.
Adding existing item (both on it's own and with a "filter" - which appears to be a directory?)
Closing the project and VStudio in the vain hope it would eventually discover the directories/files I'd added
VStudio complains it cannot find these files when it is capable of opening them? My question is simply this: "How can I add a directory containing source files to a VC++ project such that the linker/complier can see them?
(disclaimer; i've never used Visual Studio before or many Microsoft products, so am finding this all very alien)
Workaround;
Add the files to a directory outside of the project and then reference those directories in the "Additional Include Directories" in Properties -> Configuration Properties -> C/C++ -> General.
Why I can't add additional directories within the project and have Visual Studio rescan them (like an Eclipse refresh) is beyond me.
Please see the answer at the following question. This answer fixed the problem for me. It has to do with adding $(ProjectDir) in the "C/C++ Include Directory" in the project settings.
"Cannot open include file" error in VS2010
The answer linked above, fixed my issue with not being able to include subdirectory files inside of the project. I hope this helps anyone else having this issue.
Thanks,
first you need to include any header file you'd like to use into your cpp files by #include "path/file.hpp". in your case your probably didn't specify path, e.g. "subdir/file.hpp"

Howto resolve... Visual Studio Source Control notification "Projects have recently been added to this solution"

After some use Visual Studio 2008 when opening a solution that is checked into Visual Studio Team Foundation will pop up a dialog saying:
Projects have recently been added to this solution. Do you want to get them from source control?
This happens every time the solution is loaded (even if no projects have been added). The only way I have found to remove this minor annoyance is to completely rebuild the SLN file.
Has anyone found a better/simpler way?
I had this recently after we moved a number of projects in the solution. I worked out eventually, that each project actual appears in solution file multiple times each with path information! So even though the path in the main reference of the project was correct it was wrong further down the file.
So go through the .sln file and make sure the paths in all the references of each project is correct.
For instance, the first reference for one of my projects is:
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ObexPushVB", "Samples\ObjectPush\ObexPushVB\ObexPushVB.vbproj", "{E3692A59-D636-48E8-9B57-7DA80A88E517}"
EndProject
In my case the path there was correctly updated. But then we have also for that project:
SccProjectUniqueName8 = Samples\\ObjectPush\\ObexPushVB\\ObexPushVB.vbproj
SccProjectTopLevelParentUniqueName8 = InTheHand.Net.Personal.sln
SccProjectName8 = Samples/ObjectPush/ObexPushVB
SccLocalPath8 = Samples\\ObjectPush\\ObexPushVB
So all of those paths needed to be updated too! After I fixed that manually all was well. (The sample there is after the fix BTW).
Hey, this actually happened to me about 4 years ago.
First, it sounds to me like someone on your team doesn't have all the updates applied to their visual studio installation. Go around and get everyone upgraded to the latest service pack for your VS version.
Once that is done, unbind the solution, fix the file, rebind it and tell everyone to do a force get latest on your TFS project.
See
http://social.msdn.microsoft.com/Forums/en-US/tfsversioncontrol/thread/c2822ef1-d5a9-4039-9d3e-498892ce70b6
http://www.nivisec.com/2008/09/vsts-projects-have-recently-been-added.html
(broken link: http://technorati.com/posts/Yadz3Mj1pxHPSJLlnUs1tL1sIwU5jXa5rNBbIAnYdvs%3D)
This message will also occur if your solution has a reference to a project whose location is outside of the solution directory, but it doesn't physically exist (i.e. you hadn't checked it out before opening the solution). VSS (or TFS) will then give you that message and clicking OK will automatically get latest on the project that's missing so your solution won't have any unloaded projects in it.
EDIT:
Reading that again confuses me. Basically you get the message if your solution has a source control binding to a project that isn't inside of the folder your solution is in, and that outside project doesn't physically exist on your machine. Clicking on OK will check the project out for you.
In my case it was a reference to a test project which has been deleted.
I noticed that when I inspected all the projects in the Solution Explorer. Our team uses solution folders so it was not normally visible and because it was a test project it didn't have any impact on the application.
After removing the project from the solution the messages is no longer shown.
I'm working with Visual Studio 2013.
For me, it happened after having modified the folder's structure of my solution (I added a sub-folder for a project directly on the source code explorer). I got rid of this boring error by removing all the projects from my solution, using the solution explorer. After that, I closed Visual Studio, manually edited the .sln file and removed the whole section :
GlobalSection(TeamFoundationVersionControl) = preSolution
To finish, I just added the projects back to the solution as "Existing projects" with solution explorer. Visual Studio will recreate by itself the removed section of the .sln file.
The same error message can occur if someone adds a project, check-in edited solution file, but don't adds project directory to source control.
To cut a long story short - this error can mean that in .sln file there's reference to .csproj file, but the .csproj itself is physically missing.
In my case I renamed a(n) (unloaded) project in VS. It correctly moved the project to a new folder and no data was lost. However the solution file still pointed to the old directory which still existed but was empty (so the project could not be actually loaded).
After deleting the project from the solution (which was no problem because the folder was allready empty) the problem was solved.
Adding the project again from the new location was no problem either.
I had this problem after moving a number of unit test projects that were under source control (VSTS) into another folder. After this whenever I opened a branch I would get the "Projects have recently been added to this solution. Do you want to get them from source control?" error.
For some reason the csproj file from the trunk wasn't under source control which meant it was missing from the branched version. I find this happens sometimes after moving source controlled projects.
To fix it I opened the original source trunk, used Source Control Explorer to add the missing file(s), then merged the trunk to the branches to copy over the missing csproj file.
After this I could open the branched versions without the warning popping up.

Resources