Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
677 views
in Technique[技术] by (71.8m points)

visual studio 2012 - VSIX with Project Templates and NuGet Packages

I have been following this post about how to build a VSIX project that will add some custom MVC project types:

http://www.asp.net/mvc/tutorials/mvc-4/custom-mvc-templates

I also want to include some additional Nuget packages, so I was following this page from Nuget, but it seems to be for VS2010 and I'm working in 2012.

I have the project building, and everything works peachy on my machine. The install works, the new project type appears, and when I create a new project of this type, everything works perfectly.

However, when I send the installer to a coworker, things break. The installer works, they see the new project type, but when creating the project he gets error messages about not being able to install any of the packages in the extension node. I've confirmed the Product Id of the extension is correct (I intentionally malformed it in the .vstemplate file during testing and it gave an entirely different error). I've added the packages to the extension manifest, but it doesn't seem to make a difference. I've also confirmed the .nupkg files get deployed to %ProgramFiles(x86)%Microsoft Visual Studio 11.0Common7IDEExtensions.

Any suggestions on what to do?

Custom Project's .vstemplate section

<WizardExtension>
    <Assembly>NuGet.VisualStudio.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
    <FullClassName>NuGet.VisualStudio.TemplateWizard</FullClassName>
</WizardExtension>
<WizardData>
    <packages repository="registry" keyName="AspNetMvc4VS11" isPreunzipped="true">
        <package id="EntityFramework" version="5.0.0" skipAssemblyReferences="true" />
        <package id="jQuery" version="1.8.2" />
        <!-- snip -->
    </packages>
    <packages repository="extension" repositoryId="SampleExtensionId">
      <package id="Unity" version="3.0.1304.0" targetFramework="net45" />
      <package id="Unity.WebAPI" version="0.10" targetFramework="net45" />
      <!-- snip -->
    </packages>
</WizardData>

source.extension.vsixmanifest Asset tags

<Assets>
    <Asset d:VsixSubPath="ProjectTemplatesCustomMVCTemplate" etc/>
    <Asset Type="Unity.3.0.1304.0" Path="PackagesUnity.3.0.1304.0.nupkg" />
    <Asset Type="Unity.WebAPI.0.10" Path="PackagesUnity.WebAPI.0.10.nupkg" />
    <!-- snip -->
</Assets>

File Structure

  • Extension Project
    • Packages
      • NugetPackage 1
      • NugetPackage 2
      • etc
    • ProjectTemplates
      • CustomMVCTemplate
        • <custom project files>
    • source.extension.vsixmanifest
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I've made a step by step video on how to make a VSIX that auto downloads nuget packages.

http://www.youtube.com/watch?v=_ZvsFz41H-E

Since there are many steps and I never wrote them down, I won't type them here. I've definitely tested my VSIX package on other people's machine and it worked so hopefully this will work for you.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...