Reputation: 4244
I am producing a nuget package (some c# dlls that are then built into a nuget package and then uploaded to our nuget server)
I would like to have a way to test the package before I bother uploading it to a server.
I have a test project that has the package installed
Is there a way (in command line etc) to uninstall the release package from the project, and install a candidate package from the local machine in its place? (to test that the new package build is actually good?).
It would be good to have a one click update and restore of this candidate package too, so if I do a code change in my code thats being packaged, I can just have a one-click "build -> package candidate package -> restore candidate package on the test project".
In short: I change code in my package. click a button, then just hit F5 in the test project and it runs with the latest code changes.
Upvotes: 0
Views: 2913
Reputation: 23808
AFAK, to realize this, you have to modify the PackageVersion
node to make such nuget package unique every time.
Assume that your lib project and main project are all new-sdk projects.
1) Add such node under the csproj of the class library project and make the PackageVersion
unique. Also check this link:
<PropertyGroup>
<PackageVersion>1.0.0-re-$([System.DateTime]::Now.ToString('yyyyMMddHHmm'))</PackageVersion>
</PropertyGroup>
2) change your main project's csproj file to this:
<ItemGroup>
<PackageReference Include="Lib" Version="1.0.0-*" />
</ItemGroup>
It will use the latest version of the nuget under the nuget package source.
3) if you modify the lib project and then finish it, please right-click on the lib project Properties-->Pack to generate the new version.
4) then build the main project first, and then you can use the latest changed nuget package's code on the main project.
And if you want to restore to use the previous version of the nuget package, there is no way but you only have to install that version manually under Nuget Package Management.
Upvotes: 2