Move files in Visual Studio and AnkhSVN simultaneously - c++

I'm reorganizing my project in visual studio. I have some .cpp/.h files which I want to move into a subdirectory physically. A would like to have the following acts simultaneously:
File moving on file system
SVN working copy database updating (with keeping history)
Visual Studio project file(s) updating
Extra benefits would be nice, like:
Updating of #include directives referring to the file.
Are there any solutions? Best workarounds?

This is the proverbial chicken-and-egg dilemma for software developers:
Do you move/rename your files in Visual Studio first then go back to Windows Explorer and correct all the adds/deletes that should really be renames/moves?
Or do you rename/move your files in Windows Explorer then go clean up all the introduced compilation errors in Visual Studio?
You already have the solution at hand! Without AnkhSVN if you do your file operations in Visual Studio you already get two of your requirements: updating your VS project and file system synchronization. With AnkhSVN installed, though, you also get your 3rd requirement: it makes the necessary SVN synchronizations as well. All you have left to do is a commit.

I found the following description from a cached page in a Google search:
In Windows Explorer, right-click and drag the file from its old
location to its new location, then select "SVN move versioned item"
from the context menu. This will not only move the actual file itself,
but it will also make sure that all the file history stays with it
after you check in your changes. Back in Visual Studio, use the
Solution Explorer in VS2010 to "exclude from project" the
(now-missing) copy of the file in its old location, and then "include
in project" the file in its new location. You may need to refresh the
view in solution explorer and/or make sure you are viewing all the
files by clicking the "Show all Files" icon at the top (next to the
refresh icon) in order to see these files.
After you update the namespace to reflect the new location, I
recommend using a global find and replace before you try to compile to
save yourself a lot of trouble.
Hope this helps.

Related

Add Image to Assets Folder UWP C++

