本文介绍了使用snk键签名时生成错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从使用Visual Studio 2015以来,发生构建错误.在Visual Studio 2015中进行构建时,这种情况很少发生.在TeamCity中进行构建时,这种情况经常发生.

[Visual Studio 2015错误]

  • 从文件'CompanyName.snk'中提取公钥时出错:该进程无法访问文件'C:\ Users \ UserName \ AppData \ Local \ Temp \ tmp2FF6.tmp',因为该文件正在被另一个进程使用. CompanyName.Project.DAL D:\ Projecten \ CompanyName \ Repository \ Source \ Components \ CompanyName.Project.DAL \ vbc

http://i.stack.imgur.com/hKbbe.png

[TeamCity中的错误]

  • CSC错误CS7027:使用公钥从文件'CompanyName.snk'对输出进行签名时出错-该进程无法访问文件'C:\ BuildAgents \ Gamma \ temp \ buildTmp \ tmpD91D.tmp'被另一个进程使用.

http://i.stack.imgur.com/rbgHx.png

解决方案

我知道距被问到已经有一段时间了,但是由于我使用SO作为自己的参考,我也遇到了这个问题,所以我想分享我的解决方案. /p>

.snk文件用于签署项目.您可能需要重新制作一个.

  • 右键单击您的项目,选择属性.
  • 单击签名".
  • 单击签署程序集"旁边的复选框.
  • 在标有选择强名称密钥文件"的下拉列表中,单击新建".
  • 根据需要填写对话框,尤其要注意密钥文件名.当您单击确定时,这将生成一个新的.snk文件.
  • 保存项目并重建.
  • 这将在您的项目中使用新的.snk并解决错误.

希望这会有所帮助.

Build error is occurring since using Visual Studio 2015. When building in Visual Studio 2015 this is occurring rarely. When building in TeamCity this occurs very often.

[Error in Visual Studio 2015]

  • Error extracting public key from file 'CompanyName.snk': The process cannot access the file 'C:\Users\UserName\AppData\Local\Temp\tmp2FF6.tmp' because it is being used by another process. CompanyName.Project.DAL D:\Projecten\CompanyName\Repository\Source\Components\CompanyName.Project.DAL\vbc

http://i.stack.imgur.com/hKbbe.png

[Error in TeamCity]

  • CSC error CS7027: Error signing output with public key from file 'CompanyName.snk' -- The process cannot access the file 'C:\BuildAgents\Gamma\temp\buildTmp\tmpD91D.tmp' because it is being used by another process.

http://i.stack.imgur.com/rbgHx.png

解决方案

I know it's been a while since this was asked but as I use SO for my own reference and I had this problem too I wanted to share my solution.

.snk files are for signing a project. You might need to make a new one.

  • Right click on your project, select properties.
  • Click on Signing.
  • Click the checkbox beside "Sign the assembly".
  • On the dropdown labelled "Choose a strong name key file" click new.
  • Fill in the dialog box as you wish noting particularly the Key file name. When you press ok, this will generate a new .snk file.
  • Save the project and rebuild.
  • This will use the new .snk in your project and will resolve theerror.

Hope this helps.

这篇关于使用snk键签名时生成错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 06:46