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

[Feature Request] Disable caching for Local Feed #13918

Closed
gioce90 opened this issue Nov 12, 2024 · 4 comments
Closed

[Feature Request] Disable caching for Local Feed #13918

gioce90 opened this issue Nov 12, 2024 · 4 comments
Labels
Resolution:Duplicate This issue appears to be a Duplicate of another issue Type:Feature

Comments

@gioce90
Copy link

gioce90 commented Nov 12, 2024

NuGet Product(s) Involved

NuGet.exe, NuGet SDK

The Elevator Pitch

I'm asking the same feature in #8251 , in light of new clearer reasons of which is the common scenario that the feature will resolve.

For local development purposes this feature is a must-have: I exhaustive described here a common scenario, but - shortly - the idea is to give to developers the freedom to works on their local machines using Local Feeds without facing cache issues.

This is especially needed when we work on 2 or more local projects, where one is a package project and the other is a project who consumes the package. When a developer make some changes on a package, before to push these changes he wants to test the changes using (in local) other project(s) which consumes the edited package. All of this happens in local and doesn't involve yet the CI/CD pipelines. This is a really common scenario in companies with large codebase and numerous package projects.
Note that the purpose here is not to skip the CI/CD, but just speed-up the local development.

So the request is: only and exclusively for packages on the local machine, that the cache should be disabled.

It could be by default or, as suggested here, with this configuration:

nuget.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
     <add key="Local packages for Windows" value="%userprofile%\.nuget\packages\localPackages"  disableCache="True" />
     <add key="Local packages for MacOS" value="~/.nuget/packages/localPackages"  disableCache="True" />
  </packageSources>
</configuration>

Of course disableCache="True" should works only for local feeds.

Another solution it can be to operate on the in the .csproj in this way:

<Project Sdk="Microsoft.NET.Sdk">
         ...
	<ItemGroup>
		<PackageReference Include="MyPackage" Version="8.0.0-Local" disableCache="true" />
	</ItemGroup>
</Project>

Any other ideas on how to disable cache for packages on the local machine are welcome.

Additional Context and Details

In local I use to produce a package using this convention: MyPackage.x.y.z-Local ... now, we all knows that increment the version is really important when we are shipping the package, but in local it should not be a serious thing, because is just distracting and a waste of time and focus.
But using just the "-Local" suffix without increment the version means facing cache issues: this should due to global packages folder that keep the old package (I don't think that http-cache is involved).

Note:

  • In NuGet there are already several ways to skip cache, but not via .config or .csproj
  • Being forced to continuously increment the version number on both the package project and the project that references it, when we are still working locally, is non-sense [IMHO].
  • Typically a pre-release version of a package is built via CI/CD related to a feature branch: but being forced to push changes to start this pipeline, only to debug and test locally something a developer isn't entirely sure about, is a waste of time, resources (pipeline agents), and an unnecessary mess of git history. And have to wait the pipeline execution just to take the new pre-release version that then will however tested in local by the other project... is a waste of time and focus.
  • Avoiding this cache problem with the use of CLI commands, custom Powershell scripts, Directory.Builds.props (which is my case), clean all the cache manually every time... all of this is a burden that the feature proposed resolves.
  • Note that substitute the <PackageReference> tag with the more directly <Reference> tag in the .csproj of the project who uses the package expose to easy mistakes and compromises other things.
  • A fallback Package Folders doesn't resolve the problem (as initially pointed out in the closed issue).
@CEbbinghaus
Copy link

Of course disableCache="True" should works only for local feeds.

I have a problem with this as it needlessly constrains the usage of this feature. Additionally, it conflicts with your proposed "package" syntax <PackageReference Include="MyPackage" Version="8.0.0-Local" disableCache="true" />. What if that package was only available from a remote feed?

Instead, a more general solution that allows disabling caching on either feeds or packages would be preferred. So, a remote feed could have its caching disabled or a singular package within the feed could. This would benefit most for local feeds but there is no reason to limit the design to only it.

@jeffkl
Copy link
Contributor

jeffkl commented Nov 18, 2024

Closing in favor of #6579

@jeffkl jeffkl closed this as not planned Won't fix, can't repro, duplicate, stale Nov 18, 2024
@jeffkl jeffkl added the Resolution:Duplicate This issue appears to be a Duplicate of another issue label Nov 18, 2024
@gioce90
Copy link
Author

gioce90 commented Nov 20, 2024

@CEbbinghaus , you’re absolutely right — this wasn’t my first choice either.

In my opinion, the best approach would be to place disableCache="true" not in the <PackageReference> tag, but in an entry under <packageSources> in the nuget.config.

I suggested applying it only to Local Feeds because disabling the cache for a remote feed feels a bit unusual to me — after all, there’s a reason the cache exists. That said, it might make sense in specific cases for individual packages?
However, there are already other feature requests open, like #8745 and #5713 .


The NuGet team decided to close this feature request in favor of a more generic (and older) issue, which has been open since 2018... In the meantime, I’m working on a solution myself. Once it’s ready, I’ll share it and post it here.

@gioce90
Copy link
Author

gioce90 commented Dec 30, 2024

Hi @CEbbinghaus , I worked on a solution by myself, as I mentioned here and also here.

I’ve now decided to make my solution public by releasing a package called NuJet (https://github.com/gioce90/NuJet). It enhances the inner-loop development and testing process for NuGet packages, especially in local workflows.

Feel free to check it out—I’d love to hear your feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution:Duplicate This issue appears to be a Duplicate of another issue Type:Feature
Projects
None yet
Development

No branches or pull requests

4 participants