Reputation: 720
In our team we are trying to build workflow with multiple packages project and NuGet team repository server. But to avoid deployment of packages on every change every developer has own local repository on his machine. The scenario is:
Developer works on package and dependent project. He doesn't release new version of package and doesn't deploy it to NuGet team repository before stable release (so version doesn't change until release).
Project_A generates Project_A.nupkg and deploys it in local repository on post build event (version 1.0.0.0 for example).
Project_B has dependency to Project_A.nupkg and pulls it from local repository due to NuGet package restoring built-in functionality.
The problem is, when developer changes something in Project_A and re-pushes it to local repository, Project_B is not getting this update because of the same version of package in packages folder already existing.
I tried:
add "pre-release" part to version (http://docs.nuget.org/docs/reference/versioning), but package is not being updated from repository if version doesn't change.
manually call Update-Package -Reinstall -IncludePrerelease
from package manager console, but it gives Package 'Project_A.1.0.0-alpha' already exists in folder '...\packages'
What is the best solution of this problem besides changing version in AssemblyInfo.cs of Project_A on every build?
Upvotes: 1
Views: 813
Reputation: 141
I encountered the same problem. I solved it by adding the following to the .csproj file of Project_A to clear Project_A.nupkg from the nuget cache (the nuget packages folder):
<Project>
<Target Name="DeleteLocalCache" BeforeTargets="Pack">
<RemoveDir Directories="$(NugetPackageRoot)/$(PackageId.ToLower())/1.0.0-local"/>
</Target>
</Project>
I run dotnet pack
to create the nuget package. The above target runs before the pack command (BeforeTargets="Pack"
) and clears the nuget cache for Project_A.
I tested it on Mac and Linux. I believe it will also work on Windows.
Figuring out our ideal local development workflow for nuget packages took a surprising amount of effort, and I wrote up the results here in case others find it helpful: https://www.nyckel.com/blog/local-development-and-testing-of-nuget-packages/
Upvotes: 1
Reputation: 2857
Clear packages folder on BeforeClean event and always rebuild your project if you want to use the newer version of Project_A.
Upvotes: 0