Build error signing with snk

A build error has occurred since Visual Studio 2015 is used. When created in Visual Studio 2015, this rarely happens. When creating in TeamCity this happens very often.

[Error in Visual Studio 2015]

  • Error retrieving the public key from the 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]

  • Error CSC CS7027: output of a public key error from the file 'CompanyName.snk' - the process cannot access the file 'C: \ BuildAgents \ Gamma \ temp \ buildTmp \ tmpD91D.tmp' because it is using a different process.

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

+7
source share
6 answers

I know that some time has passed since this was set, but since I use SO for my own link and I had this problem, I also wanted to share my solution.

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

  • Right click on your project and select properties.
  • Click Sign.
  • Check the box next to "Sign assembly."
  • In the drop-down list that says "Choose a strong name key file," click "New."
  • Fill out the dialog box if you want to highlight the key file name. When you click ok, this will create a new .snk file.
  • Save the project and rebuild.
  • This will use the new .snk in your project and resolve the error.

Hope this helps.

+6
source

Try to clear the temporary folder used by the assembly. I saw various types of problems when there are many files in the temp folder.

Some of the tools use GetTempFileName and they will get errors when temp has many files.

The GetTempFileName method will throw an IOException if it is used to create more than 65535 files without deleting previous temporary files.

+4
source

This is probably an instance of this problem with the Roslyn compiler. The workaround is to add

<UseSharedCompilation>False</UseSharedCompilation> 

under any <PropertyGroup> node in the .csproj file.

+1
source

It started for me when I moved Resharper Cache to System Temp. When I moved it back to the Solution folder, the problem disappeared and I was able to create again.

0
source

I had the same problem. In Visual Studio 2015, I fixed it by following these steps:

  • Go to Tools> Options
  • In the Options dialog box, select Projects and Solutions> Build and Run
  • Set the "maximum number of concurrent projects" to 1

+1 to @stukselbax for taking me on the right track Also received help at this link

0
source

I used "/ m: 1" as the msbuild argument and the "SignPublic" property for true in the csproj file.

0
source

Source: https://habr.com/ru/post/1233054/


All Articles