Visual Studio IPC API : Accessing and modifying projects from outside - c++

I'm currently working to extend some of our own tools (external from VS) to support communication with Visual Studio, to generate and add new code files to existing projects, and preferably also ask a visual studio instance for the currently open solution file to find the right process to talk to.
Right now the only way for me to do this is to directly access the project XML file, and add the files on my own, and then tell windows to open my new file, and hope it get opened in the right visual studio instance... and visual studio will most likely ask me if I want to reload the changes in the project file.
This feels like a very brute force and roundabout way to do it, so I suspect there might be some better way, but all my searched have given me no results. It might be because all searches for IPC and Visual Studio just gives me results with others working with IPC related stuff in visual studio, and all I can find about visual studios API is team oriented or for extensions. If anyone could directly me in the right direction to find more info about this, or anything similar, it would be great!
(if easily doable from C++ is a plus, but if I need to wrap a DLL or use other scripts it's okay as well)
Thanks!

Related

In Visual Studio, can you add a folder-based project in a solution?

Visual Studio finally has the ability to open folder-only projects, which makes it great for simple web sites that serve from the file system, etc. However, I can't find a way to add one of these projects to my existing solution. Whenever I try opening it, it tells me to close it.
So, how can you add a folder-based project to Visual Studio solution? Or can you?

Autoexp.dat Versions

I'm working on a project where I need switch between a couple of different (incompatible) autoexp.dat files. Currently, that involves closing all instances of Visual Studio, copying the file I want to the new location, and then opening Visual Studio again. Is there a better way to do this? Maybe a command line option to specify the location of autoexp.dat? Ideally, I'd like to be able to run two instances of Visual Studio at the same time, with each using a different autoexp.dat file.
Have you tried doing what you suggest? I know there is a way to make it a plugin to visual studio, as mentioned Here. Perhaps you could modify this setup to dynamically load the autoexp.dat file you want to use?

How visual studio intellisense recognize functions and properties in classes even though there is no reflection in C++?

I want to list properties and functions present in c++ classes. Is that functionality already implemented in any library ? Does visual studio intellisense use any library ? Is that library available publicly from Microsoft?
Visual Studio parses your code, so that's how it knows. You would need to do the same.
The Visual C++ team maintains a blog that has had several very nice articles about how IntelliSense has worked in the past and how it will work in the future:
IntelliSense History, Part 1
IntelliSense, Part 2 (The Future)
Visual C++ Code Model
Rebuilding Intellisense
Visual C++ Code Model in Visual Studio 2010
Essentially they build their own 'reflection' database (the .ncb file in current and past version sof VS, using a compact SQL database starting with VS2010) by parsing the headers and other source files - using both custom parsers and parsing that's done with the cooperation of the compiler.
Apparently at least some of that information is available in the VCCodeModel and related interfaces that the Visual Studio extensibility model provides. I have no idea how well the extensibility model works or how easy it is to use.
They use a propriety format to store intellisense information (they are saved as NCB files). You can delete these files to force VS to recreate its intellisense database if things go wrong.
They then scan header files for class information as well as dependencies, then build the NCB file for future reference.
No, this library is not available for personal use.
Intellisense in C# is lots better than the one in C++
VS2010 will see C++ have the same intellisense features as C# currently enjoys.
I would imagine that Visual Studio uses the header files to provide Intellisense.

Cygwin in Visual Studio

I'm trying to port an old program I wrote for class from KDev in Ubuntu to Windows Visual Studio 2008 using Cygwin as a personal learning exercise. I have the include path configured to include C:\cygwin\usr\include but it doesn't read the .h files properly.
Namely I'm curious as to how one would go about using unix sockets.h functionality in a Visual Studio environment using Cygwin. Has anybody ever got this working or have an easier way to go about doing this?
There are several ways to go about this that could be made to work, depending upon your exact goals. The simplest way is probably just to create a Visual Studio "makefile" project that fires off a custom build command to run a makefile you've built. But that keeps you away from a lot of the nice benefits of Visual Studio as an IDE, so I'm guessing that's not really what you're after.
If you want a more fully integrated solution, you're going to need to do two things. First of all, you're going to need to change out all of your include/library paths to avoid the Microsoft ones and go after the Cygwin ones instead. You can do this by selecting "Tools->Options" from the menu, then choosing "Projects and Solutions->VC++ Directories" from the tree on the left hand side of the window that comes up. You'll have options to change the search directories for executables, headers, libraries, etc. For what you're trying to do, I'd suggest removing everything and adding in just the cygwin directories.
Second, you'll have to tell Visual Studio to use the gcc/g++ compiler. This is a bit trickier. VS supports custom build rules for custom file types... but it seems to have C++ hardwired in for the Microsoft compiler. I don't really know a great way around that except to use your own custom file extension. You can try the standard unix extensions of .c (C files) and .cc (C++ files), but I suspect Visual Studio will automatically pick up on those. You may have to go with something totally foreign.
If you right click on your project in the Solution Explorer and select "Custom Build Rules" you'll be given an interface that will let you create your custom build rules for the file extension you've chosen. The interface is relatively straightforward from there.
This might not get you exactly what you wanted, but it's probably about as close as you're going to get with Visual Studio.
Simply speaking, don't do that. It would be just waste of time. I tried it several times, but always failed. Mostly, I was frustrated by many linking errors, and also was unable to use VS as a debugger.
You can use Visual Studio for editing and browsing source code. It is nice because VS provides the best C/C++ intellisense features (e.g., Auto completion, fast go to definition/declaration). But, it is very hard to use cygwin tool chains with Visual Studio 2008. Visual Studio 2008 is not designed to work with other tool chains. Specifically, you need to change (1) headers, (2) libraries, (3) compiler and (4) linker. However, it is generally very hard, or you need to trade off with the nice features of Visual Studio.
The strongest feature of Visual Studio is its debugging ability such as fully integrated debugging environment and very easy watch windows (e.g., you can see STL vector's element directly in watch windows). However, you can't do this if you would change fundamental tool chain (although I am very suspicious it is even possible to safely build with Visual Studio and cygwin tool chains).
Unfortunately, current Visual Studio 2008 is not for cygwin/MinGW.
This is an old question, but since it comes up first (for SO) on a Google search I wanted to share that it looks like the latest Visual Studio versions do support this.
For instructions, refer to this blog post:
https://blogs.msdn.microsoft.com/vcblog/2017/07/19/using-mingw-and-cygwin-with-visual-cpp-and-open-folder/

Visual Studio: Intellisense Problems and Linux Compatibility

Two somewhat unrelated questions:
Sometimes when I am working on a C++ project in Visual Studio 2008 Express, intellisense just does not want to "work" even though it really should. Auto completion box does not show and status bar says something along the lines of: "Intellisense: No further information is available".
Sometimes it can be fixed by either rebuilding the solution or re-opening the solution, and sometimes even that doesn't work. Is this a known problem? If so: are there any known fixes?
Is there any C++ IDE for Linux that has compatibility with MSVC++'s .sln files? I sometimes want to work on some project without having to go through the hassle of creating a new project and adding the files or manually creating a Make file.
edit:
To answer my own questions:
Apparently there's no real fix other than to try and delete the .ncb file. Alternative would be a different IDE or to use a commercial package replacing intellisense.
Code::Blocks seems to be able to open Visual Studio files. Or at least import them easily.
I posted these together as they both related to visual studio and I didn't deem them important enough to both deserve their own topic.
Do think the downvote is a little harsh though!
Intellisense failing is usually because of a "corrupt" ncb file. The usual solution is to delete it.
Reportly the next version VS 2010 will not be using ncb files anymore.
I've actually had some luckk opening .sln files using Monodevelop.
To avoid creating the Make files by hand try CMake
To answer your second question, there is no way to open .sln files in anything other than Visual Studio. They're a proprietary file type that (it seems) no one has any interest in writing a parser for.
You can however use Visual Studio to generate a makefile automatically. Just use the "Projects > Export Makefile" menu command in Visual Studio.