Why can't I add images to my UWP assets folder? I usually use C#, but I have to use C++ because I'll eventually be turning this into an optional package (somebody tell me if I'm wrong, and I can write optional packages in C#).
Using Visual Studio, I right click on the Assets folder in the Solutions Explorer click Add->Existing Item and then click on my image. It shows up in Visual Studio, but it doesn't actually get added to the Assets folder so I'm unable to view it when I load my app. I wouldn't think that it matters whether I use C++ or C#, but one is working and not the other.
I've tried rebuilding the project, rebooting the computer, repairing Visual Studio and I'm still stuck.
As suggested by paxbun, I tried using File Explorer to add the file. If I added the file in the Assets folder with the project files, it didn't help. I was able to get the code to work by adding the file to the AppX folder in the Debug folder, but this won't help when I'm ready to release (to make sure, I did a quick sideload).
I haven't put much at all in the code, but you can view it at https://github.com/benjasperson/SimpleCPPImage
Upon further research, I found my answer here.
Clicking "Show all files" in the Solution Explorer and then setting "Include in project" to true was all I needed to do.

Visual Studio & C++: Use filters as directories

I Use Visual Studio 2012 Professional and C++. When creating so called 'filters' and adding source files to them, the files in the solution explorer are divided into sub directories, while on the file system they are all in the same directory (the project directory)
Question: I want to add a file to a filter while at the same time adding it to the corresponding directory on the file system. How can this be accomplished other than manually moving files around?
One alternative would be to switch to "Show All Files" in Solution Explorer top menu.
This way you can move and manage files in folders.
Filters will not get used though.
The "Show All Files" solution did not work for me because in my case the source files were not located under the directory containing the project file.
I finally ended up with writing a VS extension which allows you to organize either the filter structure inside the project or the file structure on the disk automatically by invoking a command through the context menu. I thought some of you might be interested in that extension too:
https://github.com/reloZid/vc-fileutils
I know only this workaround: you create first the folder structure in windows explorer and then drag / drop the files / folder from windows explorer into the solution explorer of Visual Studio.
It will add them all as a "filter" to Visual Studio!

Visual Studio can't 'see' my included header files

I created an empty 'Demo' project in Visual Studio 2008 and added some existing projects to my solution. Included "MyHeader.h" (other project's header) in main.cpp file which is in 'Demo'. Also added header files' path in "Tools/Option/VC++ Directories/Include files" section. But intellisense says: "File MyHeader.h not found in current source file's directory or in build system paths..."
How the problem can be fixed?
Delete the .sdf file that is in your solution directory. It's just the Intellisense database, and Visual Studio will recreate it the next time you open that solution. This db can get corrupted and cause the IDE to not be able to find things, and since the compiler generates this information for itself on the fly, it wouldn't be affected.
If you choose Project and then All Files in the menu, all files should be displayed in the Solution Explorer that are physically in your project map, but not (yet) included in your project. If you right click on the file you want to add in the Solution Explorer, you can include it.
This happened to me just now, after shutting down and restarting the computer. Eventually I realised that the architecture had somehow been changed to ARM from x64.
In Visual Studio 2019 in my case I copied a header file into the project directory, just near the other files. Intellisense could see it, but the build failed. Fair enough, it wasn't actually added to the project. I added it as existing item but this is the point that Visual Studio still didn't account for it.
Solution:
Close the project.
Delete the .vs directory.
Reopen the project.
Now Visual Studio recreates the directory with everything in it and it can now see the included file.
If it is the case that only the IDE indicates that it cannot find included files, but compiling is successful, the issue is simply that IntelliSense is not fully up to date with recent changes. This can happen specifically when including existing projects, in my own experience.
Deleting the .sdf file (= IntelliSense database) that is generated in your solution directory forces Visual Studio to regenerate it, so that it is up to date again. Just doing a "clean" will probably do the same thing, but takes more time since everything will be generated again then.
I know this is an older question, but none of the above answers worked for me. In my case, the issue turned out to be that I had absolute include paths but without drive letters. Compilation was fine, but Visual Studio couldn't find an include file when I right-clicked and tried to open it. Adding the drive letters to my include paths corrected the problem.
I would never recommend hard-coding drive letters in any aspect of your project files; either use relative paths, macros, environment variables, or some mix of the tree for any permanent situation. However, in this case, I'm working in some temporary projects where absolute paths were necessary in the short term. Not being able to right-click to open the files was extremely frustrating, and hopefully this will help others.
Had the same problem. Double check if you added the include files to Debug or Release Version of your project. If you only added it for one of them and compile for the other VS will just play dumb and not find them.
Try adding the header file to your project's files. (right click on project -> add existing file).
In my experience, with VS2010, when include files can't be found at compile time, doing a clean, then build usually fixes the problem. It's not that rare for the editor to be able to open an include file and then the compiler to announce that it can't find that very file, even when it is open on the screen!
If the visual studio says that you miss some file in the current source file folder, there is one solution that i used. Just right click the file you want to add and choose Open Document, if it really doesn't exist, then you should see something like cannot find file in the source file path = "somewhere in your computer", then what you could do is the add your source file into that path first and see if it works.
I had this issue after upgrading to Visual Studio 2019 from 2015. It would compile the project fine but Intellisense and the IDE couldn't find any header files.
The project only had valid configuration for Win32/Debug. Include paths were not setup correctly for other environments. Even though Visual Studio displayed the current environment as Win32/Debug, Intellisense must have been using something else.
Changing the current environment to x64/Release, and then back to Win32/Debug fixed it.
In Visual Studio, click on Project > Rescan Solution as shown below to rebuild the project database.
Here's how I solved this problem.
Go to Project --> Show All Files.
Right click all the files in Solutions Explorer and Click on Include in Project in all the files you want to include.
Done :)
I encountered this issue, but the solutions provided didn't directly help me, so I'm sharing how I got myself into a similar situation and temporarily resolved it.
I created a new project within an existing solution and copy & pasted the Header and CPP file from another project within that solution that I needed to include in my new project through the IDE. Intellisense displayed an error suggesting it could not resolve the reference to the header file and compiling the code failed with the same error too.
After reading the posts here, I checked the project folder with Windows File Explorer and only the main.cpp file was found. For some reason, my copy and paste of the header file and CPP file were just a reference? (I assume) and did not physically copy the file into the new project file.
I deleted the files from the Project view within Visual Studio and I used File Explorer to copy the files that I needed to the project folder/directory. I then referenced the other solutions posted here to "include files in project" by showing all files and this resolved the problem.
It boiled down to the files not being physically in the Project folder/directory even though they were shown correctly within the IDE.
Please Note I understand duplicating code is not best practice and my situation is purely a learning/hobby project. It's probably in my best interest and anyone else who ended up in a similar situation to use the IDE/project/Solution setup correctly when reusing code from other projects - I'm still learning and I'll figure this out one day!
If some soul has scrolled down to this bottom, what worked for me was disabling the Disable Database option i.e. set it to False under Tools|Options|Text Editor|C/C++|Advanced. For some reason, it was set to True for me.
As per docs, if it's set to True
All use of the code browsing database (SDF), all other
Browsing/Navigation options, and all IntelliSense features except for
#include Auto Complete are disabled.
None of the solutions worked for me. Here is what was the issue for me:
(Note discrepancy in build configuration and VC++ Directories (x86 vs x64)
To fix, just changed the build configuration to 'x86':

VS2010 Solution under TFS 2010 source control cotaining a C++ project gives warning when opened

I have just taken over the maintenance of a project. It is a VS2010 solution which in amongst its projects includes a C++ project. The whole solution is kept in TFS 2010 as a source control system.
Now whenever I open the solution VS2010 presents me with this annoying dialog;
Visual C++ found a suitable location to store its browsing database and IntelliSense files
for the solution
"C:\***\****x.sln."
Visual C++ examined the folder "C:\***\A***LL."
This folder is not suitable because of the following:
The browsing database in this directory has the read-only attribute and cannot be written to.
The directory is on a local drive.
Because a 'Fallback Location' was not specified in the C++ Advanced Options, Visual C++ is
attempting to use your temporary directory.
Visual C++ examined the folder "C:\Users\***\AppData\Local\Temp\VC++\c****-57e7d5e2." This folder is suitable because of the following:
The directory is on a local drive.
The 'Fallback Location' is configurable under C++ Advanced Options.
Press OK to use this location.
It looks like this is caused by the C++ solutions *.SDF file being under source control, meaning when the solution is opened (despite being under source control) its read only hence the read only bit of the dialog.
So my question is whats the best practice for a C++ project under TFS source control?
Should I remove the .sdf file from source control, leaving VS to recreate this everytime somone gets the solution?
Should I tick the use fallback option efectivly bypassing the .SDF in the repository
or
Is there a better way that lets VS2010 know the SDF file is under source control so it can automatically check it out when it opens the project?
I can only recommend to exclude the sdf from source control. You have no benefit from versioning it, since it's generated every time something changes, which will be almost everytime. As an mantra one could say, that you should never versioning binary files unless it's absolutely necessary to share them (eg. icons and images that are needed).
My issue was with an Unreal Engine 4 solution. The issue was that I had moved the project's intermediate folder (which included build files), and then it was re-generated (without build files) the next time the editor was opened. The fix was to delete the new intermediate folder and re-migrate the old folder to the project directory.
If you had already deleted the intermediate folder and don't have a backup, the fix is most likely to rmb the .uproject>generate visual studio project files.

Visual Studio unmanaged C++ smart file explorer

I use Visual Studio to develop unmanaged C++ apps for a living.
Is there an add-on tool (price isnt the issue) that is smart enough to detect folders that I create within my solution folder and add them to the include path (/I)? It would automatically do this for win32, or x64 platform settings, or debug, and release, etc.
It should also be smart enough to remove the include paths if folder is deleted
Arent you frustrated sometimes when you double click a file under solution explorer and Visual Studio says it cant find the file because somebody moved or renamed it? ---> Is there a tool that would periodically scan the files in Solution Explorer and automatically removes or prompts the user to let them know those files are no longer valid?
Like John Lakos once said, I too would pay for an add-on that can automatically add #include into my code by just parsing my project's .h/.cpp files.
When is Visual Studio going to have an Eclipse-like solution explorer that allows user to directly manipuate the files/folders structure directly from within Visual Studio?
You can manipulate files/folders from the IDE! Just click the "show all files" button in the solution explorer (2nd from left, at the top). I just recently found that out.