I have a nuget package as SampleNugetPackage. Currently I am using version number 7.9.18 and am soon going to migrate to a higher version 7.10.18. The nuget package is to be utilized by hundreds of projects. I migrated my project to use Package reference instead of packages.config and got the following piece of code under my .csproj file:
<ItemGroup>
<PackageReference Include="SampleNugetPackage">
<Version>7.9.18</Version>
</PackageReference>
</ItemGroup>
Since the package is to be utilized by hundreds of projects, I can not go and manually upgrade the version there from 7.9.18 to 7.10.18 under each .csproj file. So, I am thinking of using a variable there. I tried using a property as "PackageVersion" by defining it under a property group as shown below:
<PropertyGroup>
<PackageVersion></PackageVersion>
</PropertyGroup>
And then tried using this property in the code as given below:
<ItemGroup>
<PackageReference Include="SampleNugetPackage">
<Version>$(PackageVersion)</Version>
</PackageReference>
</ItemGroup>
And then I am trying to build my project using the following command through command line: msbuild myproject.sln /p:PackageVersion=7.9.18 /t:rebuild But when trying to see whether the correct version has been added, using Visual Studio, I am unable to view the package when I click on "Manage Nuget Packages". Instead I see the following error:
By error, it is clear that the value passed to PackageVersion property is not being used by my nuget package, I am getting an empty string instead. My nuget package is located at the following path on my machine: "D:\CustomNugetPackages". Is there a way to pass the nuget package's version value from the command line?