I've tried clearing the local cache as a pre-build event in a project, but that takes place AFTER the nuget restore, so I have to rebuild twice for that solution to work. Maybe you can try using a "after-build" target to clean the cache? I mean in a scenario where you have projects from A to G, project A consumes a package called NugetOne. We built the project A and the NugetOne will be added to cache.(C:\Users\xxx\.nuget\packages). Now we're working in project B which also will consume NugetOne, we want to delete the cache before the restore when building the project in VS. But according to the comments above, this approach failed. So maybe we can add a target which runs after build to clean the cache. And we can add the target to project A or project B to get similar result: If we add it to A: After building A successfully, the cache has been cleaned, then when building B, we have no need to worry about the impact of the cache. If we add it to B: It works like the pre-build-event you use,have to rebuild twice to make it work. Not sure if it's what you want, but if you want a development environment in which development won't be affected by cache from other projects.You can consider using a . My content of Directory.Build.props(Add it to /repos folder, it will impact all your solutions under it, Add it to solution and it will impact all projects in this solution): <Project> <Target AfterTargets="build"> <Message Importance="High" Text="Clean the cache..."/> <xxx //Do your clean cache action here! /> </Target> </Project>Hope it helps in some aspects. (责任编辑:) |