Workspace-specific includePath for Visual Studio Code - include

This question: Visual Studio Code includePath shows how to modify the global includePath for Visual Studio code to change the locations VSCode looks for header files. I want to change the includePath, but just for a single project, not all projects. Is there a way to make changes to the include path that only apply to a single project?

The c_cpp_properties.json file described in that question is in the .vscode folder in your workspace, so it is already project specific.
If you use the "Add include path to settings" feature the extension will create a c_cpp_properties.json file with the system default paths, but that is only to help you get started, it does not mean that is a global configuration.

Related

Change Xamarin Project Name in Templates

Is there a way to modify the project template to change how the Visual Studio Xamarin (Shared PCL) Project Templates names the default project names? For example, in VS,
File->New Project->Cross-Platform->Blank App (Xamarin.Forms Portable)
will create the following projects:
{SolutionName}
+ {AppName}
+ {AppName}.Droid
+ {AppName}.iOS
The physical file paths are the same as the solution/project structure. I'm wondering if it's possible to change the default names of the projects and folder for the physical files.
I've tried looking for the project templates in /common7/ide/projecttemplates, but I don't see anything relevant.
You can find the templates here:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Xamarin\Xamarin
Note: This is a path for VS 2015. You would need to go to the respective path version of VS.
In which you can select the latest version you have downloaded. i.e. 4.2.0.719
Inside you can then go to the T\PT\CSharp\Cross-Platform folder and find the template you're after.
Keep in mind that they might not be located here if you have older versions installed. They might actually be referenced in your earliest version.
EX:
4.1.2.18\T\~PC\PT\Cross-Platform\Xamarin.Forms.PCL.zip
Once inside this folder, you can edit the .vstemplate however you'd like for each project.
This is never-ending story. I suggest extract the project template change what you need and repackage as your custom template. This was for me the best method so far (last 6+ years).
So:
locate the template
unzip it into a folder
edit template
repackage (zip)
redeploy (install/copy)
My recommendation into place for custom templates
Otherwise it will eventually be overwritten.
rebuild template cache
devenv /installvstemplates
Mine are in:
"%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Xamarin\Xamarin\4.2.0.695\T\PT\CSharp"

How can I change the default build output directory in Visual Studio?

In Visual Studio 2010 through 2013, by default (eg. When I create a new Console Application) new solutions output their compiled executable into Solution name/Project name/bin/Debug/. I want them to be output into Solution name/Debug/, and likewise for all other build configurations like "Release".
I can do this by manually going into properties of each project, going to the Build tab, changing Output path from bin\Debug to ..\Debug. I must repeat this for every project and every build configuration.
After dozens of solutions, I'm a bit sick of doing this tedious task by hand every time. Is there a way to change the default output path?
A solution that works for Visual Studio 2013 is sufficient.
This property is defined in each Visual Studio Project Template
So, for example, the C# Console Application template is located in
\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ProjectTemplates\CSharp\Windows\1033\ConsoleApplication\consoleapplication.csproj
The csproj is an XML file that you can edit at your will. The build output directory is define like this (for each configuration):
...
<OutputPath>bin\Debug\</OutputPath>
...
<OutputPath>bin\Release\</OutputPath>
...
If you change this file, it will change all your future new C# Console Application projects. You could also write a utility program that list all csproj in \Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ProjectTemplates and update them accordingly.
This is not necessary.
One of the projects in your solution is marked as the Startup project, shown in bold in the Solution Explorer window. An EXE project, like your console mode app. You used Project + Add Reference to add references to other projects in the solution so you can use the class libraries that those projects generate in your console mode app.
Those references will have the Copy Local property set to True.
When you build your project, MSBuild will automatically copy the assemblies from their respective bin\Debug directory into the bin\Debug directory of your console mode app, thanks to that Copy Local setting. And it is smart enough to also look at the dependencies of those class libraries and copy them as well.
So after the build is complete, the bin\Debug directory won't just have your console mode project's EXE file but also all the DLLs it needs to execute properly.
There are a few ways that this can go wrong and MSBuild cannot figure out that such a dependency actually exists. Pretty uncommon, you'd for example have to use Reflection in your code to load assemblies (Assembly.Load() and friends). The workaround for that is to explicitly copy the dependency in a post-build event. You didn't leave enough bread-crumbs in your question to judge whether that's the real problem.
What you ask for is certainly possible, the IDE just doesn't make it easy because it wasn't designed to assume this was necessary at all. You'd have to replace the Build + Output Path setting to, say, ..\Debug instead. You can create your own project template with that setting already preset. Create a new class library project, change the setting and use File + Export Template to create the template. You'll have it available the next time you create a project.
But, really, find out first why the default Copy Local machinery isn't working for you.
Rather than changing a global, protected file, you can create your own .targets file that changes the <OutputPath> however you want and import that into your projects. This could also set other defaults you might want to change and don't want to do for every project. All you'd have to do then in your project files is add something like toward the top (after the root element, of course):
<Import Project="$(SolutionDir)\Common.targets"/>

Setting up environment variables in Visual Studio 2010

How can we set up the PATH environment variable in Visual Studio 2010 for the entire solution/project?
When I want to refer to a reference .dll, it has worked for me to set up a Solution Explorer level folder, and add the DLL file to that folder. Then in the filesystem, I add a matching folder (since the Solution folder is logical and not a real folder) at the solution level. There I put the physical DLL file, and if you are using source control, check-in that directory.
Once that's all done, for any project that needs to reference that DLL file, I can browse to it on the Solution level, add the reference, and make sure that the properties are set to 'Copy Local,' so that the DLL file shows in the appropriate /bin folder.
I would try something like that to get your dependencies better organized.

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

Sharing visual studio macros with team members

Is it possible to add visual studio macros to a solution, so they would be checked in by svn ?
If not, how do you deploy your utilities/scripts with your developer team ?
Unless I'm mistaken, VS Macros are stored in a .vsmacros file as selected when you created the Macro project (I think the default location is C:\Users\yourname\Documents\Visual Studio 2010\Projects\VSMacros80), so just copy that file to your project's directory and add it to the project with no build action and you should be all set.
But that's just if you want to use those macros only with that project, most macros are useful in many projects and if so I'd recommend keeping them where they are rather than in the folder of just one project, and then just add the .vsmacros file manually to subversion to some suitable location (suggestion would be a Tools folder) and check in and out manually when needed.

Resources