如何为整个项目创建解决方案级别的NuGet包?

时间:2022-09-01 18:37:21

I have created a NuGet gallery in my company. I want to create and publish a solution level NuGet package. Everyone who will install the package will not get a dll but an entire project added to his/her visual studio solution. Just like adding an existing project, the user will get a project with source code classes and everything is ready to use. Just build it and use it.

我在公司创建了一个NuGet画廊。我想创建并发布一个解决方案级别的NuGet包。安装软件包的每个人都不会获得dll,但整个项目都会添加到他/她的visual studio解决方案中。就像添加现有项目一样,用户将获得一个包含源代码类的项目,并且所有内容都可以使用。只需构建并使用它。

I know it's possible, but couldn't find any documentation.

我知道这是可能的,但找不到任何文件。

Anyone?

任何人?

1 个解决方案

#1


-1  

It is possible to add any files (not only .dll) and even directory structures to a NuGet package, so in theory you could store all files belonging to a project in a package and publish that. However, it is only possible to install NuGet packages into an existing project, meaning that you won't be able to add the packaged files as new project to any solution. In addition, the contained files will be put to the solution's packages folder, not to a solution or project folder.

可以将任何文件(不仅是.dll)甚至目录结构添加到NuGet包中,因此理论上您可以将属于项目的所有文件存储在包中并发布它。但是,只能将NuGet包安装到现有项目中,这意味着您将无法将打包文件作为新项目添加到任何解决方案中。此外,包含的文件将被放入解决方案的packages文件夹,而不是解决方案或项目文件夹。

As an alternative, consider creating a Template project instead of a NuGet package, as explained in How to: Create Project Templates and my blog post Creating template projects. This will result in a .vsix file that any developer can install as Visual Studio Add-In, the templated project will then appear in Visual Studio's File -> New -> Project... dialog as new project type and can be added to any solution.

作为替代方案,请考虑创建一个Template项目而不是NuGet包,如如何:创建项目模板和我的博客文章创建模板项目中所述。这将生成一个任何开发人员可以作为Visual Studio加载项安装的.vsix文件,模板化项目将出现在Visual Studio的File - > New - > Project ...对话框中作为新项目类型,并且可以添加到任何解。

Similar to your NuGet gallery, it is also possible to create a private Visual Studio Gallery to share such Add-Ins within, for example, a company, as explained in this MSDN article.

与您的NuGet库类似,也可以创建一个私有的Visual Studio库,以便在公司内部共享此类加载项,如本MSDN文章中所述。

#1


-1  

It is possible to add any files (not only .dll) and even directory structures to a NuGet package, so in theory you could store all files belonging to a project in a package and publish that. However, it is only possible to install NuGet packages into an existing project, meaning that you won't be able to add the packaged files as new project to any solution. In addition, the contained files will be put to the solution's packages folder, not to a solution or project folder.

可以将任何文件(不仅是.dll)甚至目录结构添加到NuGet包中,因此理论上您可以将属于项目的所有文件存储在包中并发布它。但是,只能将NuGet包安装到现有项目中,这意味着您将无法将打包文件作为新项目添加到任何解决方案中。此外,包含的文件将被放入解决方案的packages文件夹,而不是解决方案或项目文件夹。

As an alternative, consider creating a Template project instead of a NuGet package, as explained in How to: Create Project Templates and my blog post Creating template projects. This will result in a .vsix file that any developer can install as Visual Studio Add-In, the templated project will then appear in Visual Studio's File -> New -> Project... dialog as new project type and can be added to any solution.

作为替代方案,请考虑创建一个Template项目而不是NuGet包,如如何:创建项目模板和我的博客文章创建模板项目中所述。这将生成一个任何开发人员可以作为Visual Studio加载项安装的.vsix文件,模板化项目将出现在Visual Studio的File - > New - > Project ...对话框中作为新项目类型,并且可以添加到任何解。

Similar to your NuGet gallery, it is also possible to create a private Visual Studio Gallery to share such Add-Ins within, for example, a company, as explained in this MSDN article.

与您的NuGet库类似,也可以创建一个私有的Visual Studio库,以便在公司内部共享此类加载项,如本MSDN文章中所述。