Skip to content

Commit d1b5a81

Browse files
Update package registration logic (#49566)
1 parent 8471913 commit d1b5a81

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

test/dotnet-new.IntegrationTests/DotnetNewTestTemplatesTests.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -281,15 +281,16 @@ private void RecordPackages(string projectDirectory)
281281
version = match.Groups[3].Value;
282282
}
283283

284-
// Find existing registration for this package or null if not found
284+
// Find existing registration for this package with the SAME VERSION
285285
var existingRegistration = manifest.Registrations?.FirstOrDefault(r =>
286286
r.Component != null &&
287287
r.Component.Nuget != null &&
288-
string.Equals(r.Component.Nuget.Name, packageId, StringComparison.OrdinalIgnoreCase));
288+
string.Equals(r.Component.Nuget.Name, packageId, StringComparison.OrdinalIgnoreCase) &&
289+
string.Equals(r.Component.Nuget.Version, version, StringComparison.OrdinalIgnoreCase));
289290

290291
if (existingRegistration == null)
291292
{
292-
// Add new package if it doesn't exist
293+
// Add new package if it doesn't exist with this version
293294
manifest.Registrations?.Add(new Registration
294295
{
295296
Component = new Component
@@ -304,12 +305,6 @@ private void RecordPackages(string projectDirectory)
304305
});
305306
updatedManifest = true;
306307
}
307-
else if (existingRegistration.Component?.Nuget?.Version != version)
308-
{
309-
// Update version if it's different from the existing one
310-
existingRegistration.Component?.Nuget?.Version = version;
311-
updatedManifest = true;
312-
}
313308
}
314309
}
315310

0 commit comments

Comments
 (0)