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.
Related
I am using MapForce for the first time. I was able to successfully create an XML mapping. However, I am not sure how to run the generated code in Visual Studio, so that I can use it and see the output. I generated the code for the mapping in C# and did try to run the "Mapping" Project in VS.
Unfortunately, I am not able to due to few errors. There isn't a good documentation on the folders that are created in the project. If I can get a documentation link that I can refer to or if somebody can define why those folders are there and how can I use them/ how I should be running those projects.
Please correct me if I am wrong anywhere.
If you generated code to C:\MyFolder\, then you need to open in Visual Studio the solution C:\MyFolder\Mapping\Mapping.sln. Note that the "Mapping" is the default name, if you configured it to be something else from MapForce settings, then it may be different.
Solutions in other generated folders are supporting libraries, and you should never edit them (or at least do so at your own risk). The only file you can (but you don't normally need to) modify is called MappingConsole.cs. For example, you may want to change the paths of the mapping input/output files. In any case, after you build and run the solution, a Mapping.exe application is created in the Bin\Debug folder.
It would have been helpful if you indicated which errors you get. Perhaps the paths to the mapping input files cannot be resolved relative to the Mapping.exe application?
I have a Text Box in MSI Project and I want to validate whether it is Filled or Empty
if empty next button has to be in disable state else it has to continue.how to do this
Thanks in Advance
Windows Installer has a table called the ControlCondition table. Using this table you can create conditions that Enable, Disable, Hide and/or Show a control. However, the tool you are using doesn't expose this underlying feature of Windows Installer. This is one of the many, many reasons Visual Studio Deployment Projects were removed from Visual Studio 2010.
There are hack ways of using postbuild events to run SQL commands against the built MSI to inject the functionality but I don't recommend this. It's like tweaking the MSIL of a built assembly because C# didn't support something that CLR could do.
just google orca table editor and download this tool using this you can view the database that #Christopher is talking about. You can do this by right clicking on the MSI that is generated after building your project and open with the Orca editor you will be given access to the entire database and please make sure you change the table mentioned by Christopher care fully as there is little or no validation when you make changes to this table.
I am trying to create an MSI installer/uninstaller for my Windows project, consisting of a service, a couple of user-mode exes/dlls and some data files. I was able to use Visual Studio 2010 to compile an MSI package using its Setup Project. It works fine for installation, but uninstallation requires some additional steps before files are actually removed along with the registry settings.
So I was wondering, is there any way I can run a script (C#, or WSH JScript) before removing files/registry settings?
Yes, you can add as well scripts (VBS or JScript) to an MSI as C# or C++ custom actions in compiled MSI enabled Dlls, you can call .exe files, etc. There is a table called CustomAction and the Custom actions can be sequenced with the sequence tables, the most important are InstallExecuteSequence and InstallUISequence.
Working with custom actions is not so an easy task I think. If it is possible for you to ask experts, I would consider it.
Most times, when you want to add a custom action for uninstalling resources, there is maybe something wrong with your MSI.
4 of 5 custom actions one wants to add, are not necessary but can be replaced with correct MSI table entries.
Generally, I don't recommend using Visual Studio installer, because it gives you not very much control, and it is easy to make things wrong, especially for upgrading and more complicated task.
But if you still want to add a custom action here is some basic idea:
For example for starting a VB script you can add a custom action of type 38. Choose a name in the "Action" column, let the "Source" columns empty, and type the VB script code in the "Target" column:
E.g. with something like that you have an VB "interface" to the MSI properties like the newly invented "MYDIR_EXISTS" here.
on Error Resume Next
set filobj = Createobject( "Scripting.FileSystemObject" )
If filobj.FolderExists("C:\MyDir") Then Session.Property("MYDIR_EXISTS") = "True"
...
If you work with Visual Studio Installer you could consider adding the custom actions with a transform afterwards. Again this needs some MSI knowledge.
Me, personally, I would not work with script files for distributed setups, only if the setup is an infrastructural one for the same company. But it is a starting point.
Calling an compiled .exe with Custom Action type 34 or 50 would be an alternative.
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.