Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated NU1012 error message to display item paths #4843

Merged
merged 1 commit into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ private static void ValidateFileFrameworks(IEnumerable<IPackageFile> files)
};
var warnPaths = new HashSet<string>();

var frameworksMissingPlatformVersion = new HashSet<string>();
var itemsWithFrameworkMissingPlatformVersion = new HashSet<string>();
List<ContentItemGroup> targetedItemGroups = new();
foreach (var pattern in frameworkPatterns)
{
Expand All @@ -848,15 +848,15 @@ private static void ValidateFileFrameworks(IEnumerable<IPackageFile> files)

if (framework.HasPlatform && framework.PlatformVersion == FrameworkConstants.EmptyVersion)
{
frameworksMissingPlatformVersion.Add(framework.GetShortFolderName());
itemsWithFrameworkMissingPlatformVersion.Add(item.Path);
}
}
}
}

if (frameworksMissingPlatformVersion.Any())
if (itemsWithFrameworkMissingPlatformVersion.Any())
{
throw new PackagingException(NuGetLogCode.NU1012, string.Format(CultureInfo.CurrentCulture, Strings.MissingTargetPlatformVersionsFromIncludedFiles, string.Join(", ", frameworksMissingPlatformVersion.OrderBy(str => str))));
throw new PackagingException(NuGetLogCode.NU1012, string.Format(CultureInfo.CurrentCulture, Strings.MissingTargetPlatformVersionsFromIncludedFiles, string.Join(", ", itemsWithFrameworkMissingPlatformVersion.OrderBy(str => str))));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1509,15 +1509,15 @@ public void SavingPackageValidatesMissingTPVInFiles()
ExceptionAssert.Throws<PackagingException>(() => builder.Save(new MemoryStream()),
"Some included files are included under TFMs which are missing a platform version: " + string.Join(", ", new string[]
{
"net5.0-windows",
"net6.0-windows",
"net7.0-windows",
"net8.0-windows",
"net9.0-windows",
"net10.0-windows",
"net11.0-windows",
"net12.0-windows",
"net13.0-windows"
"lib/net5.0-windows/Foo.dll",
"ref/net6.0-windows/Foo.dll",
"runtimes/win7-x64/lib/net7.0-windows/Foo.dll",
"runtimes/win7-x64/nativeassets/net8.0-windows/Foo.dll",
"build/net9.0-windows/foo.props",
"contentFiles/csharp/net10.0-windows/Foo.txt",
"tools/net11.0-windows/win7-x64/Foo.exe",
"embed/net12.0-windows/Foo.dll",
"buildTransitive/net13.0-windows/foo.props"
}.OrderBy(str => str)));
}

Expand Down