dsplaisted / strongnamer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

StrongNamer 0.2.5 : "StrongNamer.AddStrongName" task failed unexpectedly.

jzabroski opened this issue · comments

Using the old csproj file format with the old nuget packages.config approach fails under the below conditions. (In my case, I cannot upgrade to the new csproj file format because I'm packaging the target exe with Wix 3.11, which reads the old csproj file format to construct the dependencies for the Msi Installer. This puts me in a weird loop where there is no solution to my problem.):

  1. Target .NET Framework 4.8
  2. Add StrongNamer 0.2.5 to packages.config:
<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="StrongNamer" version="0.2.5" targetFramework="net48" />
  <package id="YourUnsignedPackage" version="1.1.129.1024" targetFramework="net48" />
</packages>

Resulting error in VisualStudio

Attempt 1:

Severity Code Description Project File Line Suppression State
Warning - The "StrongNamer.AddStrongName" task failed unexpectedly.
System.MissingMethodException: Method not found: 'Void Mono.Cecil.WriterParameters.set_StrongNameKeyBlob(Byte[])'.
at StrongNamer.AddStrongName.ProcessAssembly(ITaskItem assemblyItem, Byte[] keyBytes, StrongNamerAssemblyResolver resolver)
at StrongNamer.AddStrongName.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()
SubscriberRTDAddin
Attempt 1 log:
Attempting to gather dependency information for package 'StrongNamer.0.2.5' with respect to project 'ExcelAddins\SubscriberRTDAddin', targeting '.NETFramework,Version=v4.8'
Gathering dependency information took 200.69 ms
Attempting to resolve dependencies for package 'StrongNamer.0.2.5' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'StrongNamer.0.2.5'
Resolved actions to install package 'StrongNamer.0.2.5'
Adding package 'StrongNamer.0.2.5' to folder 'D:\source\ETS_clean\trunk\Source\packages'
Added package 'StrongNamer.0.2.5' to folder 'D:\source\ETS_clean\trunk\Source\packages'
Added package 'StrongNamer.0.2.5' to 'packages.config'
Successfully installed 'StrongNamer 0.2.5' to SubscriberRTDAddin
Executing nuget actions took 1.74 sec
Time Elapsed: 00:00:02.2704802
========== Finished ==========

Attempt 2 (without restarting Visual Studio):

Severity Code Description Project File Line Suppression State
Error - The process cannot access the file 'D:\source\ETS_clean\trunk\Source\packages\StrongNamer.0.2.5\build/net461/StrongNamer.dll' because it is being used by another process.
Attempt 2 log:
Attempting to gather dependency information for package 'StrongNamer.0.2.5' with respect to project 'ExcelAddins\SubscriberRTDAddin', targeting '.NETFramework,Version=v4.8'
Gathering dependency information took 6.09 ms
Attempting to resolve dependencies for package 'StrongNamer.0.2.5' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'StrongNamer.0.2.5'
Resolved actions to install package 'StrongNamer.0.2.5'
Adding package 'StrongNamer.0.2.5' to folder 'D:\source\ETS_clean\trunk\Source\packages'
Install failed. Rolling back...
Package 'StrongNamer.0.2.5' does not exist in project 'SubscriberRTDAddin'
Package 'StrongNamer.0.2.5' does not exist in folder 'D:\source\ETS_clean\trunk\Source\packages'
Executing nuget actions took 921.32 ms
System.IO.IOException: The process cannot access the file 'D:\source\ETS_clean\trunk\Source\packages\StrongNamer.0.2.5\build/net461/StrongNamer.dll' because it is being used by another process.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost)
   at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite)
   at NuGet.Packaging.PackageFileExtractor.ExtractPackageFile(String source, String target, Stream stream)
   at NuGet.Packaging.PackageFolderReader.CopyFiles(String destination, IEnumerable`1 packageFiles, ExtractPackageFileDelegate extractFile, ILogger logger, CancellationToken token)
   at NuGet.Packaging.PackageReaderBase.CopyFilesAsync(String destination, IEnumerable`1 packageFiles, ExtractPackageFileDelegate extractFile, ILogger logger, CancellationToken cancellationToken)
   at NuGet.Packaging.PackageExtractor.<ExtractPackageAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at NuGet.ProjectManagement.FolderNuGetProject.<>c__DisplayClass13_0.<<InstallPackageAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.Common.ConcurrencyUtilities.<ExecuteWithFileLockedAsync>d__2`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at NuGet.ProjectManagement.MSBuildNuGetProject.<InstallPackageAsync>d__36.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.PackageManagement.NuGetPackageManager.<ExecuteInstallAsync>d__85.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at NuGet.PackageManagement.NuGetPackageManager.<ExecuteNuGetProjectActionsAsync>d__76.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at NuGet.PackageManagement.NuGetPackageManager.<ExecuteNuGetProjectActionsAsync>d__76.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at NuGet.PackageManagement.NuGetPackageManager.<ExecuteNuGetProjectActionsAsync>d__76.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.PackageManagement.NuGetPackageManager.<ExecuteNuGetProjectActionsAsync>d__75.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at NuGet.PackageManagement.NuGetPackageManager.<ExecuteNuGetProjectActionsAsync>d__74.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.PackageManagement.UI.UIActionEngine.<ExecuteActionsAsync>d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at NuGet.PackageManagement.UI.UIActionEngine.<>c__DisplayClass12_0.<<PerformActionImplAsync>b__0>d.MoveNext()
Time Elapsed: 00:00:00.9565207
========== Finished ==========

Attempt 3: Restart Visual Studio

Result: Go to Attempt 1.

@jzabroski Just to double-check: This Excel add-in you're signing with StrongNamer is not an Excel-DNA add-in at the moment, correct? I only ask because we're in the process of signing all Excel-DNA assemblies with a strong-name, which will remove the need to use StrongNamer in Excel-DNA add-in projects.

I don't use ExcelDNA. I use pure COM, except for one plug-in which is legacy and uses Add-In-Express.

For what it's worth, I got this working by very carefully adding StrongNamer, one-by-one, working my way "down (up?) the project tree" until everything was signed.

I can only speculate what the root cause may have been:

  • Was it that I had Register for COM Interop accidentally checked in the project properties? I don't know, this ticket is months old.
  • Was it that I moved from the old csproj file format to the new csproj file format? Probably that is what fixed things for me, as there may be issues with package restore in a solution where it uses a mix of old way and new way to do things.

Closed as I dont expect anyone to invest time trying to fix or even reproduce this.