When trying add existing project to solution, a project in a different path is referenced - visual-studio

I am doing some housecleaning with our VC++ project structure and I had the following weird directory setup. In one folder, called "USBAScan", I have a Visual C++ project file, named "USBAScan.vcxproj". USBAScan has a subfolder that is also called "USBAScan". It also has a VC++ project file named "USBAScan.vcxproj".
My VC++ solution references a project named "USBAScan.vcxproj". Its project file property is "USBAScan\USBAScan\USBAScan.vcxproj". I remove this project and delete the project file USBAScan\USBAScan\USBAScan.vcxproj. In the solution I try to add USBAScan\USBAScan.vcxproj. I get the following error message:
"The project file USBAScan\USBAScan\USBAScan.vcxproj has been moved, renamed or is not on your computer".
Although I'm trying to add USBAScan\USBAScan.vcxproj, the solution is trying to add USBAScan\USBAScan\USBAScan.vcxproj. Why would it behave this way?

Related

How do I edit out old include paths in Microsoft Visual Studio 2022?

I am working on a project that originally had all of its .cpp and .h files in the same diectory (the src folder).
As the project is growing larger though, I wanted to seperate the files into their own subdirectories. However, after doing this, VS gives the error that the files are no longer included in the project becasue I moved them to a new directory. I then right-clicked on each file and selected "include file in project". It loaded and my errors went away.
Problem is that now when I try to compile I get an error saying cannot open the source file "src/fileName.cpp" No such file or directory. But, of course that file isnt there anymore because I moved it!
I could be misunderstanding but it seems to me that VS is still holding on to the old include paths even though the files were moved and the new paths were included. Since I added these files using the right-click method I mentioned I don't know how to navigate the project properties to get rid of the old paths that were included by default.
For clarity:
Old project structure:
src:
- game.cpp
- game.h
- logger.cpp
- logger.h
new project structure:
src:
- Game
- game.h
- game.cpp
- Logger
- logger.h
- logger.cpp
I have found the solution to my issue from someone on Reddit.
I had to unload my project to get access to the project files (.vcxproj). Once here I used the search function to find and manually remove the old include and compile paths. After reloading the project the issue was resolved.

Prevent Visual Studio from deleting output files from referenced projects

I've got a Class Library project and a Console project. Inside the Class Library project there's a folder called "ConfigSettings" containing a configuration file that's referenced by the App.config file. Its "Copy to Output Directory" is set to "Copy Always".
The Console project references this Class Library project. When the console project is built, the ConfigSettings folder is created in the correct place along with the external config file. However, every time I Debug the Console project, the external config file is deleted. The ConfigSettings folder however is left untouched. If I mark the file as read-only it is not deleted, and warning appears in Visual Studio's Error List:
Warning Unable to delete file "C:\<path>\<app>\bin\Debug\ConfigSettings\settings.config". Access to the path 'C:\<path>\<app>\bin\Debug\ConfigSettings\settings.config' is denied.
Is there a setting I can change that will prevent VS from removing this file when I Debug the project? I am using Visual Studio 2015.
This might not be the best solution possible, but I found here, if you do a "Clean solution" just before executing your solution, the files will remain.

Visual Studio 2010: how to automatically copy files into debug directory

I've got a dll, into which I've inserted txt files into the names subdirectory
When I build the solution, VS does not create the directory and does not copy the files themselves into the directory of the exe file, which references the dll library
Is there an easy way to make it do that?
It should do that, provided that you have a reference for the class library project in your executable project. I just setup a scenario like this in Visual Studio 2010:
Created a C# Console Application project
Created a C# Class Library project
Added a Reference to the C# Class Library project into the Console Application project.
Added a folder to the C# Class Library project called 'Files'
Added a Text File to the 'Files' folder called 'File1.txt'
Set the Text File 'File1.txt' 'Copy to Output Directory' property to 'Copy Always'
Did a 'Build Solution' and looked in the bin directory of my Console Application and low and behold there was a folder called 'Files' and within it, a file called 'File1.txt'
Maybe you are missing a project reference to your class library in your exe?

Unable to copy file exception in TFS build

I am getting following error
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets (178): Unable to copy file "bin\AjaxControlToolkit.pdb" to "C:\Builds\2\testbox\test\Binaries\_PublishedWebsites\test\bin\AjaxControlToolkit.pdb". Could not find a part of the path 'bin\AjaxControlToolkit.pdb'.
Just checked file is available on path.
same working fine on local as well as while building from team city. Don't know whats going wrong.
Edited
Just cant understand why it is trying to copy from obj directory..Please see the following log
Copying file from "obj\Debug\Manager.dll" to "C:\Builds\2\box\Two\Binaries\Manager.dll".
Manager -> C:\Builds\2\box\Two\Binaries\Manager.dll
Copying file from "obj\Debug\Manager.pdb" to "C:\Builds\2\box\Two\Binaries\Manager.pdb".
Copying file from "obj\Debug\Manager.xml" to "C:\Builds\2\box\Two\Binaries\Manager.xml".
Done Building Project "C:\Builds\2\box\Two\Sources\Manager\Manager.vbproj" (default targets)
Where as I have set the output to bin.
Possible reasons:
This reference is dynamic, meaning its path gets cleared and created on each build. Third party reference files should be checked in the source control to a common shared folder (e.g. \lib).
Your project have a file reference to AjaxControlToolkit to a path
which does not exist on build the server. Open the project's .csproj
file,and check the HintPath of AjaxControlToolkit.
Avoid referencing third party assemblies from the GAC (where the first bullet is applicable).

Visual studio compile error

I as using visual studio 2010. My solution is having more than one projects in it which are have relationships to each. When I adding a reference to a other project I can use public components (classes,enums ) of that. But when I compile it it gives error saying that those classes are not referenced(Not available).
But when I change the folder structure(When I reduce the level of folder hierarchy/when project folders borings to the root folder ex: d:\ ) it works fine.
Is it because of the length of the folder hierarchi ?
Check your namespaces
When you're adding reference, add it using Project References. So what it does is it compiles the dependencies first. Check if all projects are compiling individually.
Verify target framework versions
No, it is not because of folder hierarchy.... it is because not setting hierarchy properly !!
Follow this steps:
Lets say you have project A and project B.
Project A is dependent on Project B. So we need to add dependency of Project B to Project A.
So right click on Project A -> Open Folder in File Explorer.
Then check which folder it opens into (Lets call it "source folder") and check where the project files whose dependency to be added (Lets call it "destination folder") are located from that folder location. Add the relative path from source to destination folder. (Ex: "..\..\destination folder" ).
Add this relative path in Project A Properties -> Configuration Properties -> C/C++ ->Additional Include Directories.
Good luck.
Yes, hangar18 has suggested correctly. Add reference of each project (Static Libraries) to you execuatble project ( Console Application Project / Startup project).
Also add path of each folder where the header files and corresponding C/C++ files are residing.

Resources