Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build error when signing with snk key

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

like image 426
Bart VdA Avatar asked Oct 06 '15 13:10

Bart VdA


1 Answers

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 the error.

Hope this helps.

like image 197
Francis Rodgers Avatar answered Oct 15 '22 09:10

Francis Rodgers