| Severity | Warning |
| Reported by | PostSharp |
| Message | Cannot parse the package info for <AssemblyPath>: <Reason> |
Cause
For each assembly that the project references, PostSharp determines whether the assembly comes from a NuGet package: it looks for a .nuspec or a .nupkg file in the parent folders of the assembly, below a lib, ref, build or runtimes folder, as in the global packages folder of NuGet (by default %USERPROFILE%\.nuget\packages). It then reads the id and the version of the package from this file.
PostSharp reports PS0270 when the file gives no package id or no version. <AssemblyPath> is the path of the referenced assembly, and <Reason> is Invalid package identity or package version. PostSharp then handles the assembly as if it did not come from a package, and the build goes on.
This usually happens when a package was not fully extracted, or when its .nuspec file was edited or truncated. The message depends on the content of the package folders of the machine, so no example can show it.
Resolution
- Open the
.nuspecfile in the package folder of<AssemblyPath>, and check that itsmetadataelement has anidand aversion. - When the package comes from the global packages folder, delete the folder of this package version, or clear the cache with
dotnet nuget locals global-packages --clear, and restore the project again. - When the package is one that you create, add the
idandversionelements to its.nuspecfile, or thePackageIdandVersionproperties to its project, and pack it again.
To see which files PostSharp reads for each reference, capture the AssemblyBinder trace category with the PostSharpTrace MSBuild property, as Well-Known MSBuild Properties describes.
See Also
Other Resources
Well-Known MSBuild Properties
Resolution of Assembly Binding Redirections