Greg
Greg

Reputation: 4055

Solution uses PackageReference, but getting compile error referencing packages.config

My solution has two projects - proj1 and proj2, which references proj1. I just converted the solution from packages.config to PackageReference, now when I build the solution, proj2 fails to compile with error:

Could not locate C:\Users...\source\repos\project\proj1\packages.config. Ensure that this project has Microsoft.Bcl.Build installed and packages.config is located next to the project file

I looked at the .csproj files, and there are zero references to any packages folder.

If I remove the nuget package Microsoft.Bcl.Build from proj2, it compiles successfully but I get a warning saying any project that references proj1 must install that package.

Am I safe to remove it and ignore the warning? Otherwise i'm not sure why it's referencing packages.config file when i'm using PackageReference.

This is on latest VS 2019.

Upvotes: 9

Views: 9519

Answers (2)

LoLance
LoLance

Reputation: 28216

Am I safe to remove it and ignore the warning?

This could be an BCL nuget package issue(last update 2014). The package itself checks packages.config by mistake. If you use the new PackageReference(comes after VS2017) package management format, this error will happen.

So if your projects don't depend on that package, you can feel free to remove them all. Also you can try to suppress the warning by adding <SkipValidatePackageReferences>true</SkipValidatePackageReferences> to top of the xx.csproj file. Hint from this issue.

Upvotes: 23

AbhijeetGaikwad
AbhijeetGaikwad

Reputation: 131

Remove your package folder and build the solution. It worked for me.

Upvotes: 3

Related Questions