Tips on compiling NuGetGallery source code and hosting it on IIS
Last week, I tried compiling the source code of Nuget 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.
Entity Framework 5 + VS2013 Update 5 issue
I got this error when I tried to update the database.
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.
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.
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.
I will probably upload the publish file and database schedule later this week or next week.