doorman
doorman

Reputation: 16959

Roslyn, restore nuget's packages folder

I am using Roslyn to parse a solution that depends on nuget's. It seems that Roslyn gathers information based on the restored nuget files located in the packages folder of the solution. In my case I am getting information about the references nuget that is being called in the solution.

However since I am pulling the source code from Azure Devops the packages folder is not part of the files.

Is there way that Roslyn could restore the nuget packages folder for the solution?

Upvotes: 1

Views: 993

Answers (2)

GiampaoloGabba
GiampaoloGabba

Reputation: 1458

The only way i found that always work is:

Update-Package -reinstall

If you just run Update-Package, it will try to update all packages to the latest version, which isn’t necessarily what you want. But with -reinstall all the refrenced nuget package will be downloaded and installed using the right version specified in the project.

You can also launch the command for a specific project:

Update-Package -reinstall -Project ProjectName

Unfortunately for some reason the nuget restore command never worked for me in similar scenarios

Upvotes: 2

Paulo Morgado
Paulo Morgado

Reputation: 14846

Roslyn only looks at the .csproj.

You need to do an nuget restore before building.

Upvotes: 2

Related Questions