Search code examples
asp.net-corevisual-studio-2017vsixvisual-studio-templates

Visual Studio 2017 VSIX with ASP.NET Core 2 Web Application template just installs a blank project


I followed the "Getting Started with the VSIX Project Template" Microsoft documentation to create an ASP.NET Core 2 Web Application template and after running the VSIX file I have the new project template listed but when I create a new project with it none of the files are there. It is just an empty project. My attempt can be found here: https://github.com/DrewBrasher/ExampleAspNetCoreTemplate

The steps in the documentation are:

  1. Create a project template.

    a. Open the project from which to create a template. This project can be of any project type.

    b. On the Project menu, click Export Template. Complete the steps of the wizard. A .zip file is created in %USERPROFILE%\My Documents\Visual Studio \My Exported Templates.

  2. Create an empty VSIX project. On the File menu, click New and then click Project. Select either Visual Basic or Visual C#. Under the selected node, select Extensibility, and then select VSIX Project.

  3. Add the .zip file to the project. Set its Copy to Output Directory property to Copy Always.

  4. In the Solution Explorer, double-click the source.extension.vsixmanifest file to open it in the VSIX Manifest Designer, and then make the following changes:

    • Set the Product Name field to My Project Template.
    • Set the Product ID field to MyProjectTemplate - 1.
    • Set the Author field to Fabrikam.
    • Set the Description field to My project template.
    • In the Assets section, add a Microsoft.VisualStudio.ProjectTemplate type and set its path to the name of the .zip file.
  5. Save and close the source.extension.vsixmanifest file.
  6. Build the project.
  7. In the output directory, double-click the .vsix file.
  8. A VSIX Installer message box appears. Follow the instructions to install the extension.
  9. Close Visual Studio and then re-open it.

Solution

  • I believe this is a Visual Studio bug but I have found a workaround. After exporting the project as a template (step 1b), you need to:

    1. Extract the zip file.
    2. Add this to the "TemplateData" section of the .vstemplate file:

    <CreateInPlace>true</CreateInPlace>

    1. Compress the files back into a zip file.
    2. Continue with the rest of the documentation.

    Sources: https://developercommunity.visualstudio.com/content/problem/21751/creating-new-project-from-vs-2017-rc-exported-temp-1.html

    Exported project template in VS2017 misses source files