none
Deprecated APIs in VS2019 RRS feed

  • Question

  • I've got a VSIX extension. I decided to try to upgrade to the latest version of Visual Studio (2019), and see what kind of horrors that I would encounter this time in getting my extension to work with the latest version. I read the article by Mads Kristensen about upgrading VSIX extensions:

    https://devblogs.microsoft.com/visualstudio/author/madsk/

    I was lulled into a false sense of optimism by that. I feel so foolish.

    I made the changes to my .vsixmanifest as mentioned in the article. I then built the VSIX project with Visual Studio 2019. When I tried to load the VSIX, it did not find Visual Studio 2019. I got a message box with the following message:

    "This extension is already installed to all applicable products."

    After much Googling, I eventually unzipped the VSIX file, and examined the extension.vsixmanifest file within the generated VSIX. To my astonishment and dismay, the "Version" attributes on the "InstallationTarget" elements had been changed back to what they were before (16.0, instead of 17.0):

      <Installation>
        <!-- <InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[14.0]" /> -->
        <!-- Verification entry to ensure that this is the source file. -->
        <InstallationTarget Version="[14.0,16.0)" Id="Microsoft.VisualStudio.Community" />
        <InstallationTarget Version="[14.0,16.0)" Id="Microsoft.VisualStudio.Pro" />
        <InstallationTarget Version="[14.0,16.0)" Id="Microsoft.VisualStudio.Enterprise" />
        <InstallationTarget Version="[15.0,16.0)" Id="Microsoft.VisualStudio.Enterprise" />
      </Installation>

    I then examined the extension.vsixmanifest file within the bin folder. It is as it should be, and as it is when I edited it:

      <Installation>
        <!-- <InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[14.0]" /> -->
        <!-- Verification entry to ensure that this is the source file. -->
        <InstallationTarget Version="[14.0,17.0)" Id="Microsoft.VisualStudio.Community" />
        <InstallationTarget Version="[14.0,17.0)" Id="Microsoft.VisualStudio.Pro" />
        <InstallationTarget Version="[14.0,17.0)" Id="Microsoft.VisualStudio.Enterprise" />
        <InstallationTarget Version="[15.0,17.0)" Id="Microsoft.VisualStudio.Enterprise" />
      </Installation>

    It would appear that it was changed by something within the build process.

    I then edited the extension.vsixmanifest within the unzipped file to what it should be (Version="[14.0,17.0)"), re-zipped the folder into a VSIX, and it loaded to Visual Studio 2019.

    I can invoke functions within my VSIX that do not alter text. I thought to myself: "OK - so far, so good."

    I then invoked a function that alters test: It's a simple function that duplicates the current line that the cursor is on, much like the function on CTRL+D in Resharper. I had an "OH SHIT" moment when Visual Studio 2019 froze, and I saw a message at the top:

    "One or more extensions were loaded using deprecated APIs."

    My VSIX extension started out as macros, which were originally written over 10 years ago. A lot of the functions are based on EnvDTE objects. I have a bad feeling that this is the API that has been deprecated. Am I correct? If so, what can I do about getting EnvDTE functionality incorporated into Visual Studio 2019? If not, how can I find out what it is that Visual Studio 2019 does not like?

    <rant>
    As I stated before: My VSIX extension started out as macros many years ago. I was one of many who were PO'ed when Microsoft removed macro support from Visual Studio. I then managed to get everything loaded as an add-in, then had the rug pulled out from under me when Microsoft did away with add-ins on later versions. I then managed to get everything to load as a VSIX, turning the code files from my macros into libraries upon which I call functions from the VSIX, and everything was working well with Visual Studio 2015 and 2017. It seems like, with every new version, I have to endure anguish and misery just to keep the same functionality that I had from over 10 years ago.
    </rant>


    Any assistance with this would be much appreciated.


    Wally

    Friday, May 24, 2019 9:57 PM

Answers

All replies

  • EnvDTE is not deprecated in VS 2019 and should not cause the message.

    Can you share your Package class declaration?


    Sergey Vlasov | Vlasov Studio | Innovative Visual Studio extensions and tools

    Saturday, May 25, 2019 2:13 AM
  • Hi Sergey,

    //------------------------------------------------------------------------------
    // <copyright file="Burton_VS_Package_01.cs" company="Company">
    //     Copyright (c) Company.  All rights reserved.
    // </copyright>
    //------------------------------------------------------------------------------
    
    using System;
    using System.ComponentModel.Design;
    using System.Diagnostics;
    using System.Diagnostics.CodeAnalysis;
    using System.Globalization;
    using System.Runtime.InteropServices;
    using Microsoft.VisualStudio;
    using Microsoft.VisualStudio.OLE.Interop;
    using Microsoft.VisualStudio.Shell;
    using Microsoft.VisualStudio.Shell.Interop;
    using Microsoft.Win32;
    
    using EnvDTE;
    using EnvDTE80;
    
    using System.Windows.Forms;
    
    
    namespace Burton_VSIX_01
    {
        /// <summary>
        /// This is the class that implements the package exposed by this assembly.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The minimum requirement for a class to be considered a valid package for Visual Studio
        /// is to implement the IVsPackage interface and register itself with the shell.
        /// This package uses the helper classes defined inside the Managed Package Framework (MPF)
        /// to do it: it derives from the Package class that provides the implementation of the
        /// IVsPackage interface and uses the registration attributes defined in the framework to
        /// register itself and its components with the shell. These attributes tell the pkgdef creation
        /// utility what data to put into .pkgdef file.
        /// </para>
        /// <para>
        /// To get loaded into VS, the package must be referred by &lt;Asset Type="Microsoft.VisualStudio.VsPackage" ...&gt; in .vsixmanifest file.
        /// </para>
        /// </remarks>
        [PackageRegistration(UseManagedResourcesOnly = true)]
        [InstalledProductRegistration("#1110", "#1112", "1.0", IconResourceID = 1400)] // Info on this package for Help/About
        [Guid(Burton_VS_Package_01.PackageGuidString)]
        [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "pkgdef, VS and vsixmanifest are valid VS terms")]
        [ProvideAutoLoad(UIContextGuids80.SolutionExists)]
        public sealed class Burton_VS_Package_01 : Package
        {
            /// <summary>
            /// Burton_VS_Package_01 GUID string.
            /// </summary>
            public const string PackageGuidString = "(removed for post)";
    
    
            public void idCommand1()
            {
                give_message("idCommand1");
            }
    
            /// <summary>
            /// Initializes a new instance of the <see cref="Burton_VS_Package_01"/> class.
            /// </summary>
            public Burton_VS_Package_01()
            {
                int x1 = 0;
    
    
                // Inside this method you can place any initialization code that does not require
                // any Visual Studio service because at this point the package object is created but
                // not sited yet inside Visual Studio environment. The place to do all the other
                // initialization is the Initialize method.
            }
    
            #region Package Members
    
            /// <summary>
            /// Initialization of the package; this method is called right after the package is sited, so this is the place
            /// where you can put all the initialization code that rely on services provided by VisualStudio.
            /// </summary>
            protected override void Initialize()
            {
                base.Initialize();
            }
    
            #endregion
    
    
            internal void give_message(string p_mssg)
            {
                // Initializes the variables to pass to the MessageBox.Show method.
    
                string message = "You did not enter a server name. Cancel this operation?";
                //string caption = "Error Detected in Input";
                string caption = "TEST";
                MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                DialogResult result;
    
                // Displays the MessageBox.
    
                //result = MessageBox.Show(message, caption, buttons);
                result = MessageBox.Show(p_mssg, caption, buttons);
    
                if (result == System.Windows.Forms.DialogResult.Yes)
                {
    
                    // Closes the parent form.
    
                    //this.Close();
    
                }
            }
    
        }
    }
    


    Wally

    Saturday, May 25, 2019 2:36 AM
  • Thank you for providing the code!

    ProvideAutoLoad attribute is deprecated in VS 2019. You can remove it if not absolutely required for your extension or Migrate the Package to AsyncPackage.


    Sergey Vlasov | Vlasov Studio | Innovative Visual Studio extensions and tools


    • Edited by Sergey Vlasov Saturday, May 25, 2019 9:32 AM
    • Marked as answer by Wally9633 Saturday, May 25, 2019 10:04 PM
    Saturday, May 25, 2019 9:32 AM
  • Hi Sergey,

    When I build the VSIX, it still changes the version back to 16.

    However, when I did as I did before (unzip the VSIX, change the version in the vsixmanifest, then rezip the VSIX), it installs, and everything seems to be working mostly.

    THANK YOU for your assistance!


    Wally

    Saturday, May 25, 2019 10:04 PM