Skip to content

Commit

Permalink
Fix #96 by adding support for excluding the path defined in NUGET_PAC…
Browse files Browse the repository at this point in the history
…KAGES and MSBuid paths.
  • Loading branch information
brutaldev committed Oct 23, 2023
1 parent 18fc07f commit 52890ed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/Brutal.Dev.StrongNameSigner.Setup/StrongNameSigner.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ The tool will also re-write the assembly references (as well as any InternalsVis
</description>
<summary>Automatic strong-name signing of referenced assemblies. Utility software to strong-name sign .NET assemblies, including assemblies you do not have the source code for.</summary>
<releaseNotes>
Fix #86 - Generic error handling to continue processing files that cause unusual errors.
Fix #89 - Ignore copy/overwrite failures if files are locked.
Fix #90 - Change the name of the "Signed" column to "Strong-named" to avoid confusion.
Fix #92 - Ignore custom attribute errors when it comes to assembly resolution.
PR #98 - Fix temp directory access when signing in parallel.
Fix #96 - Support for NUGET_PACKAGES environment variable.
</releaseNotes>
<copyright>Werner van Deventer (https://brutaldev.com)</copyright>
<language>en-US</language>
Expand Down
10 changes: 9 additions & 1 deletion src/Brutal.Dev.StrongNameSigner/AutomaticBuildTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ public override bool Execute()
}

var sep = Path.DirectorySeparatorChar;
var nugetPackagesEnvVariable = Environment.GetEnvironmentVariable("NUGET_PACKAGES");
if (string.IsNullOrEmpty(nugetPackagesEnvVariable))
{
// Just use the default check we already use.
nugetPackagesEnvVariable = $"{sep}.nuget{sep}packages{sep}";
}

if (References[i].ItemSpec.IndexOf($"{sep}Reference Assemblies{sep}Microsoft{sep}", StringComparison.OrdinalIgnoreCase) == -1 &&
References[i].ItemSpec.IndexOf($"{sep}Microsoft.NET{sep}Framework{sep}", StringComparison.OrdinalIgnoreCase) == -1 &&
Expand All @@ -77,7 +83,9 @@ public override bool Execute()
References[i].ItemSpec.IndexOf($"{sep}.nuget{sep}packages{sep}", StringComparison.OrdinalIgnoreCase) == -1 &&
References[i].ItemSpec.IndexOf($"{sep}dotnet{sep}sdk{sep}", StringComparison.OrdinalIgnoreCase) == -1 &&
References[i].ItemSpec.IndexOf($"{sep}dotnet{sep}packs{sep}", StringComparison.OrdinalIgnoreCase) == -1 &&
References[i].ItemSpec.IndexOf($"{sep}dotnet{sep}shared{sep}Microsoft.", StringComparison.OrdinalIgnoreCase) == -1)
References[i].ItemSpec.IndexOf($"{sep}dotnet{sep}shared{sep}Microsoft.", StringComparison.OrdinalIgnoreCase) == -1 &&
References[i].ItemSpec.IndexOf($"{sep}MSBuild{sep}Microsoft.NET.", StringComparison.OrdinalIgnoreCase) == -1 &&
References[i].ItemSpec.IndexOf(nugetPackagesEnvVariable, StringComparison.OrdinalIgnoreCase) == -1)
{
Log.LogMessage(MessageImportance.High, $"Adding '{References[i].ItemSpec}' for processing.");
assembliesToSign.Add(References[i].ItemSpec);
Expand Down

0 comments on commit 52890ed

Please sign in to comment.