Is there an easy way to sign a C++ CLI assembly in VS 2010?

前端 未结 6 1712
囚心锁ツ
囚心锁ツ 2020-12-30 00:18

Right now I am setting the Linker/Advanced/KeyFile option.

I am getting the \"mt.exe : general warning 810100b3: is a strong-name signed assembly and embedding

6条回答
  •  孤独总比滥情好
    2020-12-30 00:43

    There's a fair amount of lameness here, this just never worked before. It got "fixed" in VS2010, mt.exe now generates a warning instead of letting this silently go wrong. Not a real fix, and there's not an obvious one, the linker can't just embed the signature and still allow mt.exe to run afterwards.

    The solution is to re-sign the assembly with a post-build event. Make it look like this:

    Command = sn -Ra "$(TargetPath)" $(ProjectName).snk

    If you don't already have the key file, you'll need to create the .snk file yourself, run sn.exe from the Visual Studio Command prompt. for example:

    cd \whereTheProjectIsLocated
    sn.exe -k MyProject.snk
    

    Or extract it from a container or use your designated key file. Delay signing is just a matter of running sn.exe with the proper command line options.

提交回复
热议问题