0

I've got a kind of 'rolling update' policy for nugets:

<ItemGroup>
  <PackageReference Include="AutoMapper" Version="12.*" />
...
</ItemGroup>

In addition, I have packages.lock.json with specific versions. Now the release time comes. I will cut the release branch and I need to 'freeze' nuget versions for a month in a release branch. Question: can I do some magic trick and set specific strict version of the nuget package for release branch, something like:

<PackageReference Include="AutoMapper" Version="12.*" /> + packages.lock.json + some command -> <PackageReference Include="AutoMapper" Version="12.0.4" />
4
  • Note: <PackageReference Include="AutoMapper" Version="12.0.4" /> is not a strict version rule; that would be Version="[12.0.4]" Commented Nov 1, 2024 at 14:08
  • Do you mean you want use some command to update PackageReference from float version to strict one instead of manually modifying ? Commented Nov 4, 2024 at 8:58
  • @DouXu-MSFT yes if this is possible. Commented Nov 4, 2024 at 11:17
  • Hi @SergeyShafiev, did you try Package Manager Console commands to achieve it? Commented Nov 12, 2024 at 5:53

1 Answer 1

0

If you want update .csproj PackageReference from float version to strict one via some command, you can use Package Manager Console commands to achieve it.

Update-Package  AutoMapper -Version 13.0.1

After running above command, it will automatically update the following files:

project file

<ItemGroup>
  <PackageReference Include="AutoMapper" Version="12.0.4" />
</ItemGroup>

packages.lock.json file

 "AutoMapper": {
        "type": "Direct",
        "requested": "[12.0.4, )",
        "resolved": "12.0.4"
  }

Docs Referred: Update-Package (Package Manager Console in Visual Studio)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.