usatek
usatek

Reputation: 115

update or downgrade .csproj file after nuget restore packages from packages.config

I have many VSTS builds which has reference to one nuget package. Depending on primiary build we have to sometimes to upgrade/downgrade nuget package in VSTS build. We are doing this by copying packages.config with proper version, then we use nuget restore. My problem is that after upgrade/downgrade of nuget package .csproj file still have old version od package reference, so when build starts it still try to search for old reference from .csproj file and build fails.

I there any way to change .csproj file after nuget restore?

Upvotes: 1

Views: 1378

Answers (1)

Marina Liu
Marina Liu

Reputation: 38116

No, there is no way to update the .csproj during the build. You should change the .csproj locally and then build in VSTS.

Except the way manually changed the .csproj file, there has an easier way to change package versions correspondingly in .csproj. Execute below command in Package Manager Console window:

update-package -reinstall

So the workflow to use upgrade/downgrade nuget package version as below:

  1. Change the versions in package.config file.
  2. Run the command update-package -reinstall in in Package Manager Console window.
  3. Commit and push/checkin the changes to remote repo.
  4. Build your project in VSTS with the upgrade/downgrade nuget package version reference.

Upvotes: 2

Related Questions