Ignore an entire directory in Visual Studio before a build? - visual-studio

I currently have a project I am building in Visual Studio 2005 and I need to be able to build the part of the project some of the time with directory A and sometimes with directory B and never both. If you right click a file (foo.f) --> Click Properties --> you can change the "Exclude File From Build" from NO to YES and the project will build w/o that individual file.
Is there a way to do this for an entire folder/directory (without individually clicking every file in the folder) so that that particular folder/directory will be ignored in the build?
NOTE: I know I could select all the files in the directory if there were not subdirectories. I realize that would work but there are many subdirectories within this main directory (1000+ files 20+ subdirectories) and using shift and selecting the top and bottom files. You cannot select them all that way; it pops up an error when you right-click!

Solution explorer supports multiple selection.
Open the directory
Select the top file
Hold shift and click on the bottom file.
This will select every file in the directory. The right click context menu will then allow you to exclude them all as a group.
You can get even more fine grained selection by using control to select elements.

Related

TFS 'All files are up to date'

Issue
I get 'All Files are up to date' with TFS's 'get latest' (Both at the parent directory and solution level) when they clearly aren't (there are a few folders that others have checked in that I am not getting). I can see they exist locally in the appropriate location (which is most certainly mapped) but I absolutely can not get them added to solution explorer.
I'm in VS 2013.
What I've Tried
1) Drag and drop the folders from the file explorer. Doesn't work - VS apparently doesn't allow this.
2) Right click the parent folder in Solution Explorer click 'Add -> existing item'. Apparently you can't add an entire folder, so adding individually is no good as there are over 2000 items in all the sub-directories.
3) Right click, 'Source Control -> Get Specific Version' check both boxes regarding overwriting.
4) Repeat step 3, but first delete folder in the file explorer. The files get re-added to file explorer, but not Solution Explorer.
5) I found this Visual Studio Solution Explorer not showing files and folders and tried it, also to no avail.
6) Multiple combinations of all the above steps, restarting VS, etc.
Thanks!
EDIT 2/24/2016
Adding this here as a reference diagram for my comment in response to the answer, as I can't use new lines in a comment.
File Structure:
FooFolder
|-foo.txt
|-BarFolder
|--bar.txt
In the above example, you still have to ctrl+click through foo.txt and bar.txt separately, since select all would include the folders and disallow add to solution.
If you see the "missing" files on your local file system after a Get Latest then they are correctly in Source Control. To add the files to your project you need to Show All Files then you can right click each and Include in Project:
To add files to the solution right click and choose Add | Existing Item:

Code Blocks(New project/Rename main file)

When I create a new project in code blocks File->New->project->console application->Go->C++-><project title>->GNU compiler->finish (both debug and release box are checked), Then a project is created having .cpp file with name of main.
My question is how to rename this main file.
Before asking this question I have tried to solve it, but it includes many steps.
I have tried two ways (one way gives me a solution, and the other way indicates that file has been corrupted).
Actually I want to find a quick way to rename this main file?
If there is any method please tell me.
Two methods which I used(mentioning below)
File->New->project->console application->Go->C++-><project title>->GNU compiler->finish
then go to local disc (where project is saved) rename main file. Open project again in code blocks. Open main file it says file does not exist.
This method was quick but failed to rename main.
File->New->project->console application->Go->C++-><project title>->GNU compiler->finish.
then in code blocks at left side bar Sources/main/right click on main/remove file from project (then code blocks indicate you have deleted this main file but actually its not when I checked in local disk, main file was there). Then I create a new.cpp` file as File/New/File and next simple steps.
So finally I got what I want. A new project with .cpp file (name of .cpp file that I want). But I'm not satisfied, I want a quick method.
As of Code::Blocks 13.12 you can rename a file within a project
like this: Say the file to be renamed is main.cpp in project
MyApp.
In the C::B Management pane navigate in the Projects tree-view to
Projects -> MyApp -> Sources -> main.cpp.
Right-click on the file-icon of main.cpp. A pop-up menu appears.
The third item on the menu is Rename file. You can take it from there
Capture your code in a text file.
Close code::blocks
In the folder containing the files, rename all *.cpp and *.h or whatever your using including the cbp file. Don't need to change the depend or layout. Delete the bin and debug folders.
Double click the cbp (project file).
Remove the old files (right mouse click remove).
Then right mouse click on the project and select "add files".
Choose your newly named files, build and run.
In Code::Blocks 16.01, assuming your project and files are open:
If you want to rename main.cpp then, in the Management window, Projects tab, navigate to the Sources folder of your project and right-click on main.cpp. In the context menu that appears, if you find Close main.cpp menu item — click it! otherwise click Rename file...
If you want to rename the title of your project, in the Management window, Projects tab, right-click on the title of your project. In the context menu that appears click Properties... to open the Project/targets options window, and type the new title of your project in the Title field. NOTE that this will not change the name of the project folder or the name of your project's .cbp file, because the title of your project is stored inside the .cbp file.
If you want to rename any file or folder in your project, first close the project using the File menu, then, in the Management window, Files tab, navigate to the desired file or folder, right-click on it and choose Rename.... Proceed with care. You might want to delete old .dependand .layout files that are no longer associated with your project.
In newer versions of CodeBlocks, simply close the file editor and right click on the file (at left tree) -> Rename File.

Duplicating xcode projects

I am trying to duplicate an xcode project for an app that is virtually identical but still has differences in a handful of source files and some data files. For the most part this seems to work, but I am having an issue where, after I build project 2, then project 1, I notice that running project 2 runs with files from project 1. I need to touch the distinct files in project 2 to get them to built in proj 2. Does anyone know what I have to do to have them recognize their own files properly?
I first suspected that it was some sort of object file issue where file.m in proj 1 would be built and confuse file.m in proj 2 into thinking it was up to date. Looking in their config, the dirs for intermediate build files are different, though so maybe I'm looking at the wrong setting or the problem is elsewhere? The two projects use files of the same name but from different subdirectories.
Here is how to locate the missing (red) files using the new Xcode 4 interface: 1) select the file or files in the left hand Project Navigator (the folder icon); 2. In the right sidebar click on "File Inspector" which is the leftmost icon resembling a page; 3. In the "Identity and Type" section, there is a grey box labeled "Location". Click on the small icon to the lower left that resembles a file browser - this will come up with a file browser to locate the file. Voila, you are done.
Unless you set it up differently, Xcode should use the location of folder the project file -- *.xcodeproj -- is in as a basis for referencing its files. Are your .xcodeproj files in different subdirectories, too? If you ensure that the project file and all of the files it references are in completely different directories you should be set.
If you've done that and it's still a problem you can manually re-reference them. Right-click on a file (or the group it's in) and choose Get Info. Then click the Choose button on the right side of the Path entry in the info window, and show Xcode where it should look for that file. Before closing the info window change the Path Type to relative to project.
If the file name turns red in Xcode it means that it doesn't see the file in the location you just specified, so copy it there in the Finder. The red text should turn to black and you'll be set.
Do this with all of the files in each project and there can be no mistake on Xcode's part after that.

Visual Studio - how to BULK add files under a given directory as LINK?

How can one add in Visual Studio all the files under a given directory 'as link' (that is, without Visual Studio creating a local copy under current project's directory, which is what happens if one adds a folder as 'existing item')?
In my case, I don't want local copies. Instead, I want to work with existing items in their original locations. And, I don't want to add them by going through each folder. Instead, I want to specify a given folder and click a magic silver bullet button that adds all of the files below it as 'link'.
Thanks in advance.
(Disclaimer - I went through related questions, but all of them result in VS creating local copies.)
For single files
on the add item dialog you can see a small arrow pointing down on the add button
click that (since it is a button with a dropdown) and chose the add as a link menuitem. that will add the item as link
For multiple files
on the add existing items dialog SELECT all the files you want to add as an link and press the menu item ont he add button add as a link
For Multiple files in multiple locations
If you want to select a folder and add all the items on all subfolders then you can do that this way,
on the open dialog do a search for file types you want to add, select them all and do the "add item as link" action.
Since your question changed twice including the change on the title (once)
Visual Studio - how to BULK add files under a given directory as LINK?
edited title
I have added all the things i think you needs let me know if you still like to do something else
Hope this helps
Dan
If you want files under an external directory to be synced automatically in your Visual Studio project (i.e any new files are added to the solution explorer and any deleted ones are removed) then you can specify a wild card in the link. Do to this you will need to edit the project file (.csproj, .vbproj) manually though.
Find the section in the file where the ItemGroup elements are located and add something like this:
<ItemGroup>
<Content Include="..\MyDirectory\*.*" />
</ItemGroup>
This will add all files under MyDirectory (one level up from the project) to the solution automatically.
If you select 'Show all Files' in the Solution Explorer, you can than view all the files and folers and select them and right click to add them using 'Include in Project'.

Visual Studio solution that just points to a folder and shows all sub-folders and files in the solution explorer?

Is there a way to create a blank solution, or some type of file-based project solution within Visual Studio so that I can point to a root folder, and have all of the sub-folders and files in that root, show up in my solution explorer? I realize I can create a blank solution and then add the individual items manually by add > existing item, however, this does not keep the folder structure intact, and, well, it would take forever if I have a lot of folders/files.
You can also create the blank solution and then click the second-from-the-right icon at the top of the solution explorer (it looks like three files with one "cut out"). Once you click that button to show the files in the solution directory that are not in a project, you can select all the files (with shift-click) and then right-click on your selection and select "Include In Project."
Also note you can select multiple files in the "Add Existing..." file window with shift- or control-click.
You have to create a Visual Studio Project inside your solution to be able to add files with keeping their folder structure. The files to be added must reside below the project's main folder.
I suggest adding a "C# Empty Project" (Solution Explorer: Solution > Add > New Project ... > Visual C# > Windows > Empty Project). After that you can proceed as described by SoloBold to show the files in the project folder. Right click on the topmost folder of your source files an select "Include In Project" and the whole folder structure including all files will be added. This may take some time depending on the number of files / subfolders.
See also: Answer to similar question, with screenshot

Resources