Background:
I have an visual studio C++ custom project template to create a custom solution. When we say new project and select this custom template, it would ask for an xml file and create a visual c++ solution, substituting values from the xml file to the template files.
What am trying to do now?
I wanted to automate this process, (no user intervention to open visual studio and select the custom template). Infact to use the component in C#. This component has a dependency with visual studio wizard as shown in sample javascript
Difficulties faced?
The xml parser is a com component, which takes visual studio wizard as a parameter. Only if i set this properly, i can proceed further. The wizard is basically implements the below interface.
http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.vswizard.ivcwizctlui_members(v=VS.90).aspx
Not sure how to access this wizard in C#.
Current Javascript code:
var aConverter = new ActiveXObject("NAMESPACE.MYParser");
//Problem: Not sure how to set this value, when "NAMESPACE.MYParser" used in C#
aConverter.Wizard = window.external;
aConverter.Filename = xmlfile;
//This method if called from C# without setting "aConverter.Wizard" throws exception
aConverter.ParseMyXML();
var value = aConverter.Someproperty;
Prior research:
I tried to use dte.LaunchWizard, but still i get an UI popped up, which i need to avoid. LaunchWizard not a good way for me, as i wanted direct control in C# for "NAMESPACE.MYParser"
It may be not exactly the same direction as you want to go, but have you considered using CMake(open source) for that?
CMake is a tool for automatically setting up code-projects/toolsets on different plattforms and IDEs. CMake can also generate VisualStudio solutions, so all you would have to do is set up your CMake config files, and just generate the solution. You can also incorporate parameters, so that the user is able to costumize the project to be generated even further.
It is a great tool, runs on most platforms and there is also an easy to use GUI available. Check it out: http://www.cmake.org/
Related
Im currently writing some very small c# exercises, for a algorithm course.
visual studio is my favourite IDE, and usually, when i create or clone a visual studio project, I get the full functionality of viusal studio including spellchecking and suggestions for fields and methods on objects and so on.
But right now I am just trying to open a single .csc file and write some code in it. The problem is that when i do that, i get no suggestions. So if I create a list I would usually be able to view all the methods and fields inside the list class simply be referencing an object. Syntaxm checking works fine.
How do I turn on intellisense suggestions in a file that is not in a project?
Thank you
The simplest way is simply to add that file to a project.
Open VisualStudio.
Create a new project (you can probably use Console project or Class library, depending on what you're doing).
Add your file in that project.
Make sure your file as the Build Action C# Compiler.
And that should work.
Background
I'm using EntityFramework DB first and SQL server in my project. My tables have primary key columns with different names like PersonID, AccountID, AccountMemberID, etc. however, in my POCO classes, I wanted this to be represented as a property defined by an interface named just "ID" in all classes. In the designer, you can easily just rename the column on the entity, but this is tedious if you have 100+ tables to rename and also error-prone.
Question
So I built a console app that reads an .edmx file and renames all of the primary key properties to "ID". What I want now is a way to make this easy to run from within Visual Studio. I could just include the console app in source control and then have the developer open the directory where it is and run it, but I'm trying to make it less easy to forget to run it. s there a way to kick it of from within Visual Studio? It would be easiest if it were to run every time the .edmx was saved, but I'd be happy with a few clicks within Visual Studio to run it. I don't know if this could be a custom tool, or a plugin, or extension, or command...can someone tell me where to get started?
Edit: I would also like it to be able to give feedback. Currently, as a console app, it prints out which entities were modified or any errors encountered. Also, it doesn't have to be a console app. I just want to keep my C# code if possible.
It sounds like you want to make use of the Task Runner in Visual Studio. Take a look at the blog Task runners in Visual Studio 2015 (I know you said you are using 2015, but the feature is also in 2017).
I've done something similar where I had tasks written in Cake Build generate SQL files from C# code. I then hooked up a before build task that generate new SQL files based on any changes the developer did to the C# code. This allowed us to validate a change very quickly before hitting commit and helped to reduce developer mistakes.
I want to make a visual studio's add in that has the ability to sort resource files alphabetically every time someone edits a resource file. I'm not looking for a solution, but I have never used the Visual Studio sdk before. I simple want to know if anyone that has experience with the Visual Studio sdk may know if this is possible? Also any suggestions on how to start making an addin are appreciated.
If you have never used visual studio extensibility, I recommend you this page:
Make a solution notebook tool window
There is some useful information about how to interact with visual studio for saving data in sln and suo files, and also you can find information about some attributes you can use to tell visual studio what your package (or plugin) needs to do.
It's a general knowledge thing although, not directly related to what you want to do.
this link is about how to listen to some specific events visual studio fires, it shows you general way of creating listeners in your plugin
this one is actually about what you need to do (it tells you how to catch the event fired before visual studio saves a file)
and the most important one: the source code for creating a custom source control for visual studio, that's where I found most of the info I needed to understand visual studio extensibility
with all these links you should get something to start with, and of course you have the official msdn documentation about extending visual studio
What you'll need to do is creating a plugin that will listen to events fired when an item is about to be saved in visual studio. I don't think there is a specific event for resx files, so you'll probably have to test which file is saved, but that should be all.
Once you have the item, you can find the physical file and sort it.
Another thing, I found out that the events declared in the DTE object don't really work (at least for me it didn't), that's why I recommend you to implement the listener pattern to catch the events you need.
Hope this helps
I actually did exactly that.
You can find the source code for the extension in GitHub. It shows you how the get handles for files from the Solution Explorer, add context menu actions, write to the output menu, etc..
I am in the process of creating a Wizard to help my organization auto create a base project for all applications. The idea is that a programmer can enter a project name, a few other basics and the process will create some projects, add other project from source control, configure IIS, etc...
A lot of the work is done by simply using project templates and the IWizard interface for some of the more complicated operations. What I am trying to do is this, once all of the projects are auto created, I am creating a workspace and automatically moving all of the files under source control. I am also doing things like adding common projects, setting up some special settings in IIS, etc... The problem is that the solution file, although it is under source control, is not actually configured to use source control.
Anyone have an idea on how to programmatically configure a solution so that it is part of source control and ready to use? I've run into a brick wall and can't seem to get any further. BTW: In case a didn't make it clear, I'm essentially trying to do the same in code as right clicking on a project and selecting "Add Solution to Source Control."
Like I've said, I've got most of the issues solved. Just this last one is giving me fits...
The important facts:
Windows XP
VS 2008
TFS
Using Microsoft.TeamFoundation objects....
Can you handle this through the Visual Studio extensibility framework? EnvDTE basically provides access to anything you can do interactively...
I just did what you said while recording a Macro; Looks like:
DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate()
DTE.ActiveWindow.Object.GetItem("CLSTestSolution").Select(vsUISelectionType.vsUISelectionTypeSelect)
DTE.ExecuteCommand("File.TfsAddSolutionToSourceControl")
Perhaps you can start there?
What we ideally need is, to know how Microsoft handles XAML generated code (Those *.g.cs files). If you goto a XAML code behind, intellisense will work even if the *.g.cs file is not part of the project!!
Context:
In a custom VS package, we need to have some logic to open a CS file (with out making it a part of the project) in the VS IDE, to allow the user to edit it.
We are hooking up the document to the Running document table and receiving the events like Saving, Close and all, using IVSRunningDocumentTable. Works good.
Now the problem is, when the document is opened, Intellisense can't work, for the simple reason that the opened document is not part of the project (sadly, we can't do that, we can't make it code behind).
Intellisense is driven by a memory cache of identifiers and types. These types are cached based on the project you are in and the references that project has. If the code file you are editing is not part of a project, Visual Studio would have to load every possible assembly and create intellisense data for each type in the entire .NET framework because it would have no way of knowing whether or not your code file required it.
I guess Visual Studio could load intellisense based on the content of the file but that is not the way it currently works.
Visual Assist X by Whole Tomato is an addin to VS I've been using for many years. It will give you Intellisense and more when you open it.