将 Roslyn 与 Nuget 结合使用时,避免使用大量软件包和二进制文件 [英] Avoid significant amounts of packages and binaries when using Roslyn with Nuget

查看:45
本文介绍了将 Roslyn 与 Nuget 结合使用时,避免使用大量软件包和二进制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的应用程序中使用 Roslyn.我为此添加了 NuGet 包(Microsoft.CodeAnalysis.CSharp).事实证明,这个包依赖于许多其他包:

I'm trying to make use of Roslyn in my application. I added the NuGet package for that (Microsoft.CodeAnalysis.CSharp). It turns out that this package depends on many others:

它们中的大多数在 .NET Framework 上似乎未使用(例如,System.Runtime 提供了诸如 Int32 之类的类型).

Most of them seem unused on the .NET Framework (e.g. System.Runtime which provides types such as Int32).

这些包的大小与实际使用的内容之间存在令人难以置信的对比.许多数据似乎是翻译:

There is an incredible contrast between the size of those packages and what is actually being used. A lot of the data appear to be translations:

(我并不是说这里有人做得不好.我没有足够的能力做出这个决定.我只是想找出如何处理这个问题,见下文.)

(I'm not saying someone did a bad job here. I'm not competent enough to make that determination. I just want to find out how to deal with this, see below.)

将所有这些都检查到源代码管理中似乎是个坏主意.如果我每隔几个月更新这些软件包,那么随着时间的推移,所有这些文件的存储库将膨胀数 GB.我也很担心 IDE 的速度,坦率地说,我很担心自己会在这巨大的软件包海洋中感到困惑.

It seems like a bad idea to check all of that in to source control. If I update those packages every few months then then repository will bloat by gigabytes from all those files over time. I'm also worried about IDE speed and frankly about confusing myself in this huge sea of packages.

由于安全问题以及依赖另一家公司的持续服务才能构建我们的源代码,因此无法使用包恢复.通过其他公司",我的意思是我需要相信 Microsoft 和软件包作者始终可用,不要向我发送病毒,也不要删除导致我的应用程序中断的旧版本.如果我只下载一次,或者每隔几个月,就会大大减少曝光率.

Package restore cannot be used due to security concerns and reliance on another company's ongoing service for our source code to be able to build. By "other company" I mean that I need to trust Microsoft and the package authors to be available at all times, not send me a virus and not remove old versions causing my app to break. If I download just once, or every few month, the exposure is greatly reduced.

我如何才能最大程度地减少使用 Roslyn 对源代码控制的影响?

我真的希望我能够将这些包放入源代码管理中.我希望有一种方法可以删除所有我不需要的包,并将它们限制在 bin 文件夹中的内容.

I really hope I will be able to put the packages into source control. I hope there is a way to remove all the packages I don't need and restrict them to what ends up in the bin folder.

推荐答案

你不应该检查包文件夹到源代码控制;那会让你难过.听起来您真正的问题是担心 nuget.org 或现有软件包的可靠性.如果这是一个问题,您可能需要考虑仅将 .nupkg 文件存储在您可以控制并保留它们的地方.您可能需要查看这些说明,了解如何你可以运行你自己的服务器,它可以像有一个网络驱动器"一样低技术.

You shouldn't check the packages folder to source control; that'll make you sad. It sounds like your real problem is concern of the reliability of nuget.org or packages existing. If that's a concern you might want to consider just storing the .nupkg files in a place where you control and can keep them around. You might want to take a look at these instructions of how you could run your own server, which can be as low tech as "have a network drive".

您还可以签入 .nupkg 文件,然后使用那个作为您的提要,这至少会减少您需要管理的文件数量.至少与未压缩的文件夹相比,这些文件夹会更小且经过压缩.

You could also check in the .nupkg files and then use that as your feed, which would at least reduce the number of files you need to manage. At least those will be smaller and compressed vs. the uncompressed folders.

这篇关于将 Roslyn 与 Nuget 结合使用时,避免使用大量软件包和二进制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