Adding the question for anyone in the future that needs to resolve the same problem
Environment: Visual Studio 2017 or 2019
Build error from Postsharp signing the assembly
MSBuild postsharptest.csproj /T:Rebuild /P:PostSharpTrace=StrongName /V:D /P:PostSharpHost=Native > postsharp.log
C:\ProgramData\PostSharp\4.0.41\bin.Release\postsharp.4.0-x86.exe obj\Debug\Before-PostSharp\PostsharpTest.exe /X:default /NoLogo /P:Output=C:\PostsharpTest\obj\Debug\PostsharpTest.exe /P:ReferenceDirectory=C:\PostsharpTest /P:Configuration=Debug /P:Platform=AnyCPU "/P:SearchPath=bin\Debug\|obj\Debug\|C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\|C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Facades\ " /P:IntermediateDirectory=obj\Debug\PostSharp /P:CleanIntermediate=False /P:MSBuildProjectFullPath=C:\PostsharpTest\postsharptest.csproj /P:SignAssembly=true /P:PrivateKeyLocation=Thycotic.snk /P:PrivateKeyContainer= /P:DelaySign= "/P:ResolvedReferences=C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Microsoft.CSharp.dll|C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll|C:\PostsharpTest\packages\PostSharp.4.0.41\lib\net35-client\PostSharp.dll|C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll|C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.DataSetExtensions.dll|C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.dll|C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll|C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.dll|C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.dll|C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.Linq.dll" /P:SymbolFile=bin\Debug\PostsharpTest.pssym /P:WriteWeavingSymbols=True /P:ConstraintVerificationEnabled=True /P:RuntimeVerificationEnabled=True /P:TargetFrameworkVersion=v4.5 /P:TargetFrameworkIdentifier=.NETFramework /P:TargetFrameworkProfile= "/P:TargetFrameworkMoniker=.NETFramework,v4.5" "/P:NativeFrameworkMoniker=.NETFramework,v4.5.1" /P:BindingMapsDirectory=C:\ProgramData\PostSharp\4.0.41\BindingMaps /P:PostSharpLibraryProfile= /P:AspectProviders= "/P:Language=C#" /T:StrongName /config C:\ProgramData\PostSharp\4.0.41\bin.Release\postsharp.4.0-x86.exe.config
C:\PostsharpTest\postsharptest.csproj : warning PS0131: The project 'ModuleDeclaration PostsharpTest.exe' does not contain any aspect or other transformation. You can disable PostSharp for this project by editing the project properties in Visual Studio. Remember to enable PostSharp back if you add an aspect to this project.
C:\PostsharpTest\postsharptest.csproj : error PS0099: Unhandled exception (4.0.41.0, 32 bit, CLR 4.5, Release): System.Runtime.InteropServices.COMException (0x8013141C): Strong name key container not found. (Exception from HRESULT: 0x8013141C)
C:\PostsharpTest\postsharptest.csproj : error PS0099: at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
C:\PostsharpTest\postsharptest.csproj : error PS0099: at ^nIsIyZ7TTJqY.GetKeyInfo(^8gP93Xsl\+Imn _0)
C:\PostsharpTest\postsharptest.csproj : error PS0099: at ^Up6wxUIUnN6a.^3w8852HL()
C:\PostsharpTest\postsharptest.csproj : error PS0099: at ^Up6wxUIUnN6a.^VfvrABjR()
C:\PostsharpTest\postsharptest.csproj : error PS0099: at ^Up6wxUIUnN6a.^SkiT()
C:\PostsharpTest\postsharptest.csproj : error PS0099: at ^Up6wxUIUnN6a.^8KD6D2SV(String _0)
C:\PostsharpTest\postsharptest.csproj : error PS0099: at ^cyC/TYSlPGB/.^wvPm(^RtksFin57NJ8 _0, ^8gP93Xsl\+Imn _1)
C:\PostsharpTest\postsharptest.csproj : error PS0099: at PostSharp.Sdk.Extensibility.Tasks.CompileTask.Execute()
C:\PostsharpTest\postsharptest.csproj : error PS0099: at PostSharp.Sdk.Extensibility.Project.ExecutePhase(String phase)
C:\PostsharpTest\postsharptest.csproj : error PS0099: at PostSharp.Sdk.Extensibility.Project.Execute()
C:\PostsharpTest\postsharptest.csproj : error PS0099: at PostSharp.Hosting.PostSharpObject.ExecuteProjects()
C:\PostsharpTest\postsharptest.csproj : error PS0099: at PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation).
I was able to resolve the problem when attempting to create a new signing key with Microsoft's Strong Name Tool (SN.exe), I was getting an access denied error.
sn -k jeff.snk
Failed to generate a strong name key pair -- Access is denied.
Using Process Monitor showed me the problem was access denied to a specific file in C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys
. After giving myself permission to all files in the directory I was able to create the signing key and run the msbuild without any errors.
User contributions licensed under CC BY-SA 3.0