Strong Naming BlogEngine.Core's Referenced Assembly

Topics: Business Logic Layer
Jul 10, 2011 at 2:38 PM

Hey all.

I've downloaded the source code of Blog Engine.NET 2.5 (The ASP.NET 4.0 version) and I've opened it in VS 2010 Professional.  When I tried to deploy the website to my FTP server, I got an error in my error list which says, "Assembly generation failed -- Referenced assembly 'BlogEngine.Core' does not have a strong name."  I've never fooled around with strong naming so I started to google a bit to see if I could get some pro-tips.  Here are the things I've tried...

1) I tried finding the Visual Studio Command Prompt based on this article, but my version of Professional doesn't have it under Tools... so I tried putting this line (al /out:BlogEngine.Core.dll BlogEngine.Core /keyFile:key.snk) in my normal windows command window, but that just came back with 'al isn't recognized as a blah blah blah'...

2) I went into Visual Studio and selected the properties of BlogEngine.Core - From there, I selected the 'Signing' tab at the bottom.  While looking at that tab, I noticed the 'Sign Assembly' checkbox was unchecked, so I checked it and picked key.snk as my strong name keyfile.  I didn't delay sign because... well, I didn't.  When I tried to rebuild the project Visual Studio threw another error about NuGet.Core not being strongly named.  From what I read here, "...all assemblies referenced by a strong-named assembly must also be strong-named. If you reference an assembly written by a third party that is not strong-name signed, you cannot strong-name sign your assembly." After all that reading it turns out I can't strongly name BlogEngine.Core because its referenced assemblies aren't strongly named, either.

Does anyone have a suggestion as to what I should try next?  I'd like to compile and publish the application on my own (rather than using the web-ready files) because I intend to change some things (as an exercise in learning more about C#).

Shifty

Jul 12, 2011 at 4:01 AM
Edited Jul 12, 2011 at 4:05 AM

Hello,

I just want to make you aware of a few things before we go forward with the publish.

The reason why blogEngine.Net is built to function as web-ready files (not compiled) is for extensions, widgets, and themes to be added via the gallery or by your own drag and drop facilities. If the website is compiled you no longer have access to add files to the App_Code or able to drop in new uncompiled code.

This will bring you at a severe disadvantage everytime you wish to test out a theme, extension or widget as you will have to completley recompile your site and publish it back to your application. Now that being said here is the process if you still wish to recompile the site on your own.

The site **doesnt have** to have strongly named assemblies, and by disabling this you can get past the strongly named assemblies issue. Additionally you probably dont want to recompile NuGet with your own strongly named key, this will really hurt your upgrade path. I have tested the process .

  1. Right click the website in visual studio and select publish
  2. Deselect
    1. Allow this pre-compiled site to be updated
    2. Enable strong naming on pre-compiled assemblies
  3. Select
    1. Use fixed naming and single page assemblies (this is required as all pages are in fact their own assemblies)
  4. Publish to a local drive first outside the regular drive ie. D:\BlogEnginePublish

To test your publish you can open another copy of visual studio (if you dont have IIS installed) and just go File -> Open Website -> Select your new compiled site and hit run (ignoring the warning about modifying the website). It should run as normal here, that lets you at least locally test the site before commiting it to your FTP. Next either re-publish via ftp, or manually push the contents over to your FTP server.

I don't really recommend this as features such as the Widget & Theme gallery will throw your Blog into complete disarray as these are all non-compiled source.

Some of the errors you can get very easily by using a compiled site.

The file '/themes/<theme>/site.master' has not been pre-compiled, and cannot be requested.

The directory '/App_Code/' is not allowed because the application is precompiled.

 

Good luck.

Jul 14, 2011 at 6:09 PM

Is there a way i compile my code and still have access to gallery from the admin panel?

Jul 16, 2011 at 11:12 AM
Edited Jul 17, 2011 at 4:28 PM

Hi nvanhaaster,

nvanhaaster wrote:

The site **doesnt have** to have strongly named assemblies, and by disabling this you can get past the strongly named assemblies issue. Additionally you probably dont want to recompile NuGet with your own strongly named key, this will really hurt your upgrade path. I have tested the process .

why should i disable the strong named feature at compile time? Only coz some poeple are thinking the signing of assemblies is waste?

There is no need to recompile any assembliy with my own key, if the assemblies are strong named and signed. For the future it would be nice, if you're using only strong named and signed assemlies.
Where is the problem to sign an assembly? It's not realy a big act.

Regards,
Klaus