I have a .Net solution which has many projects. One of the projects in the solution has a Package Reference element as shown below.
<PackageReference Include="MyPackage" Version="*" GeneratePathProperty="true" />
I have msbuild command as follows
msbuild MyCustom.sln -verbosity:m -t:restore,clean,build /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=MyPublishProfile /p:WarningLevel=0 /p:DebugSymbols=false
MyPackage nuget package is uploaded to a Nuget source (JFrog Artifactory Nuget repo). In this, I have 5 versions of a package uploaded there. Just a day ago, I uploaded version 6 with some changes.
I have 2 different Jenkins jobs running on the same server which use MyPackage. One job was created a little earlier and the other job was created a day ago. Even though I have uploaded version 6, the first job created earlier is using version 5, even if
we specify "restore" target in the msbuild command.
I understand that Package Reference installs the package to %USERPROFILE%\.nuget\packages\MyPackage folder.
I referred the following link.
https://docs.microsoft.com/en-us/nuget/consume-packages/managing-the-global-packages-and-cache-folders
As per this, there are various levels of caching which can be cleared. But for me, only nuget locals global-packages -clear is working. But this is an issue for me because it the PackageReference path is a common path for other jobs which might break, as
this command deletes the whole packages folder. Also, it is possible that some other project / job might still need to use version 5. Other cache clearing options from the above link are not working for me. I am confused.
I also tried other variations on the msbuild command like below.
msbuild MyCustom.sln -verbosity:m -t:restore,clean,build /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=MyPublishProfile /p:WarningLevel=0 /p:DebugSymbols=false /p:RestoreForce="true"
msbuild MyCustom.sln -verbosity:m -t:clean,build /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=MyPublishProfile /p:WarningLevel=0 /p:DebugSymbols=false /restore
msbuild MyCustom.sln -verbosity:m -t:clean,build /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=MyPublishProfile /p:WarningLevel=0 /p:DebugSymbols=false /restore /p:RestoreForce="true"
But it doesn't seem to be working.
Note: I don't want to delete existing packages or even existing versions of a package. I just want to make sure the latest version is downloaded / installed into the packages location when restore is called and when version in PackageReference element is
specified as *.
Can anyone please help me?
Ven