Programmatically getting solution details - visual-studio

Is there a a way to get the processor type, build type, etc, from a Visual Studio solution, via C#?

There is something called ConfigurationManager which takes care of the build type and other details.

Create a Visual Studio Addin (A Project Template is available in Visual Studio in the Extensibility Category) and access your current Solution Configuration with the ActionConfiguration Property from DTE.Solution. See this for further details:

Related

Where Visual Studio Extnesions DialogPage are stored?

I'm developing a Visual Studio extension for Visual Studio 2017. In my extension, I have a class inheriting DialogPage to allow the user to define parameters.
I want to see exactly what gets serialized when settings are changed.
According to Options and Options Pages article in MSDN the data should be stored in the registry but I couldn't find it.
Where are the settings are stored for Visual Studio options page?
According to following blog, VS2017 support multiple instances of VS install on the same machine. So the settings were moved out of the registry. Each instance also has its own private registry so they can be configured independently.
https://blogs.msdn.microsoft.com/heaths/2016/09/15/changes-to-visual-studio-15-setup/
You could find the private registry for your Visual Studio 2017 from C:\Users\UserName\AppData\Local\Microsoft\VisualStudio\15.0_XXXExp ("XXX "could be any numbers, just find the folder suffix is "Exp").
And you could open this settings file with regedit.exe. Detailed steps, please refer to:
http://www.visualstudioextensibility.com/2016/11/23/some-implications-of-the-new-modular-setup-of-visual-studio-2017-for-vsx-developers/

Automatically run extension code in Visual Studio on startup

Can I create an extension for Visual Studio that runs in the background as soon as the user opens the Visual Studio IDE? For example, I am building an extension that gets the current active file address in Visual Studio (with C#), but I would like this extension to always run in the background without having to be activated by the user clicking a button or pressing some key combination.
Is this possible, and if so, what is the best way of doing it?
Any help would be greatly appreciated! Regards, Erfan
Since you tagged your question with visual-studio-2010 I assume you are working on an "Add-in" rather than a "VSPackage Extensions".
In this case, you can use the OnConnection event handler.
If you are working on a VSPackage Extensions, you can use the attribute ProvideAutoLoad.
Just search for these, you will find sufficient information. Both ways are also described shortly here under "How can I run my add-in code in a VSPackage?"
For Extension add following attribute to Package class, this will load the extension when a solution is not open in visual studio. I have tested this with VS 2015 and 2017.
[ProvideAutoLoad(UIContextGuids80.NoSolution)]
For VS 2010 and higher the recommended extensibility approach is a package (VS 2015 won't allow add-ins).
To get the package loaded when Visual Studio is loaded see HOWTO: Autoload a Visual Studio package.
Once loaded, your package may be interested in two different kind of selection change events:
To get notified when the selection in the Solution Explorer changes, get the IVsMonitorSelection interface and call the AdviseSelectionEvents/UnadviseSelectionEvents and provide a class that implements the IVsSelectionEvents interface.
To get notified when the active window changes (which can be a document window or a toolwindow), implement the IVsWindowFrameNotify interface.

How to create SharePoint 2010's site column through Visual Studio 2010?

I was trying to create lists, content type and site columns through Visual Studio 2010. There were options of adding content type and list instance but not of content type. So, I could not figure out how to add site column? What item do I need to add for this and what kind of coding is to be done for the same?
this resources may help you:
Walkthrough: Create a Site Column, Content Type, and List for SharePoint => http://msdn.microsoft.com/en-us/library/ee231593.aspx
You may also try SharePoint Designer 2010 instead of Visual Studio 2010
You can use CAML but I wouldn't recommend it. The better way is using object model and feature event receiver. An complete example is quite long, here is the link http://zhouyupublic.blogspot.co.uk/2012/11/create-site-column-and-content-type.html.My
My recent favorite way to do the same is using PowerShell. But since you ask about how to do it with VS, it is outside the topic here.

Visual studio autoexp.dat alternative?

Custom debug visualization in visual studio:
Is there any way to do it per project instead of editing the "global" autoexp.dat?
Would be nice if it tagged along when changing workstation..
No: per-project (or per-user) visualizers in Visual Studio 2010 (C++ native) are not possible. Visual Studio 2012 added this feature; it is based on "natvis" XML files.
Rather old question, but lets give my cent:
For VS2008 SP1 and VS2010 you have the alternative to use your custom file, instead of invasively edit the native autoexp.dat file using the _vcee_autoexp environment variable.
Credit to: https://vtk.org/Wiki/ITK/Debug_Visualizers_for_Visual_Studio
Note: I have not tried, but maybe using a relative path VS loads it based on the solution folder. Alternatively I would also try using multiple path separated with semicolons. Just give it a try.

Visual Studio extensibility (add-in): How to access Silverlight-related properties?

This is the question that has been posted to MSDN forums some time ago, and stayed unanswered to this day:
http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/676b13d4-acfc-4252-b102-5fc0553e4b81/
The property I'm interested in is ProjOutputReferences, stored in the Visual Studio solution (.sln) file.
In Visual Studio, this property is accessible through Property Pages dialog of a Silverlight WebSite project (requires that you have Silverlight Tools for VS2008 installed). There, there is a page called "Silverlight Applications" on which the content of the above mentioned property can be edited.
I need to access it programmatically inside my add-in, through VS automation or low-level interface(s).
In the latest released version of the Silverlight Tools for VS 2008 SP1, the list is persisted in the SilverlightApplicationList property in the referring project file.
For example, I have SilverlightApplication2 and SilverlightApplication2.Web in my solution (the latter references the former). I have the following node in my SilverlightApplication2.Web.csproj file:
<SilverlightApplicationList>{BBA7B148-42AE-477E-BB5E-0BA5AEC0A467}|..\SilverlightApplication2\SilverlightApplication2.csproj|ClientBin|False</SilverlightApplicationList>
There really isn’t a way to access this property via purely DTE, but you can use the Visual Studio SDK / VSIP interfaces to do so (specifically, you want to get the IVsBuildPropertyStorage interface for access to MSBuild properties). Here is a code snippet (runs in a menu command handler in a VSPackage):
IVsSolution solution = GetService(typeof(SVsSolution)) as IVsSolution;
IVsHierarchy hierarchy;
solution.GetProjectOfUniqueName(#"SilverlightApplication2.Web\SilverlightApplication2.Web.csproj", out hierarchy);
IVsBuildPropertyStorage buildPropertyStorage = hierarchy as IVsBuildPropertyStorage;
if (buildPropertyStorage != null)
{
string silverlightAppListValue;
buildPropertyStorage.GetPropertyValue("SilverlightApplicationList", "Debug", (uint)_PersistStorageType.PST_PROJECT_FILE, out silverlightAppListValue);
MessageBox.Show(silverlightAppListValue);
}
If you still want to try doing this from an Addin, you’ll have to get follow the approach that Craig mentions to cast the DTE object to an IServiceProvider (so you can call GetService).
-Aaron Marten
Since .sln files are just text files, try editing your .sln file using Notepad. You should be able to find the property you are looking for listed there. Assuming the information is in an understandable format, you should then be able to use a simple text parser to extract the info from the .sln programmatically.

Resources