csproj file yourself and add the necessary items by hand. Visual Studio shows linked items with a slightly different icon, as you can see below where SharedSettings.json is a linked file and appsettings.json is a normally added file:Īs you'd expect for ASP.NET Core projects, you don't need Visual Studio to get this behaviour. That way, if you modify the original file you'll immediately see the changes in your project. Instead of copying the file into the project directory, Visual Studio will create a link to the original. Instead, click the little dropdown arrow next to the Add button and select Add as Link. To add a file as a link, right click and choose Add > Existing Item… as before, but this time, don't click the Add button. Adding files from outside the project by linking Sometimes this is the behaviour you want, but often you want the original file to remain where it is and for the project to just point to it, not to create a copy. Visual Studio will spot that the file is outside the project directory and will copy it in. You're then presented with a file picker dialog, so you can navigate to the file, and choose Add. You can easily do this from Visual Studio by right clicking the project you want to include it in, and selecting Add > Existing Item… Sometimes, you might want to include an existing item in your ASP.NET Core apps that lives outside the project directory. Adding files from outside the project by copying I suspect this feature may have slipped under the radar for many people due to the slightly obscure UI hints you need to pick up on in Visual Studio. You may now resume slinging code like a boss.This post is just a quick tip that I found myself using recently - including files in a project that are outside the project directory. Hit the keyboard shortcut and the file will be immediately highlighted in the Solution Explorer. Bind to Shift+Alt+F (or other combo as desired) by pressing this key combination in the “Press shortcut keys” input box and clicking “Assign”. This will select the “LocateCurrentFileInSolutionExplorer” macro you just created in blue. Under “Show commands containing”, type “Locate”. Navigate to Tools > Options > Environment > Keyboard. Public Sub LocateFileInSolutionExplorer()ĭTE.ExecuteCommand("View.TrackActivityinSolutionExplorer")ĭTE.ExecuteCommand("View.SolutionExplorer")īe sure to hit Ctrl+S to save. Paste the code below into the Public Module “LocateCurrentFileInSolutionExplorer” body: Rename Module1 to “LocateCurrentFileInSolutionExplorer”.ĭouble click the “LocateCurrentFileInSolutionExplorer” you just created. Right click on Module1 and select “Rename”. Now third party add-ons like ReSharper offer a convenient context menu for locating the current file in the Solution Explorer on demand, but we can pull it off quickly in Visual Studio via a simple macro bound to a keyboard shortcut. So getting this behavior on demand is the way to go. However, the constant jumping around in Solution Explorer is distracting and be a hindrance when you don’t want to lose your current location in the explorer. Check “Track active item in Solution Explorer”. Tools > Options > Projects and Solutions > General. You can set the solution explorer to always stay in sync with this simple setting: Visual Studio doesn’t offer an easy way to locate the current file you’re editing in the Solution Explorer on demand.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |