I am trying to write a PowerShell script to update my .nuspec (nuget depdency) file to the latest build version. I'm having problems with wildcards.
So I want to replace the version number of this line
<dependency id="MyCompany.Common" version="1.0.0.0" />
to the new version number, i.e. version 2.2.2.2
<dependency id="MyCompany.Common" version="2.2.2.2" />
My current place method looks like this. Note. I need to have a wildcard, as I have several nuget packages in the solution I need to replace, all follow the format MyCompany.PackageName
$filecontent -replace 'id="MyCompany.*" version="*"', "$Version" | Out-File $file
But it actually ends up creating
<dependency 2.2.2.21.0.0.0" />
How to change my regex so that it only replaces the version number?
Chris source share