Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize NuGet package downloads for a specific operating system #2

Open
asimmon opened this issue Jul 31, 2022 · 3 comments
Open

Optimize NuGet package downloads for a specific operating system #2

asimmon opened this issue Jul 31, 2022 · 3 comments
Labels
wontfix This will not be worked on

Comments

@asimmon
Copy link
Owner

asimmon commented Jul 31, 2022

EphemeralMongo use a dedicated runtime NuGet package for each operating system (linux-x64, osx-x64 and windows-x64).

However, when using EphemeralMongo4, EphemeralMongo5 or EphemeralMongo6, the three OS-specific runtime packages are downloaded and copied to the build output, which takes time and a lot of space. The ideal solution would to only download the relevant runtime package for the consuming operating system.

Unfortunately, there is no viable solution today to optimize the download process.

  1. It is not an option to download MongoDB and the tools at runtime, there could be network issues, some people use proxies and firewalls, we would have to implement a reliable cache.
  2. .NET does not provide (yet) a way to use conditional NuGet dependencies on both the target framework moniker (TFM) and a runtime identifier (RID).

There are actually a lot of opened issues in the .NET GitHub repository about option #2, so it might be possible in a future version of .NET:

Using runtime.json is also not an option because it is deprecated, undocumented, and was created for internal .NET Core NuGet packages.

Until then, we'll stick with the RID-specific runtime package.

@asimmon asimmon added the wontfix This will not be worked on label Oct 2, 2022
@asimmon asimmon pinned this issue Nov 28, 2022
@0xced
Copy link

0xced commented Feb 4, 2023

I finally got around to try EphemeralMongo. 😃

It seems to me that there's an easy solution to reduce the download size with the existing packages. Instead of importing EphemeralMongo through the EphemeralMongo6 package, one can import the EphemeralMongo.Core package and the runtime package conditionally, so that only the runtime for the current OS is restored (i.e. downloaded).

In other technical words, going from this:

<ItemGroup>
  <PackageReference Include="EphemeralMongo6" Version="0.1.3" />
</ItemGroup>

to this:

<ItemGroup>
  <PackageReference Include="EphemeralMongo.Core" Version="0.1.3" />
  <PackageReference Include="EphemeralMongo6.runtime.linux-x64" Version="0.1.3" Condition="$([MSBuild]::IsOSPlatform('Linux'))" />
  <PackageReference Include="EphemeralMongo6.runtime.osx-x64" Version="0.1.3" Condition="$([MSBuild]::IsOSPlatform('OSX'))" />
  <PackageReference Include="EphemeralMongo6.runtime.win-x64" Version="0.1.3" Condition="$([MSBuild]::IsOSPlatform('Windows'))" />
</ItemGroup>

It's not as tidy and a built-in solution would be nicer but it can definitely save some bandwidth and time.

Maybe it could be worth mentioning this approach in the README?

@asimmon
Copy link
Owner Author

asimmon commented Feb 22, 2023

@0xced done! Thank you for the suggestion.

image

@0xced
Copy link

0xced commented Sep 30, 2023

Linking some more issues that discuss the matter (even if not obvious from their titles).

Interesting how all theses issues are still open. 😅

Also, note that the libclang package is using the undocumented runtime.json feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants