pr0g33k

 collapse all
  1. Microsoft Visual Studio 2015 Installer Projects

    Microsoft released an installer project extension for Visual Studio 2015 that brings back the installer projects that were available in Visual Studio 2010. If you don't want to use the InstallShield Limited Edition setup and deployment project, this is a good alternative.

    https://visualstudiogallery.msdn.microsoft.com/f1cc3f3e-c300-40a7-8797-c509fb8933b9

  2. Reinstalling All NuGet Packages in a Solution

    I just did a fresh install of Windows 10 and Visual Studio 2015. When I pulled down my projects from TFS Online and opened several VS solutions, however, many references were missing from the projects and nothing would build. It turns out that NuGet packages are referenced relative to the solution and not the individual projects. If you have a library that you want to share across multiple solutions and you add that library to a new solution, the NuGet packages for that shared project will have to be set up again for the new solution because the path to the "packages" folder will have changed due to the new, relative path of the new solution.

    To get things going again, I ran the following command from the Package Manager Console:

    Update-Package -Reinstall

    That uninstalled and then reinstalled every package in the solution.

    You can also target a specific project in the solution if you want:

    Update-Package -Project "My.Project.Name" -Reinstall

    I hope that helps!

  3. HTML Encode Clipboard Contents in Visual Studio 2013

    I use Visual Studio's HTML (Web Forms) Editor to author the articles for this blog because the Split screen feature, which allows me to easily see both the Design editor and Source editor at the same time, helps me ensure the markup is as minimal as possible. When Visual Studio 2013 was released, though, I noticed that one of the features I often used, Edit -> Paste Special, was missing. In previous versions, this command would paste the clipboard contents into the HTML Source Editor as HTML-encoded text. This was especially useful when I wanted to paste HTML between <pre></pre> tags so that the formatting was preserved and any angle brackets were not rendered as actual markup. Other things like quotation marks, apostrophies, and angle brackets in C# code (like the syntax for generics) needs to be HTML encoded so that they validate and appear as expected when output as HTML. So I created a windowless C# application that launches from Visual Studio's External Tools support and HTML-encodes anything placed in the clipboard. Here's how I did it:

    Create a new C# Console Application:

    When the new project opens, right-click on the Project in Solution Explorer and select Properties. Change the Output Type to "Windows Application":

    Next, add references to System.Web and System.Windows.Forms:

    Change the code in Program.cs to this:

    using System;
    using System.Web;
    using System.Windows.Forms;
    
    namespace HtmlEncodeClipboard
    {
        class Program
        {
            [STAThread]
            static void Main()
            {
                Clipboard.SetText(HttpUtility.HtmlEncode(Clipboard.GetText()));
            }
        }
    }

    Compile the project and make sure it builds. Then switch the Solution Configuration to Release and build it again so that we can get a release build.

    Now create a new Web application (ASP.NET, MVC, whatever - it doesn't matter). When the project opens, open Tools -> External Tools...

    Click the "Add" button then type a name in the Title field. For Command, browse to the bin/Release folder of your HtmlEncodeClipboard project and select the HtmlEncodeClipboard.exe executable.

    You can move the External Tool up or down the list to position it where you want in the Tools menu. Take note of where you position it, though. We'll use that information in a minute.

    To test the external tool, add a HTML page to your project (or a new View if you're in a MVC project - we just need the HTML editor). Select some markup in the editor, copy it (Ctrl + C or Edit -> Copy), go to the Tools menu and select your new command, then paste the clipboard contents (Ctrl + V or Edit -> Paste). Hopefully the result is HTML encoded text in the editor.

    Now let's add this to Visual Studio's Edit menu. Select Tools -> Customize... Switch to the Commands tab and select "Edit" from the Menu Bar dropdown list:

    Scroll down and select "Cycle Clipboard Ring" then click "Add Command..."

    In the Add Command dialog, scroll down and select "Tools" then scroll through the Commands until you find the command you added earlier. This is where it's important that you noted in which position you placed your command. I positioned mine as the third command in the Tools list so here I would choose "External Command 3."

    Next, click "Modify Selection" and rename your new menu item:

    Now you can select your command from the Edit menu, too:

    To add a keyboard shortcut, go to Tools -> Options and select "Keyboard" under the "Environment" node. In the "Show Commands Containing:" textbox, type the name of your command (in my case, the name is "ExternalCommand3" - remember the position you chose earlier). I'm only interested in using this command in the HTML Source Editor so I selected that in the "Use new shortcut in:" dropdown list. In "Press shortcut keys:" I used the "Ctrl + Shift + Alt + E" keystroke sequence because it wasn't previously assigned to anything. Make sure you click the "Assign" button after you find a keystroke sequence that works for you.

    I hope this is helpful for you. Using Visual Studio's External Tools feature makes it very easy to enhance your productivity.