How to build the project which contains the active file in visual studio? - c++

I am using visual studio 2010. My code is in C++ and my solution contains many projects and each project again contains multiple folders under it. Whenever I change a file it gets automatically selected in solution explorer as I have enabled the option "Track Active Item in Solution Explorer" in Tools->Options->Projects and Solutions->General. But after changing the file I have to manually select the project (this could be cumbersome as I have to scroll up and down due to many files present) and then right click on it and select "build". Is there any other simple way to do this?

You could assign a shortcut to Build.BuildSelection or Build.BuildOnlyProject
Go to Tools menu, then Options=>Environment=>Keyboard and enter Build.BuildSelection or Build.BuildOnlyProject in the Show commands containing search text area. Then assign two free shortcuts. Build.BuildSelection is for building the current file; Build.BuildOnlyProject will build its project.
I use ctrl-shift+b to build all the solution. I hate to use the mouse for those repetitive tasks.

Related

Microsoft Visual Studio Professional 2013, Where are variables defined and edited?

I'm working on an existing project, the solution contains quite a lot of projects with a lot of dependencies and variables.
I'm struggling to locate any of the variables using the IDE, where will I find these in the IDE?
For example in one of the .vcxproj files there are variables such as:
$(FraenkelPlatformName)
Where would I find this in the IDE ?
Edit:
Edit 2:
Ok, based on the great comments on my post, but no answer posted this is what I need to do:
From the VIEW top line menu, select Property Manager
Select a project from the left "Property Manager" panel and expand the node.
Open a build folder, Debug or Release and double click on buildvars
From Common Properties select User Macros
All the variables are listed here and can be Added or Removed.

Multiple file compilation in visual C++ 2010

I have a very specific question in regards to visual C++ 2010 express. I have looked everywhere but can't find instructions on how to compile several source files. I have programmed on Unix at the command line and am trying to learn visual C++ 2010. I am using a header file that contains the function declarations and global variables. I don't know if this is the correct venue to ask this question but if anyone knows of some place where I can get the answer I would be grateful
Thanks,
Ral
If you have a project that you build from the command line with a makefile, then the Visual Studio development environment will not recognize your project. To open and build your project using Visual Studio, first create an empty project containing the appropriate build settings using the Makefile Project Wizard. You can then use this project to build your project from the Visual Studio development environment.
The project displays no files in Solution Explorer. The project specifies the build settings, which are reflected in the project's property page.
The output file that you specify in the project has no effect on the name that the build script generates; it declares only an intention.
Source: Creating a Makefile Project (VS2013)
On the menu: File->New->Project
On the dialog:
select Win32 Console Application,
enter Name ( like you did in the -o in unix) in the bottom,
and press OK
On the next dialog: Press next.
On the next dialog:
unmark Precompiled headers
mark Empty project
press Finish
Now find the Solution Explorer tree. You have Solution name and a project with the same name in it.
Right click on the project (not solution)
choose Add->Existing Item
and select your files, (you can copy them to the opened folder and then choose them)
press Add
Now you can try to compile.

How do you create the "Shader" folder in Visual Studio interface

I have seen several projects with the "Shader" folder in the Solution Explorer.
However, when I create one myself, I can only see "Header files", "Source files", "Resource files", and "External dependencies" folder.
Is there a way to tell Visual Studio I need a "Shader" folder because I'm going to use shaders?
If not, how can I create it manually?
Visual Studio has virtual folders called "Filters". These can map to real folders in the file system or you can just use them to define logical/conceptual groups of items inside your projects.
To create a filter under a project in Visual Studio, just right-click with the mouse on your project in the Solution Explorer, expand "Add" and click "New Filter". A new filter ("NewFilter1") will be created under your project which you can then rename as you like.
You can drag items from your project inside it in order to group them "logically" or you can right-click on your new filter and choose Add>Existing Item or Add>New Item. You can even nest multiple filters inside each other.
For example in your case, you would call this filter "Shader" and you can drag-and-drop all shader-related files inside it. This only affects your project and not the directory structure in the file system.
You can still create a "real" folder in the file system and then add files into it, which you can then reference in your project's filter.

Visual C++ 2010 Different configurations for multiple projects

I've got a solution with multiple projects.
Now every project has its own configuration and nearly all projects do even have multiple configurations.
When building the projects I want that all configurations that do exist are built. Is there a way to do this automatically without picking every configurations by hand and start the building process over and over again?
To do it by hand in MSVC GUI you can do the following:
1. Right-click on the solution, in the popup menu go to the menu item "Batch build..."
2. In the dialog that will appear, do "Select all" or just select the projects/configurations you need.
3. Click button "Build" (or "Rebuild" if you prefer a clean build).
You could write an MSBuild or NAnt script (or even a plain old batch file) to compile all the configurations so you don't have to do it all by hand.

Move files in Visual Studio and AnkhSVN simultaneously

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.