问题
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:
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.)
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.
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.
How would I best minimize the source control impact of using Roslyn?
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.
回答1:
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".
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.
来源:https://stackoverflow.com/questions/43052851/avoid-significant-amounts-of-packages-and-binaries-when-using-roslyn-with-nuget