none
How to include NuGet packages in a project template? RRS feed

  • Question

  • I am trying to create a project template to create a WPF program that depends on Prism, Unity and a few other NuGet packages but am having trouble getting the syntax and/or organization of the zip file/vstemplate quite right.

    Inside the vstemplate a WizardExtension is declared. Following that is a WizardData tag which declares the NuGet packages to be included in the project. My first attempt at the packages tag was just a simple <packages> with no attributes. That didn't work. My next attempt looked like:

    <packages repository="extension" repositoryId="WpfMvvmPrismUnityApplication.51608644-4e69-4ecd-84e6-3d558569a1c2">

    That failed because the repositoryId was not something that Visual Studio liked when the project was created and I just couldn't figure out how to generate a repositoryId that it did.

    The next attempt was

    <packages repository="template">

    but I couldn't get that to work. In all cases I tried multiple alterations on the packages folder, changing its contents and placement within the zip file but just couldn't get things right.

    The zip file lives in the Visual Studio custom area and Visual Studio can find it. However, when a new project is created an error is displayed.

    Could not add all required packages to the project. The following
    packages failed to install from
    'C:\Users\rhaggard\AppData\Roaming\Microsoft\VisualStudio\12.0\ProjectTemplatesCache\CSharp\WPF\WpfMvvmPrsmUnity\WpfMvvmPrismUnityApplication':

    CommonServiceLocator.1.3 : Unable to find version '1.3' of package 'CommonServiceLocator'.

    Unity.4.0.1 : Unable to find version '4.0.1' of package 'Unity'.<o:p></o:p>

    Prism.Core.6.3.0 : Unable to find version '6.3.0' of package 'Prism.Core'.<o:p></o:p>

    Prism.Wpf.6.3.0 : Unable to find version '6.3.0' of package 'Prism.Wpf'.<o:p></o:p>

    Prism.Unity.6.3.0 : Unable to find version '6.3.0' of package 'Prism.Unity'.

    So, what am I doing wrong with the packages thing?


    Richard Lewis Haggard

    Thursday, November 16, 2017 9:03 PM

All replies