In Windows 10, can I set a default "Open with" application for docker files? - windows

Docker image files must be named Dockerfile with no extension. I typically edit these files using Visual Studio Code. Whenever I want to open one, I need to right click it and select Open With and then select Visual Studio Code from the list. For most files, which have a file extension, the Open With modal has a checkbox to remember the preferred application. Is there anyway to set a preferred application for files based on anything other than file extension, so that I could just double-click a Dockerfile to edit it?

You can use information from here to assign files with no extension to a default program, but it seems it will apply to ALL files with no extension (docker or not).

Related

How can my integraded terminal automatically cd into the directory of the currently active file?

I'm pretty new to Visual Studio Code and am used to a nice feature from my previous IDE. That feature had the integrated terminal follow the active file into its directory, at all times. So when I switched to viewing another file in my IDE, the integrated terminal would change its cwd to that new file's directory.
I'm aware of the Terminal Here Extension and the context menu option:
The problem with both is, that they require action on my part, i.e. using a shortcut or the context-menu respectively. I want the terminal to just change into the active file's directory, whenever I switch to another file.
How can I achieve this with Visual Studio Code?

Make Visual Studio Code open files in the already open project window?

I build my project on the terminal using make. When I encounter some compile errors, the output indicates in which files there is an error. I can Ctrl-click the file names to open them (a feature of iTerm). However, this makes Visual Studio Code open a new window with that single file, instead of navigating to that file in the already open project window. Is there a way to change this?
There is an option window.openFilesInNewWindow, but that only works for files opened within VS Code, not from Finder or other apps.
VSCode accepts -r or --reuse-window as a parameter to force opening a file in the active project window.
If you can configure your iTerm feature and add this parameter, it should work as expected.
Reference : https://code.visualstudio.com/docs/editor/codebasics

Visual Studio 2013 - Open .aspx and .cs files from other project at the current project

Probably it's a stupid question but i would like to open aspx and cs files from the windows explorer without opening a new instance of visual studio, is this possible?
Greets,
Firmino
There are several ways you can improve your experience opening files in VS.
You can use drag and drop
Troubleshooting: You can't drag and drop between apps in Windows if one of them is running with admin rights and another is not. Normally, you don't need either of Explorer or VS to run with admin privileges.
Visual studio running with no admin rights will most likely will be reused to open a file when you doubleclick in the Explorer (sometimes it still opens new instance with no sensible reason)
You can use File_Menu->Open->File (Ctrl+O). This will basically open an Explorer instance for you.
You can use File_Menu->Recent files if you have opened desired file recently
You can just add file to the project (and then get rid of it when it's no longer needed) (Shift+Alt+A)
You can use Show All Files feature (a toggle button in Solution Explorer) to view all the files under project folder (recursively), even if they are not included in the project. You cannot see folders higher in hierarchy, but you could make for example a symlink or just a dumb copy
You can file a feature request or a bug report (it can be done from VS itself) to make developers know about this situation
Hope any of those solutions will work for you.
Right Click On The File
Click Open With
And Select Notepad..
It Would Do The JOB

How to add a new file association to Visual Studio?

(Windows XP, Visual Studio 2010 Express (Web Developer))
I would like to add various file types to open in Visual Studio that it does not open by default, namely .js, .html, .shtml, .css, etc.
I tried looking for UI inside Visual Studio to add new file types, but I couldn't find anything, so I tried the naive approach of right clicking on the file -> Open With -> Choose Program -> Browse -> c:\program files\Microsoft Visual Studio 10.0\Common7\IDE\VWDExpress.exe. This almost works, except it starts a new instance of the IDE rather than opening a new tab the way .cs files do.
I've tried to go registry diving, exported the association for .cs files, and changing it to point to .shtml (for example), but this still spawns new windows.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.shtml]
"Content Type"="text/plain"
"PerceivedType"="text"
#="VWDExpress.cs.10.0"
[HKEY_CLASSES_ROOT\.shtml\OpenWithProgids]
"VSTA.cs.9.0"=""
"VWDExpress.cs.9.0"=""
"VWDExpress.cs.10.0"=""
[HKEY_CLASSES_ROOT\.shtml\OpenWithProgids\Shared]
#="Shared key to keep this from being removed with install/uninstall of side-by-side components."
[HKEY_CLASSES_ROOT\.shtml\PersistentHandler]
#="{5e941d80-bf96-11cd-b579-08002b30bfeb}"
I strongly suspect that doing this is the wrong way to go about this, but I can't find a better solution. Is there one?
Ive had the same issue so downloaded VWD with SP1 along with VS.PHP 2.10. Right clicked on a .php file and chose 'open with vs.php 2.10', checked the checkbox on bottom which saves settings. Double clicking on a php file has been working since then. In order to be able to use it from a file manager like winscp i had to put 'explorer' as the editor executable. It works for my js html css and php files and opens them in the same VWD instance. Only pain may be that vs.php is to be paid for eventually and that you'd need to associate every extension you wish to work with.
After you use naive approach to associate file with VWDExpress.exe, find a command in registry and add /EDIT parameter. I don't know if this works for Express versions, but for full Visual Studio this opens file in already open Visual Studio instance.
Download Default Programs Editor and open.
In my case I was associating .php files to Visual Studio 11, and to do this I simply copied the settings for .cs files. I've noted all steps below.
FIle Type Settings > Context Menu
Search .php (or whatever association) - note you can multi-select
Click next
Click Add... under the list
Enter the following data:
Command name: Open
Program path: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe" /dde
Now unfold the Advanced Settings, tick Use DDE Message, and click Edit. Add the following:
Message: Open("%1")
Application: VisualStudio.11.0
Topic: system
If you want to apply this to lots of files I suggest using the built in saving to registry option and creating a batch script with it.

How do I "Add Existing Item" an entire directory structure in Visual Studio?

I have a free standing set of files not affiliated with any C# project at all that reside in a complicated nested directory structure.
I want to add them in that format to a different directory in an ASP.NET web application I am working on; while retaining the same structure. So, I copied the folder into the target location of my project and I tried to “add existing item” only to lose the previous folder hierarchy.
Usually I have re-created the directories by hand, copied across on a one-to-one basis, and then added existing items. There are simply too many directories/items in this case.
So how do you add existing directories and files in Visual Studio 2008?
Drag the files / folders from Windows Explorer into the Solution Explorer. It will add them all. Note this doesn't work if Visual Studio is in Administrator Mode, because Windows Explorer is a User Mode process.
Enable "Show All Files" for the specific project (you might need to hit "Refresh" to see them)**.
The folders/files that are not part of your project appear slightly "lighter" in the project tree.
Right click the folders/files you want to add and click "Include In Project". It will recursively add folders/files to the project.
** These buttons are located on the mini Solution Explorer toolbar.
** Make sure you are NOT in debug mode.
In Solution Explorer:
Click Show All Files (second icon from the left at the top of Solution Explorer).
Locate the folder you want to add.
Right-click and select "Include in Project"
I use this to install add-ons like HTML editors and third-party file browsers.
I just want to point out that two of the solutions offered previously,
Drag and drop from Windows Explorer
Show All Files and then include in project.
do not do what the question asked for:
Include in project while preserving the directory structure.
At least not in my case (C++/CLI project Visual Studio 2013 on Windows 7).
In Visual Studio, once you are back in the normal view (not Show All Files), the files you added are all listed at the top level of the project.
Yes, on disk they still reside where they were, but in Solution Explorer they are loose.
I did not find a way around it except recreating the directory structure in Solution Explorer and then doing Add Existing Items at the right location.
I didn't immediately understand this based upon these descriptions but here is what I finally stumbled on:
Turn on "Show All Files" - there is an icon on the Solution Explorer toolbar
Using Windows Explorer (not solution explorer), move your files into the directory structure where you want them to reside
Click "Refresh" also on the Solution Explorer toolbar
The files that you've moved should be visible "ghosted" in the Solution Explorer tree structure where you've placed them
Right click on your ghosted files or folders and click "Include in Project". All the contents of a folder will be included
Below is the icon for the 'Show All Files', just for easy reference.
Click above in the red circle. Your folder will appear in Solution Explorer.
Right click on your folder -> Include in project.
You can change your project XML to add existing subfolders and structures automatically into your project like "node_modules" from NPM:
This is for older MSBuild / Visual Studio versions
<ItemGroup>
<Item Include="$([System.IO.Directory]::GetFiles("$(MSBuildProjectDirectory)\node_modules","*",SearchOption.AllDirectories))"></Item>
</ItemGroup>
For the current MSBuild / Visual Studio versions:
Just put it in the nodes of the xml:
<Project>
</Project>
In this case just change $(MSBuildProjectDirectory)\node_modules to your folder name.
You need to put your directory structure in your project directory. And then click "Show All Files" icon in the top of Solution Explorer toolbox. After that, the added directory will be shown up. You will then need to select this directory, right click, and choose "Include in Project."
This is what I do:
Right click on solution -> Add -> Existing Website...
Choose the folder where your website is. Just the root folder of the site.
Then everything will be added on your solution from folders to files, and files inside those folders.
At last, Visual Studio 2017 allows the user to import an entire directory with a single click. Visual Studio 2017 has a new functionality "Open Folder" that allows opening the entire folder, even without the need to save it as solution. The source code can be imported using the following methods.
Menu File → Open → *Folder (Ctrl + Shift + O)
devenv.exe <source folder>
It even supports building and debugging CMake projects.
Bring your C++ codebase to Visual Studio with “Open Folder”
There is now an open-source extension in the Marketplace that seems to do what the OP was asking for:
Folder To Solution Folder
If it doesn't do exactly what you want, the code is available, so you can modify it to suit your scenario.
HTH
A neat trick I discovered is that if you go to "Add existing...", you can drag the folder from the open dialog to your solution.
I have my Visual Studio to open in Admin Mode automatically, so this was a good workaround for me as I didn't want to have to undo that just to get this to work.
What worked for me was to drag the folder into Visual Studio, then right click the folder and select "Open Folder in File Explorer". Then select all and drag them into the folder in Visual Studio.
In Windows 7 you could do the following:
Right click on your project and select "Add->Existing Item". In the dialog which appears, browse to the root of the directory you want to add. In the upper right corner you have a search box. Type *.cs or *.cpp, whatever the type of files you want to add. After the search finishes, select all files, click Add and wait for a while...
The cleanest way that I've found to do this is to create a new Class Library project in the target folder, and redirect all of its build output elsewhere. It still leaves a .csproj file sitting in that folder, but it does let you see it in Visual Studio and pick which files to include in your project.
It has been a while since this was originally posted, but here is an alternative answer.
If you only care to be able to look at the physical files from inside visual studio and do not necessarily require to see them in the solution explorer default view, then click on the switch view button and choose the folder view and any physical directory/directories that are under your solution root folder will appear here even if they do not appear in the solution explorer default view.
If however, you want to add a folder tree that isn't too large as a virtual solution directory/directories to match your existing tree structure, do that and and then "add the existing" physical files to the virtual directory/directories. If the physical directory exists in your solution directory it will not copy the files - it will link directly to the physical files but they will appear as part of the solution virtual directories.
It's annoying that Visual Studio doesn't support this natively, but CMake could generate the Visual Studio project as a work around.
Other than that, just use Qt Creator. It can then export a Visual Studio project.

Resources