Package not found in primary source when importing same Addin twice
- Dominant language
- C#
- Stars
- 4.2k
- Forks
- 778
- Avg merge
- 1h 15m
- Merged PRs (30d)
- 19
Description
### What You Are Seeing?
When adding an Addin from two different cake files, the second #load fails with "Error: Package 'Cake.Kudu 0.10.0' is not found in the following primary source(s): 'C:/tmp/cake-double-import/tools/Addins'. Please verify all your online package sources are available (OR) package id, version are specified correctly."
At the time of the second import the first cake script was imported, the addin downloaded to the Addins folder.
### What is Expected?
That both imports work, seeing that the first pushed the package into the Addins folder.
### What version of Cake are you using?
0.30.0 - 0.33.0
Repro repo is with 0.33.0, our production environment has the same issue on 0.30.0 however
### Are you running on a 32 or 64 bit system?
64bit
### What environment are you running on? Windows? Linux? Mac?
Windows 10 locally, Windows Server 2016 on production
### Are you running on a CI Server? If so, which one?
Teamcity (we're cleaning the cache and do a clean checkout before every run - which makes more problems.)
### How Did You Get This To Happen? (Steps to Reproduce)
Repro repo: https://github.com/asci13/cake-double-import
1. Clone repo
2. run build.ps1
The error occurs the first time, make sure to clean the repo (or just delete the Addins folder) before doing another run.
### Output Log
~~~sh
PS C:\tmp\cake-double-import> .\build.ps1 -Verbosity=Diagnostic
Module directory does not exist.
NuGet.config not found.
Analyzing build script...
Analyzing C:/tmp/cake-double-import/build.cake...
Analyzing C:/tmp/cake-double-import/feature1.cake...
Analyzing C:/tmp/cake-double-import/feature2.cake...
Processing build script...
Installing addins...
The 'addin' directive is attempting to install the 'Cake.Kudu' package
without specifying a package version number.
More information on this can be found at https://cakebuild.net/docs/tutorials/pinning-cake-version
It's not recommended, but you can explicitly override this warning
by configuring the Skip Package Version Check setting to true
(i.e. command line parameter "--settings_skippackageversioncheck=true",
environment variable "CAKE_SETTINGS_SKIPPACKAGEVERSIONCHECK=true",
read more about configuration at https://cakebuild.net/docs/fundamentals/configuration)
CACHE https://www.nuget.org/api/v2/FindPackagesById()?id='Cake.Kudu'&semVerLevel=2.0.0
CACHE https://www.nuget.org/api/v2/Packages(Id='Cake.Kudu',Version='0.10.0')
Total number of results gathered : 3
Gathering dependency information took 68.22 ms
Summary of time taken to gather dependencies per source :
C:/tmp/cake-double-import/tools/Addins - 8.55 ms
https://www.nuget.org/api/v2 - 18.31 ms
c:\nuget\ - 9.24 ms
Resolving dependency information took 0 ms
Retrieving package 'Cake.Kudu 0.10.0' from 'c:\nuget\'.
Adding package 'Cake.Kudu.0.10.0' to folder 'C:\tmp\cake-double-import\tools\Addins'
Added package 'Cake.Kudu.0.10.0' to folder 'C:\tmp\cake-double-import\tools\Addins'
Added package 'Cake.Kudu.0.10.0' to folder 'C:\tmp\cake-double-import\tools\Addins' from source 'c:\nuget\'
Successfully installed 'Cake.Kudu 0.10.0' to C:/tmp/cake-double-import/tools/Addins
Executing nuget actions took 287.58 ms
The addin Cake.Kudu will reference Cake.Kudu.dll.
The 'addin' directive is attempting to install the 'Cake.Kudu' package
without specifying a package version number.
More information on this can be found at https://cakebuild.net/docs/tutorials/pinning-cake-version
It's not recommended, but you can explicitly override this warning
by configuring the Skip Package Version Check setting to true
(i.e. command line parameter "--settings_skippackageversioncheck=true",
environment variable "CAKE_SETTINGS_SKIPPACKAGEVERSIONCHECK=true",
read more about configuration at https://cakebuild.net/docs/fundamentals/configuration)
CACHE https://www.nuget.org/api/v2/FindPackagesById()?id='Cake.Kudu'&semVerLevel=2.0.0
Package Cake.Kudu from source C:/tmp/cake-double-import/tools/Addins gathered from cache.
Total number of results gathered : 1
Error: System.InvalidOperationException: Package 'Cake.Kudu 0.10.0' is not found in the following primary source(s): 'C:/tmp/cake-double-import/tools/Addins'. Please verify all your online package sources are available (OR) package id, version are specified correctly.
at NuGet.PackageManagement.ResolverGather.GatherAsync(CancellationToken token)
at NuGet.PackageManagement.ResolverGather.GatherAsync(GatherContext context, CancellationToken token)
at Cake.NuGet.Install.Extensions.NuGetPackageManagerExtensions.GetAvailablePackageDependencies(NuGetPackageManager packageManager, NuGetFolderProject nuGetProject, PackageIdentity packageIdentity, ResolutionContext resolutionContext, INuGetProjectContext nuGetProjectContext, ISet`1 primarySources, ISet`1 allSources, CancellationToken token) in C:\projects\cake\src\Cake.NuGet\Install\Extensions\NuGetPackageManagerExtensions.cs:line 259
at Cake.NuGet.Install.Extensions.NuGetPackageManagerExtensions.GetPackageAndDependenciesToInstall(NuGetPackageManager packageManager, NuGetFolderProject nuGetProject, PackageIdentity packageIdentity, ResolutionContext resolutionContext, INuGetProjectContext nuGetProjectContext, ISet`1 primarySources, ISet`1 allSources, CancellationToken token) in C:\projects\cake\src\Cake.NuGet\Install\Extensions\NuGetPackageManagerExtensions.cs:line 199
at Cake.NuGet.Install.Extensions.NuGetPackageManagerExtensions.GetInstallProjectActionsAsync(NuGetPackageManager packageManager, NuGetFolderProject nuGetProject, PackageIdentity packageIdentity, ResolutionContext resolutionContext, INuGetProjectContext nuGetProjectContext, IEnumerable`1 primarySourceRepositories, IEnumerable`1 secondarySourceRepositories, CancellationToken token) in C:\projects\cake\src\Cake.NuGet\Install\Extensions\NuGetPackageManagerExtensions.cs:line 107
at Cake.NuGet.Install.NuGetPackageInstaller.Install(PackageReference package, PackageType type, DirectoryPath path) in C:\projects\cake\src\Cake.NuGet\Install\NuGetPackageInstaller.cs:line 130
at Cake.Core.Scripting.ScriptProcessor.InstallAddins(IReadOnlyCollection`1 addins, DirectoryPath installPath) in C:\projects\cake\src\Cake.Core\Scripting\ScriptProcessor.cs:line 101
at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary`2 arguments) in C:\projects\cake\src\Cake.Core\Scripting\ScriptRunner.cs:line 152
at Cake.Commands.BuildCommand.Execute(CakeOptions options) in C:\projects\cake\src\Cake\Commands\BuildCommand.cs:line 41
at Cake.CakeApplication.Run(CakeOptions options) in C:\projects\cake\src\Cake\CakeApplication.cs:line 45
at Cake.Program.Main() in C:\projects\cake\src\Cake\Program.cs:line 73
~~~
Contributor guide
Research direction
Run build.ps1 from the linked cake-double-import reproduction after deleting tools/Addins. Start with Cake.Core/Scripting/ScriptProcessor.cs and the package-installation methods in Cake.NuGet/Install/Extensions/NuGetPackageManagerExtensions.cs shown in the trace. Done means both Cake.Kudu imports succeed after a clean run without the primary-source error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, powershell
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 28/100