Bart VdA
Bart VdA

Reputation: 638

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]

https://i.sstatic.net/hKbbe.png

[Error in TeamCity]

https://i.sstatic.net/rbgHx.png

Upvotes: 12

Views: 26670

Answers (9)

user3469905
user3469905

Reputation: 1

I am building an open source project with Visual Studio 2022. The open source project was throwing this error. I do not need to sign the project to do my testing.

In Visual Studio 2022, right-click on the project. Left-click Properties. Scroll down to Build / Strong Naming. Under Sign the assembly, uncheck Sign the output assembly to give it a strong name.

Build the project and the error no longer displays.

Upvotes: 0

hussein zakizadeh
hussein zakizadeh

Reputation: 173

double click on your project and set to false:

  <SignAssembly>false</SignAssembly> 
 <PublicSign>false</PublicSign>

remove this line :

 <AssemblyOriginatorKeyFile>CompanyName.snkk</AssemblyOriginatorKeyFile>

Upvotes: 1

user19439918
user19439918

Reputation: 21

Just had this issue today in visual Studio 2022- I was messing with the csproj file and ended up having the wrong filepath to the snk file. I fixed it by changing the filepath to be correct.

  1. Right-click on the project -> unload (so that you can edit the csproj file)

  2. Under <PropertyGroup> check the <AssemblyOriginatorKeyFile> tag

  3. My code was:<SignAssembly>true</SignAssembly> <AssemblyOriginatorKeyFile>../NAMEHERE.snk</AssemblyOriginatorKeyFile> NAMEHERE was specific to my project, yours will vary. Look at your snk file. The ../ in front will vary, check the filepath of your snk file. If you caused this error by messing with your csproj file, like I did, then the correct answer is what the filepath was before you changed it. :)

  4. Right-click on the project -> reload

Upvotes: 0

Paul Schneider
Paul Schneider

Reputation: 31

I used '/m:1' as an msbuild argument, and 'SignPublic' property to true in the csproj file.

Upvotes: 0

n0rd
n0rd

Reputation: 12630

This is probably an instance of this issue with Roslyn compiler. The workaround would be adding

<UseSharedCompilation>False</UseSharedCompilation>

under any <PropertyGroup> node in .csproj file.

Upvotes: 2

Francis Rodgers
Francis Rodgers

Reputation: 4675

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.

Upvotes: 14

Mark Bell
Mark Bell

Reputation: 384

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

  1. Go to Tools > Options
  2. From the Options dialog, select "Projects and Solutions > Build and Run"
  3. Set the "maximum number of parallel project builds" to 1

+1 to @stukselbax for getting me on the right track Also got help from this link

Upvotes: 0

Brian
Brian

Reputation: 1894

It started for me when I moved the Resharper Cache to System Temp. When I moved it back to the Solution folder, the problem went away, and I could build again.

Upvotes: 0

Alexander Bartosh
Alexander Bartosh

Reputation: 8807

Try to clean up the temp folder that is used by the build. I have seen different types of problems when the temp folder has lots of files.

Some of the tools are using GetTempFileName and they will get errors when temp has a lots of files

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

Upvotes: 4

Related Questions