【问题标题】:How to install templates from nuget package?如何从 nuget 包安装模板?
【发布时间】:2017-04-25 15:49:22
【问题描述】:

我知道我可以从模板安装 nuget 包:

https://docs.microsoft.com/en-us/nuget/visual-studio-extensibility/visual-studio-templates

但我想做相反的事情,我想在安装包之后安装模板 - 由 nuget 包提供。

我读到我可以创建一个 powershell 脚本并在安装包后运行它。这是唯一的方法吗?我在这里有什么选择?

谢谢。

【问题讨论】:

    标签: nuget nuget-package visual-studio-templates


    【解决方案1】:

    对于 .NET Core,可以使用

    dotnet new --install <id of your template package>
    

    docs for the CLI

    【讨论】:

    • 安装后不显示。可能是什么原因?我也尝试以管理员身份运行。它确实在该命令之后显示/列出模板,但我没有看到我尝试安装的新模板。
    • 好吧,不管怎样,经过各种尝试,它终于奏效了——关闭所有 VS 实例,再次运行 VS Developer Shell 的管理模式。
    【解决方案2】:

    我也有同样的问题,发现:

    1. Dotnet 5.0 无法通过 id 从我的 nuget 服务器加载模板,但 dotnet 6.0 可以,并将 .nupkg 文件放入 %USERPROFILE%.templateengine\packages
    2. VS 2022 和新 Rider 查看这些模板。
    3. Dotnet 5.0 可以通过 .nupkg 本地路径安装模板,并将其放到 %USERPROFILE%.templateengine\dotnetcli\v5.0.404\packages 中
    4. 在第 3 步之后,您可以在 Visual Studio 2019 中使用模板,但我在 .template.config 文件夹中也有 ide.host.json https://github.com/sayedihashimi/template-sample#supporting-visual-studio-2019

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-22
      • 2017-09-15
      • 2016-04-18
      • 2022-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-16
      相关资源
      最近更新 更多