- Before starting, you will need:
- Node.js and npm installed globally
choco install nodejs-lts -y
refreshenv
- if it says refreshing for cmd.exe, you have to close and restart PowerShell and navigate back to the folder (you need to install the PowerShell profile - reference the troubleshooting page at https://chocolatey.org/docs/troubleshooting)npm install gulp -g
- A local running instance of SQL Server and Visual Studio 2013 or above
choco install sql-server-management-studio mssqlserver2014express -y
(you may find a newer version of SQL Server Express)
- Node.js and npm installed globally
- In Visual Studio, open ChocolateyGallery.sln.
- Note if you already had this open, close it and reopen it so that it can know where npm and gulp are located - that is necessary for the build to succeed.
- In the Website project, open web.config
- Locate the connectionStrings section, and modify the NuGetGallery connection string to point to your local instance of SQL Server. It's not a bad idea to change the database name (initial catalog) just to avoid confusion. For example if your SQL Server instance is named SQL2016, you could use:
<add name="NuGetGallery" connectionString="Data Source=.\SQL2016;Initial Catalog=Chocolatey;Integrated Security=SSPI;MultipleActiveResultSets=False;" providerName="System.Data.SqlClient" />
Note: the database does not need to exist - Open the Package Manager Console (Tools > NuGet Package Manager > Package Manager Console)
- If prompted, restore any missing NuGet packages (Don't use
nuget restore
from the command-line as this will pull in extra packages that cause the build to break) - Run the Update-Database command in Package Manager Console (if the command is not found, try reloading the solution in Visual Studio)
- The database named in the connection string should now exist in your SQL Server.
- Press F5 to start the web application
- You may experience an error of
The CodeDom provider type Microsoft.VisualC.CppCodeProvider could not be located
. This is due to what Visual Studio thinks are header files in thechocolatey\Website\node_modules
folder. Make that hidden (just the top levelnode_modules
folder). - Press F5 to start the web application
- Your web browser should launch, showing the Chocolatey home page
- Head to Find Packages and then sign up, entering details to create a new account
- To make this account an administrator, run the following SQL against your new database eg. Use SQL Server Management Studio or sqlcmd from the command line. Note: Replace 'username' with the name of the user account you just created
DECLARE @adminId int
SELECT @adminId = [Key] FROM Roles WHERE Name = 'Admins'
DECLARE @userId int
SELECT @userId = [Key] FROM Users where Username = 'username'
INSERT INTO UserRoles(UserKey, RoleKey) VALUES(@userId, @adminId)
- You should now be up and running!
When debugging, you might see this exception: SimpleInjector.ActivationException: 'The given type IControllerActivator is not a concrete type. Please use one of the other overloads to register this type.'
.
Just ignore this and keep running.
- Please don't fix anything in the
nugetgallery
folder or subfolder. Instead you should copy the unchanged item over tochocolatey/Website
. - Then remove the old item from the Visual Studio project and add the newly copied item to the project.
- Save the project and commit your changes.
- Make your changes as normal now.