Change where Visual Studio looks for project file? - visual-studio

Is there a way to change where visual studio looks for project files(.vcxproj)? So I can keep all visual studio related files in separate VS folder and have my project still open and save correctly in visual studio.

I figured it out. I can open up visual studio's solution file (.sln) in notepad and edit the path to the project file there. It's can be done on this line:
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Solution", "Project/Project.vcxproj", "{E3671A4E-1047-4D41-8AF1-EA19EAC2C601}"
So right now the .sln file is looking for the project file within 'Project/'. All I have to do is change the path here in relation to the solution file.

Related

Building a Folder in Visual Studio

I'm working in Visual Studio 2017. I wanted to open a folder of files, so I clicked File -----> Open ------> Folder and selected the folder containing all my files.
When I view the Solution Explorer, I can see all of my programming files. However, I am unable to build my project and run it. Is there any way to build and run a folder in Visual Studio? I've tried selecting the .cpp file that I wanted to build specifically, but there's still no build/debug option.
In fact, under the Debug menu, the F5 Start option is grayed out. Any solutions?
I think you have to create a Visual Studio project first, and then add those files to the project. What you are doing right now is just using VS as an editor and viewer.

How do I manage Visual Studio file dependencies without editing the project file?

Whenever we want to make files in Visual Studio depend on another file, we have to edit the .csproj file and place the file in a <DependentUpon> element. Is there an extension or hidden feature that allows this to be done from within Visual Studio without editing the project file and reloading the project?
You have to edit the .csproj file to set up the dependency.
If you do this from within Visual Studio this will cause the project to be reloaded.
If you want to avoid reloads then you could edit the file outside Visual Studio (it's just xml) and then load it, but you would have to get the syntax correct. It's far simpler to let Visual Studio do its thing.

Visual Studio EnvDTE - Open project folder in file explorer

When you right click a project in visual studio, there is an option "Open folder in File Explorer". How can the same be done from the automation model (EnvDTE) of visual studio? I thought I could use Project.FullName but that didn't work for our auto generated project files that have the .vcxproj file in a different folder than the actual .cpp files.
You can use
Project.Properties.Item("FullPath").Value
to get the correct path.

How do I open a project without a .sln file in Visual Studio?

I was writing this program all in Vim and now I'm thinking of moving to Visual Studio, but since I didn't start in Visual Studio in the first place, there is no .sln file to open from. How should I open such a project in Visual Studio?
If you have a web project (without a .sln), you must do:
Menu File → Open → Web Site...
And choose the folder where the project is.
If a *.csproj file exists, you can build a new solution by Visual Studio at first. Next, you can open this *.csproj file in Visual Studio.
An even simpler way in Visual Studio is to follow this:
Menu File → New → Project from existing code
Choose the source file location and a .csproj and .sln file is created.
The simplest way to do this (assuming this is not a web project, as indicated in another answer) would most likely be to:
Create a new project (of the desired type), which should also create the solution for it to live within.
In the solution explorer, right click and select "Add > Existing item..."
Insert all individual files that belong in this new project.
It's probably also worth noting that it's a good idea to double check the project setting, namespaces, etc. before you get too far with building up your project to avoid potential issues later.

Automatically include all .cpp/.h files of a folder in a vcproj Project in Visual Studio

Is there a way to set a vcproj Project folder in order to automatically include all .cpp or .h files depending on the path of the project ?
On other words, when adding files to the folder of my project using Windows explorer, is it possible to have these new files automatically added to a vcproj Project, inside Visual Studio ? (even if I have to relaunch Visual Studio).
I do not need just to see them, but I need them to be automatically included inside the project for compiling and other operations...
The only way I see is to create a Visual Studio addin or a VB Script to do that...
Thanks,
Regards
You can edit project file and use wildcards. http://msdn.microsoft.com/en-us/library/ms171454%28v=VS.90%29.aspx

Resources