From c66019ddd8cf3e1a4bd7b7f432197a7dccbc2f65 Mon Sep 17 00:00:00 2001 From: Stephen Klancher Date: Sun, 9 May 2021 17:13:04 -0700 Subject: [PATCH] Fixes NullReferenceException when using TunnelVisionLabs.ReferenceAssemblyAnnotator --- .../StrongNameSigner.nuspec | 2 +- src/Brutal.Dev.StrongNameSigner/AutomaticBuildTask.cs | 8 ++++++-- .../Brutal.Dev.StrongNameSigner.csproj | 8 ++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Brutal.Dev.StrongNameSigner.Setup/StrongNameSigner.nuspec b/src/Brutal.Dev.StrongNameSigner.Setup/StrongNameSigner.nuspec index a50deb5..8792777 100644 --- a/src/Brutal.Dev.StrongNameSigner.Setup/StrongNameSigner.nuspec +++ b/src/Brutal.Dev.StrongNameSigner.Setup/StrongNameSigner.nuspec @@ -2,7 +2,7 @@ Brutal.Dev.StrongNameSigner - 2.7.1 + 2.7.2 .NET Assembly Strong-Name Signer Werner van Deventer Werner van Deventer diff --git a/src/Brutal.Dev.StrongNameSigner/AutomaticBuildTask.cs b/src/Brutal.Dev.StrongNameSigner/AutomaticBuildTask.cs index d96e1b3..f318065 100644 --- a/src/Brutal.Dev.StrongNameSigner/AutomaticBuildTask.cs +++ b/src/Brutal.Dev.StrongNameSigner/AutomaticBuildTask.cs @@ -94,10 +94,13 @@ public override bool Execute() if (!signedAssembly.IsSigned) { signedAssembly = SignSingleAssembly(References[i].ItemSpec, snkFilePath, signedAssemblyFolder, probingPaths); - chagesMade = true; + if(signedAssembly != null) + { + chagesMade = true; + } } - if (signedAssembly.IsSigned) + if (signedAssembly != null && signedAssembly.IsSigned) { signedAssemblyPaths.Add(signedAssembly.FilePath); processedAssemblyPaths.Add(signedAssembly.FilePath); @@ -185,6 +188,7 @@ private AssemblyInfo SignSingleAssembly(string assemblyPath, string keyPath, str else { Log.LogMessage(MessageImportance.Low, "Strong-name signature already applied to '{0}'...", assemblyPath); + Log.LogMessage(MessageImportance.Low, "Original assembly IsSigned: {0}, After signing attempt IsSigned: {1}", oldInfo.IsSigned.ToString(), newInfo.IsSigned.ToString()); } } catch (BadImageFormatException ex) diff --git a/src/Brutal.Dev.StrongNameSigner/Brutal.Dev.StrongNameSigner.csproj b/src/Brutal.Dev.StrongNameSigner/Brutal.Dev.StrongNameSigner.csproj index 43bff83..70220a4 100644 --- a/src/Brutal.Dev.StrongNameSigner/Brutal.Dev.StrongNameSigner.csproj +++ b/src/Brutal.Dev.StrongNameSigner/Brutal.Dev.StrongNameSigner.csproj @@ -104,4 +104,12 @@ + + REM requires installing nuget commandline. example using chocolatey: +REM choco install nuget.commandline +REM note: output dir cannot end in slash +if /I "$(ConfigurationName)" == "Release" nuget.exe pack $(ProjectDir)..\Brutal.Dev.StrongNameSigner.Setup\StrongNameSigner.nuspec -Properties "Configuration=$(Configuration)" -NonInteractive -OutputDirectory "$(ProjectDir)bin\$(ConfigurationName) + +if /I "$(ConfigurationName)" == "Release" "$(SystemRoot)\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" /p:CleanIntermediates=True /p:Configuration=Release "$(SolutionDir)Brutal.Dev.StrongNameSigner.Docs\Documentation.shfbproj" + \ No newline at end of file