'Jenkins MSBuild fails, error NETSDK1064: Package Microsoft.CodeAnalysis.Analyzers, version 2.9.3 was not found
I am trying to deploy a sample aspnet core project but Jenkins build fails.
C:\Program Files\dotnet\sdk\3.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(234,
5): error NETSDK1064: Package Microsoft.CodeAnalysis.Analyzers, version 2.9.3 was not found. It might have
been deleted since NuGet restore. Otherwise, NuGet restore might have only partially completed, which
might have been due to maximum path length restrictions. [C:\Program Files
(x86)\Jenkins\workspace\test\ProductCoreApi\ProductCoreApi.csproj]
I'm using VS2019. I removed and reinstalled the package and tried all possible measures. Still unable to get an idea of what went wrong. The project is in github. Any idea on what went wrong?
Solution 1:[1]
Solution 2:[2]
ok so for me it turned out that the jenkins slave I was running under the system account instead of Admin account.
Solution 3:[3]
I encountered a similar problem when trying to build a solution through an MSBuild script.
There's a problematic section in one of the .csproj
files:
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
....
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.Analyzers.2.9.4"...>
</Error>
...
</Target>
When it was removed, I could continue running the build. The packages it complains about are all there.
Solution 4:[4]
Solution 5:[5]
I removed all Nuget packages with this command
dotnet nuget locals --clear all
Then rebuild my solution again.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Omid Rahimi |
Solution 2 | Ovi |
Solution 3 | Paul |
Solution 4 | Malik |
Solution 5 | Salar Afshar |