diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs index c9be7c90e26..0c1a9c39a81 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs @@ -603,8 +603,12 @@ await TestUpdateForProject("Some.Package", "7.0.1", "13.0.1", ); } - [Fact] - public async Task UpdateBindingRedirectInWebConfig() + // the xml can take various shapes and they're all formatted, so we need very specific values here + [Theory] + [InlineData("")] + [InlineData("\n ")] + [InlineData("\n Designer\n ")] + public async Task UpdateBindingRedirectInWebConfig(string webConfigXml) { await TestUpdateForProject("Some.Package", "7.0.1", "13.0.1", packages: @@ -612,7 +616,7 @@ await TestUpdateForProject("Some.Package", "7.0.1", "13.0.1", MockNuGetPackage.CreatePackageWithAssembly("Some.Package", "7.0.1", "net45", "7.0.0.0"), MockNuGetPackage.CreatePackageWithAssembly("Some.Package", "13.0.1", "net45", "13.0.0.0"), ], - projectContents: """ + projectContents: $$""" Debug @@ -669,7 +673,7 @@ await TestUpdateForProject("Some.Package", "7.0.1", "13.0.1", - + {{webConfigXml}} web.config @@ -711,7 +715,7 @@ await TestUpdateForProject("Some.Package", "7.0.1", "13.0.1", """) ], - expectedProjectContents: """ + expectedProjectContents: $$""" Debug @@ -768,7 +772,7 @@ await TestUpdateForProject("Some.Package", "7.0.1", "13.0.1", - + {{webConfigXml}} web.config diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs index f156e1506c5..bfc669b9e59 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs @@ -116,19 +116,19 @@ static void AddConfigFileToProject(ProjectBuildFile projectBuildFile, Configurat return null; } - var configFilePath = Path.GetFullPath(Path.Combine(directoryPath, GetContent(configFile))); + var configFilePath = Path.GetFullPath(Path.Combine(directoryPath, GetValue(configFile))); var configFileContents = await File.ReadAllTextAsync(configFilePath); return new ConfigurationFile(configFilePath, configFileContents, false); - static string GetContent(IXmlElementSyntax element) + static string GetValue(IXmlElementSyntax element) { - var content = element.GetContentValue(); + var content = element.GetAttributeValue("Include"); if (!string.IsNullOrEmpty(content)) { return content; } - content = element.GetAttributeValue("Include"); + content = element.GetContentValue(); if (!string.IsNullOrEmpty(content)) { return content; @@ -139,7 +139,7 @@ static string GetContent(IXmlElementSyntax element) static bool IsConfigFile(IXmlElementSyntax element) { - var content = GetContent(element); + var content = GetValue(element); if (content is null) { return false;