Tips on compiling NuGetGallery source code and hosting it on IIS

Last week, I tried compiling the source code of NuGetGallery and hosting it on IIS but found some issues. Here is the list of issues/solutions that I found. I am sharing it here. Hope it will save some of your times if you are facing the same issues.

Note that I was using the master branch and the date that I downloaded the source from that branch was 22/09/2015.

Azure SDK

The first error that I got was the compile error. It was because I don’t have an Azure SDK on my VM. Well, I know installing the Azure SDK is one of the prerequisites but I am not going to host it on Azure so I decided to change the path of two assemblies below in NuGetGallery.csproj.

  • Microsoft.WindowsAzure.Diagnostics.dll
  • Microsoft.WindowsAzure.ServiceRuntime.dll

NuGet Gallery team shipped those assemblies under lib/AzureSDK so it’s quite easy to change it.

Wrong Path of Azure DLL

Entity Framework 5 + VS2013 Update 5 issue

I got this error when I tried to update the database.

22-09-2015 1-02-14 PM

It looks like a known issue with EF5+VS2013Update but I found the workaround Update-Database throwing “Could not load file or assembly EntityFramework .. or one of its dependencies” error.

The steps below is the workaround to fix this issue.

  • Start VS Command Prompt as Administrator
  • Go to your packages directory and find the EntityFramework package directory.
  • Go to lib\net45
  • Type: gacutil /i EntityFramework.dll
  • Restart Visual Studio

I managed to update the database after I did those steps but I got the runtime error below when I launch the NuGetGallery project.

Failed to set Database.DefaultConnectionFactory to an instance of the ‘System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework’ type as specified in the application configuration. See inner exception for details.

{“Could not load file or assembly ‘EntityFramework’ or one of its dependencies. The system cannot find the file specified.”:”EntityFramework”}

so I would suggest that you should uninstall EntityFramework.dll from GAC later.

gacutil /u EntityFramework

RequireSsl

It’s up to you whether you want to have SSL enabled or not. For me, I don’t need it so remove [RequireSsl] attribute from NuGetGallery/Controllers/AuthenticationController.cs.

Remove ReWrite

I don’t want to enable http-rewrite module and when I look at the config, it looks like they are just using it for nuget.org only so I removed the whole re-write session from config.

Remove rewrite

Enable-LocalTestMe

If you are running it from VS, you will have to enable the local test me by running .\Enable-LocalTestMe.ps1 script unless you want to change the configuration manually. but your goal is just to host it on IIS then you don’t have to do it.

Enable_localTestMeinIISExpress

NuGet Push “Method Not Allowed” error

After I manage to run NuGetGallery project, I got another small issue with nuget push.

[16:35:45][push] Failed to process request. ‘Method Not Allowed’.
[16:35:45][push] The remote server returned an error: (405) Method Not Allowed..
[16:35:45][push] Process exited with code 1
[16:35:45][Step 6/6] Step Push To NuGet (NuGet Publish) failed

I removed “WebDEV” from http-handler and module. After that, it works.

 

 

WebDev

I will probably upload the publish file and database schedule later this week or next week.

Visual Studio 2013 + SlowCheetah error

I got this error recently when I tried to rebuild the project that I downloaded from github in VS2013.

Error Message:

Error 1 The “SlowCheetah.Xdt.TransformXml” task could not be loaded from the assembly C:\Users\Michael\AppData\Local\Microsoft\MSBuild\SlowCheetah\v2.5.10.2\SlowCheetah.Xdt.dll. Could not load file or assembly ‘file:///C:\Users\Michael\AppData\Local\Microsoft\MSBuild\SlowCheetah\v2.5.10.2\SlowCheetah.Xdt.dll’ or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. Project-Name

Error Screenshot

SlowCheatch

Here is the solution that works for me. Of course, feel free to share if you have alternative solution or better one.

Solution

  • Close Visual Studio 2013 (if it’s opened)
  • Delete SlowCheetah package in %userprofile%\AppData\Local\NuGet\Cache

Cache

  • Delete all folders under this path %userprofile%\AppData\Local\Microsoft\MSBuild\SlowCheetach

 

MSBuild

 

That’s all. It works for me. If it’s not working for you or you have other solution, please drop a comment. Thanks!