Skip to content

Commit 36e0fcb

Browse files
authoredMar 19, 2025
Add VerifyGenerateScript support for packages with customizations (#1202)
* Add VerifyGenerateScript support for packages with customizations * Update tests/SbrpTests/GenerateScriptTests.cs
1 parent 5af41f8 commit 36e0fcb

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed
 

‎tests/SbrpTests/GenerateScriptTests.cs

+15-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public enum PackageType
2323
{
2424
new object[] { "Microsoft.Build.NoTargets", "3.7.0", PackageType.Text },
2525
new object[] { "Microsoft.Extensions.Logging.Abstractions", "6.0.4", PackageType.Reference },
26-
new object[] { "NuGet.Protocol", "6.12.1", PackageType.Reference },
26+
new object[] { "NuGet.Packaging", "6.12.1", PackageType.Reference },
2727
new object[] { "System.Buffers", "4.6.0", PackageType.Reference },
2828
new object[] { "System.Security.Cryptography.ProtectedData", "8.0.0", PackageType.Reference },
2929
};
@@ -64,14 +64,27 @@ public void VerifyGenerateScript(string package, string version, PackageType typ
6464

6565
ExecuteHelper.ExecuteProcessValidateExitCode(command, arguments, Output);
6666

67+
// Copy any customization files from the source directory to the sandbox directory.
68+
// This is necessary because git diff doesn't support exclusions when comparing files outside of the repository.
69+
string[] customFiles = { "Customizations.cs", "Customizations.props" };
70+
foreach (string customFile in customFiles)
71+
{
72+
string srcFile = Path.Combine(pkgSrcDirectory, customFile);
73+
if (File.Exists(srcFile))
74+
{
75+
string destFile = Path.Combine(pkgSandboxDirectory, customFile);
76+
File.Copy(srcFile, destFile);
77+
}
78+
}
79+
6780
(Process Process, string StdOut, string StdErr) result =
6881
ExecuteHelper.ExecuteProcess("git", $"diff --no-index {pkgSrcDirectory} {pkgSandboxDirectory}", Output, true);
6982

7083
string diff = result.StdOut;
7184
if (diff != string.Empty)
7285
{
7386
Assert.Fail($"Regenerated package '{package}, {version}' does not match the checked-in content. {Environment.NewLine}"
74-
+ $"{diff}{Environment.NewLine}");
87+
+ $"{diff}{Environment.NewLine}");
7588
}
7689
else if (result.Process.ExitCode != 0)
7790
{

0 commit comments

Comments
 (0)