I'm trying to compile a web project that is strongly-typed. The assembly is signed with a .snk file. Here's the log of the build:
1>Using "Csc" task from assembly "C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Build.Tasks.CodeAnalysis.dll".
1>Task "Csc"
1> D:\TFSONLINE\XXX\Dev\Source\packages\StackExchange.Precompilation.Build.3.2.1\build\..\tools\StackExchange.Precompiler.exe /noconfig /nowarn:1701,1702,2008 /nostdlib+ /errorreport:prompt /warn:4 /doc:bin\XXX.xml /define:DEBUG;TRACE /appconfig:Web.config /errorendlocation /preferreduilang:en-US /highentropyva+ /reference "ZZZ.dll" /debug+ /debug:full /keyfile:..\YYY.snk /optimize- /out:obj\Debug\XXX.dll /ruleset:..\XXX.ruleset /subsystemversion:6.00 /target:library /utf8output /analyzer:..\packages\Microsoft.CodeAnalysis.Analyzers.1.1.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll /analyzer:..\packages\Microsoft.CodeAnalysis.Analyzers.1.1.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll /analyzer:..\packages\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\Newtonsoft.Json.dll /analyzer:..\packages\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll /analyzer:..\packages\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\StyleCop.Analyzers.dll
1>CSC : error CS7027: Error signing output with public key from file '..\YYY.snk' -- Assembly signing not supported.
This is due to how the Roslyn compiler handles the signing key. I've been able to workaround this issue by hardcoding the path of my key in the code at https://github.com/StackExchange/StackExchange.Precompilation/blob/master/StackExchange.Precompilation.Build/Compilation.cs#L96
by adding the following code:
var compilation = CSharpCompilation.Create(
options: CscArgs.CompilationOptions.WithAssemblyIdentityComparer(GetAssemblyIdentityComparer())
.WithStrongNameProvider(new DesktopStrongNameProvider(System.Collections.Immutable.ImmutableArray.Create<string>(@"D:\TFSONLINE\XXX\Dev\Source\YYY.snk"))),
references: references,
syntaxTrees: sources,
assemblyName: CscArgs.CompilationName);
This is an ugly workaround but it works for me for now. If I have the time this week, I'll try to work on a pull request. Otherwise, the real path of the key is already passed as /keyfile to StackExchange.Precompiler.exe. It would be nice if StackExchange.Precompiler.exe could support a signing key in a more generic way.
I'm trying to compile a web project that is strongly-typed. The assembly is signed with a .snk file. Here's the log of the build:
This is due to how the Roslyn compiler handles the signing key. I've been able to workaround this issue by hardcoding the path of my key in the code at https://github.com/StackExchange/StackExchange.Precompilation/blob/master/StackExchange.Precompilation.Build/Compilation.cs#L96
by adding the following code:
This is an ugly workaround but it works for me for now. If I have the time this week, I'll try to work on a pull request. Otherwise, the real path of the key is already passed as /keyfile to StackExchange.Precompiler.exe. It would be nice if StackExchange.Precompiler.exe could support a signing key in a more generic way.