简体   繁体   English

如何在类库C#项目中将ac#项目添加为资源?

[英]How to add a c# project as a resource in a class library c# project?

I have been working on a class library that generates c# projects from an existing c# project. 我一直在研究从现有c#项目生成c#项目的类库。 Right now I have the template project in a specific folder on my machine but what I really need is to add that template project to the class library as a resource, so I could distribute the dll. 现在,我在计算机上的特定文件夹中拥有模板项目,但我真正需要的是将该模板项目作为资源添加到类库中,以便我可以分发dll。 Any suggestion will be very helpful. 任何建议都会非常有帮助。

If I'm understanding this correctly, and you're saying you've got a project that produces new C# projects (so .csproj and .cs files) and you want to add those as a resource, then I'd zip them up and add the zip as a resource. 如果我正确理解了这一点,并且您说的是您有一个生成新C#项目的项目(因此.csproj和.cs文件),并且想要将它们添加为资源,则可以将其压缩并将zip作为资源添加。

Also have a look at the way new templates in Visual Studio are distributed. 还可以看看Visual Studio中新模板的分发方式。 Within Visual Studios program files you'll find the built-in templates for example "C# Console Application" and "VB.NET WinForms" in the default path "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\IDE\\ProjectTemplates", however you can always download new ones from online and add them to Visual Studio, I'm guessing they could be zip or some form of packaged file. 在Visual Studio程序文件中,您将在默认路径“ C:\\ Program Files(x86)\\ Microsoft Visual Studio \\ 2017 \\ Enterprise \\\\”中找到内置模板,例如“ C#控制台应用程序”和“ VB.NET WinForms”。 Common7 \\ IDE \\ ProjectTemplates”,但是您始终可以从网上下载新的并将其添加到Visual Studio,我猜它们可能是zip或某种形式的打包文件。

There's information from Microsoft on how to create your own project templates and mentions about zipping them up https://docs.microsoft.com/en-us/visualstudio/ide/how-to-create-project-templates?view=vs-2017 Microsoft提供了有关如何创建自己的项目模板的信息,并提到将其压缩到https://docs.microsoft.com/zh-cn/visualstudio/ide/how-to-create-project-templates?view=vs- 2017年

There's also a guide here on how to create your own project templates https://www.ecanarys.com/Blogs/ArticleID/180/Create-custom-project-templates-in-Visual-Studio 这里还有关于如何创建自己的项目模板的指南https://www.ecanarys.com/Blogs/ArticleID/180/Create-custom-project-templates-in-Visual-Studio

Having a look around at distributed project templates, they mostly come from the Visual Studio Marketplace. 看看分布式项目模板,它们主要来自Visual Studio市场。

Video 18 of this series on the Microsoft Virtual Academy might help you. 本系列有关Microsoft Virtual Academy的视频18可能会为您提供帮助。

Creating and Adding References to Assemblies https://mva.microsoft.com/en-US/training-courses/c-fundamentals-for-absolute-beginners-16169?l=Ry6jz0QIC_5706218949 创建并添加对程序集的引用https://mva.microsoft.com/zh-cn/training-courses/c-fundamentals-for-absolute-beginners-16169?l=Ry6jz0QIC_5706218949

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM