Is there an on solution open event in visual studio? Something similar to the Pre/Post build events for projects, but instead only fires when the solution opens. I would like to add a command to run when the solution opens, but can't seem to find anything that will allow me to do that.
Related
I don't know what happens with my Visual Studio 2022. When I create a C++ console project, I can build the project. However, when I do the same thing for C# project, I can not build the project. I look like in the picture. Any help is truly appreciated.
I tried everything I can but it didn't work.
That sounds like a bug. When a new project is created, it should appear in Solution Explorer. However your solution has no projects, and the source file appears in "Miscellaneous Files" (meaning it's not part of a project, and therefore VS won't know how to build it).
Please use the Visual Studio Installer to run a repair on your VS installation. If that doesn't help, use Help | Send feedback | Report a problem and include a recording of the steps you're taking to create a new project. If you link the feedback ticket here, I can make sure it gets looked at by the right people. Thanks.
You need to create a new Console App for creating and running C#
projects
Press F5, choose Debug > Start with debugging from the Visual Studio
menu, or select the green Start arrow and project name on the Visual
Studio toolbar. Or, to run without debugging, press Ctrl+F5 or choose
Debug > Start without debugging from the Visual Studio menu.
When working with Unity in Visual Studio, my solution gets often changed from an external source. When Visual Studio realizes that my solution has been changed it asks if I want to reload my solution or not. In my case, I always want to reload it.
Is there a way to skip the dialog box that presents various options and simply always have it reload the solution?
EDIT: I'm using Visual Studio 2015/2017
This is what you are looking for :
Tools > Options > Environment > Documents > Detect when a file is changed outside the environment > Reload Modified files.....
For Visual Studio 2017 :
A thought occurs. Have your external script that modifies the solution, use the Visual Studio automation model to close the solution, then make your updates, and then re-open the solution?
You could write a Visual Studio extension that adds a menu command to the IDE to invoke your script, unless it's automatic, and then simply choose the command from the menus to invoke your script, wait for it to finish, reloading your solution in the process, and then you're there.
When using ReSharper in Visual Studio, I often cannot run the "code cleanup" option, as it is grayed out in the menu. I have also tried using the hotkey but I get the error message: The key combination (Ctrl+E, C) is bound to command (ReSharper_CleanupCode) which is not currently available.
I've done a lot of research about it online and found that often the reason this option is not allowed is that the file I am working on has not been added to the solution explorer.
If I add the JavaScript file I'm working on to the solution explorer, it then allows me to code cleanup, but this is EXTREMELY inconvenient for me; I open many files in my work and I do not want to make a new project/solution, then manually add the file each time to use this ReSharper feature. (also by adding files to the solution explorer, the files stop saving and I have to manually copy/paste the code from them into the original document when I'm done working with them.)
Is there a setting in ReSharper that I can change to allow me to code cleanup my currently selected file under all circumstances without needing to add it to the solution manual first?
If not, is there a way to configure or utilize Visual Studio 2015 in such a way that allows me to easily add JavaScript/CSS/HTML files to Visual Studio and also to the solution explorer when I don't have a solution/project already created and loaded? (and also actually save the file when I'm done working on it to where I dragged/dropped it from, rather than embedded in a solution file (.sln)?) (Currently, Visual Studio DOES save files with CTRL + S, but ONLY if it has not been added to a solution/project. It's currently how I'm editing all of my files.)
I realize this is quite old, but I encountered this in VS2017 with Resharper 2018.1.2.
The only "workaround" I found was to Suspend Resharper, then Resume it.
Tools -> Options -> Resharper Ultimate -> General -> Suspend Now
Then in the same menu
Resume Now.
I'm looking to have a particular running instance of Visual Studio open a file. Is there a way I can fake a drag-drop operation via code from my app to Visual Studio? Same as if I were to drag a file from Explorer into VS.
I realize I could probably do this easier as an add-in or macro but I'm looking to make this work purely from a script.
You could try sending a WM_DROPFILES message to the Visual Studio window.
I want VS2010 to ask me when I am closing the whole environment whether I am sure about closing VS2010 or not.
Unfortunately I couldn't find this setting anywhere
Anybody knows?
AFAIK, there is no such option. However, there is an old tool called NoClose that can disable the (X) button for you (see LifeHacker article about this tool)
Though I haven't used it under Windows 7/8, I'm not sure if it is compatible.
I haven't tried this in Visual Studio 2010, but you can achieve this in Visual Studio 2008 at least by using an Automation Macro. The instructions below work for 2008, and shouldn't be too hard to translate to 2010 (hopefully).
Open up the Macro IDE (Tools->Macros->MacroIDE), and in the list of Macros you should see an item EnvironmentEvents. Double-click this to get a module containing the existing Environment Event macros.
In the drop-down list select SolutionEvents, and then in the Declarations list select QueryCloseSolution. What we're doing is creating a macro that is run whenever you try to close a Solution. We'll create a messagebox to ask the user if they really want to do it, and optionally cancel the shutdown - you should end up with something like this:
Private Sub SolutionEvents_QueryCloseSolution(ByRef fCancel As Boolean) Handles SolutionEvents.QueryCloseSolution
If (MsgBox("Close the solution?", MsgBoxStyle.OkCancel) = MsgBoxResult.Cancel) Then fCancel = True
End Sub
Save the Macro project, and try closing the solution, or shutting down Visual Studio. If the stars are aligned you'll see a confirmation message box. If you click "Cancel", the solution won't close, and VS won't shut down.
Now, perhaps someone can confirm in the comments if this works for VS2010?