NuGetGallery
NuGet Gallery is a package repository that powers https://www.nuget.org. Use this repo for reporting NuGet.org issues.
Top Related Projects
Quick Overview
The NuGetGallery repository is the source code for the NuGet Gallery, which is the central package repository for the .NET ecosystem. The NuGet Gallery is a web application that allows developers to publish, discover, and consume NuGet packages, which are reusable .NET components that can be easily integrated into .NET projects.
Pros
- Centralized Package Repository: The NuGet Gallery provides a centralized location for .NET developers to find and consume packages, making it easier to manage dependencies and share code across projects.
- Extensive Package Ecosystem: The NuGet Gallery hosts a vast collection of packages, covering a wide range of functionality and use cases, allowing developers to leverage existing solutions and focus on building their applications.
- Robust Package Management: The NuGet Gallery supports features like package versioning, dependency management, and package search, making it easier for developers to manage their project dependencies.
- Community-Driven Development: The NuGet Gallery is an open-source project, allowing the .NET community to contribute, report issues, and collaborate on the development of the platform.
Cons
- Complexity of Codebase: The NuGet Gallery codebase is large and complex, as it needs to handle a wide range of functionality and edge cases, which can make it challenging for new contributors to get started.
- Dependency on External Services: The NuGet Gallery relies on several external services, such as Azure Blob Storage and Azure SQL Database, which can introduce potential points of failure and add complexity to the deployment and maintenance of the application.
- Performance Challenges: The NuGet Gallery needs to handle a large volume of traffic and package downloads, which can sometimes lead to performance issues and slow response times.
- Limited Customization Options: The NuGet Gallery is designed as a centralized package repository, which means that the options for customizing or extending the platform may be limited for individual organizations or use cases.
Code Examples
N/A (This is not a code library)
Getting Started
N/A (This is not a code library)
Competitor Comparisons
Repo for NuGet Client issues
Pros of Home
- Serves as the central hub for NuGet project management and issue tracking
- Provides comprehensive documentation and guidelines for contributors
- Offers a broader overview of the NuGet ecosystem and roadmap
Cons of Home
- Less focused on specific code implementation details
- May not provide as much hands-on development experience for contributors
- Updates and changes might be less frequent compared to NuGetGallery
Code Comparison
NuGetGallery (Package display):
public ActionResult DisplayPackage(string id, string version)
{
var package = _packageService.FindPackageByIdAndVersion(id, version);
return View(package);
}
Home (Issue template):
## Description
[Provide a clear and concise description of the issue]
## Steps to Reproduce
1. [First Step]
2. [Second Step]
3. [and so on...]
While NuGetGallery focuses on the implementation of the NuGet package repository and website, Home serves as a central location for project management, documentation, and community interaction. NuGetGallery is more code-centric, whereas Home provides a broader perspective on the NuGet ecosystem and its development process.
Chocolatey - the package manager for Windows
Pros of choco
- Broader scope: Manages system-wide software packages, not just .NET libraries
- Command-line focused: Easier for automation and scripting
- Supports multiple package types: Can handle MSI, EXE, ZIP, and more
Cons of choco
- Less integrated with Visual Studio and .NET ecosystem
- Smaller repository of packages compared to NuGet
- Requires elevated privileges for most operations
Code Comparison
NuGetGallery (C#):
public async Task<ActionResult> ConfirmOwner(string id, string username, string token)
{
var package = PackageService.FindPackageByIdAndVersion(id, version: null);
if (package == null)
{
return HttpNotFound();
}
}
choco (PowerShell):
function Install-ChocolateyPackage {
param(
[string] $packageName,
[string] $fileType = 'exe',
[string] $url,
[string] $url64bit = $url,
[string] $silentArgs = ''
)
Write-Debug "Running 'Install-ChocolateyPackage' for $packageName with url:`'$url`', args: `'$silentArgs`'"
}
The code snippets highlight the different focus areas: NuGetGallery deals with package ownership and .NET-specific concepts, while choco emphasizes system-wide package installation with support for various file types and silent installation arguments.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
NuGet Gallery â Where packages are found
This project powers nuget.org, the home for .NET's open-source ecosystem. For information about NuGet, visit the Home repository.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Getting started
First install prerequisites:
- Visual Studio 2022 - Install the following
Workloads
and individual components:- ASP.NET and web development
- Azure development
- Just web UI functional tests: "Web performance and load testing tools" individual component
Visual Studio 2019 may work but Visual Studio 2022 is recommended.
The "Azure development" workload installs SQL Server Express LocalDB which is the database configured for local development.
Run the gallery website locally
This repository contains both the gallery web app (what runs www.nuget.org) as well as background jobs and shared libraries.
Let's focus on running the gallery web app locally, first.
- Clone the repository with
git clone https://github.com/NuGet/NuGetGallery.git
- Navigate to
.\NuGetGallery
- Build with
.\build.ps1
- Create the database and enable HTTPS with
.\tools\Setup-DevEnvironment.ps1
- Open
.\NuGetGallery.sln
using Visual Studio - Ensure the
NuGetGallery
project is the StartUp Project and pressF5
to run the site
Refer to our documentation for information on how to develop the frontend, use AAD, and more.
Shared libraries
There are a set of shared libraries used across the NuGet server repositories, including:
- NuGet.Services.Configuration
- NuGet.Services.KeyVault
- NuGet.Services.Logging
- NuGet.Services.Owin
- NuGet.Services.Cursor
- NuGet.Services.Storage
To edit them, follow these steps:
- Build with
.\build.ps1
- Open
.\NuGet.Server.Common.sln
using Visual Studio - Create the validation database:
- Open Package Manager Console, set
NuGet.Services.Validation
as default project, then runUpdate-Database
.
- Open Package Manager Console, set
Note that many of these shared projects are also referenced by the other solution (e.g. in NuGetGallery.sln
) files in the root of the repository, to simplify modification.
Background jobs
This repository also contains nuget.org's implementation of the NuGet V3 API as well as many other back-end jobs for the operation of nuget.org.
-
Open
.\NuGet.Jobs.sln
using Visual Studio -
Each job would be an exe with 2 main classes
Program
andJob
-
Program.Main
should simply do the following and nothing morevar job = new Job(); JobRunner.Run(job, args).Wait();
-
Job class must inherit
JsonConfigurationJob
. This job based provides some dependency injection setup and has you set configuration in a JSON file.
Most jobs can be run locally with a -Configuration {path_to_json}
command line argument. Not all follow this pattern.
Check the implementation in Program.cs
or the README.md
next to the .csproj
project file for job-specific information.
Deploy
Deploy to Azure
You will find instructions on how to deploy the Gallery to Azure here.
Deploy locally
After you succeed in running the NuGet Gallery, you can create a publish profile to deploy locally (such as your local Windows computer).
The steps are:
- Select the
NuGetGallery
project in Solution Explore of Visual Studio. - Right click the project, and then click
Publish
in the pop-up menu. Create a publish profile and make sure the Target is set toFolder
. - Copy the contents of the
Target Location
to any folder you want. For the following example, assume the folder isC:\ContosoSoftware\NuGetGallery
. - Execute the command below to start the web app (note that the parameter
/path
of iisexpress.exe only supports absolute paths on Windows)."C:\Program Files\IIS Express\iisexpress.exe" /path:C:\ContosoSoftware\NuGetGallery
Now you can access the local website with a web browser. The URL is https://localhost
.
After you deploy it, you don't need using Visual Studio to run it anymore.
Contribute
If you find a bug with the gallery, please visit the Issue tracker and create an issue. If you're feeling generous, please search to see if the issue is already logged before creating a new one.
When creating an issue, clearly explain
- What you were trying to do.
- What you expected to happen.
- What actually happened.
- Steps to reproduce the problem.
Also include any information you think is relevant to reproducing the problem such as the browser version you used. Does it happen when you switch browsers. And so on.
Submit a patch
Before starting work on an issue, either create an issue or comment on an existing issue to ensure that we're all communicating. We have a list of items that are up for grabs and you can start working on (but always ping us beforehand).
To contribute to the gallery, make sure to create a fork first. Make your changes in the fork following the Git Workflow. When you are done with your changes, send us a pull request.
Copyright and License
Copyright .NET Foundation
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoftâs Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-partyâs policies.
The Git Workflow
This is the Git workflow we're currently using:
Setting up
Clone and checkout the dev
branch.
Visual Studio may modify the applicationhost.config
file. You can force git to ignore changes to this file
with:
git update-index --assume-unchanged .vs/config/applicationhost.config
You can undo this with this command:
git update-index --no-assume-unchanged .vs/config/applicationhost.config
This should help prevent unwanted file commits.
When starting a new feature/unit of work.
-
Pull the latest. Begin by pulling to make sure you are up-to-date before creating a branch to do your work This assumes you have no local commits that haven't yet been pushed (i.e., that you were previously up-to-date with origin).
git checkout dev git pull dev
-
Create a topic branch to do your work. You must work in topic branches to help us keep our features isolated and easily moved between branches. Our policy is to start all topic branches off of the 'dev' branch. Branch names should use the following format '[user]-[bugnumber]'. If there is no bug yet, create one and assign it to yourself!
git checkout dev git checkout -b billg-123
-
Do your work. Now, do your work using the following highly accurate and efficient algorithm :)
-
Make changes.
-
Test your changes (you're practicing TDD, right?)
-
Add your changes to git's index.
git add -A
-
Commit your changes.
git commit -m "<description of work>"
-
if (moreWorkToDo) go to #3.1 else go to #4.
-
-
Start a code review. Start a code review by pushing your branch up to GitHub (
git push origin billg-123
) and creating a Pull Request from your branch to dev. Wait for at least someone on the team to approve the PR. -
Merge your changes in to dev. Click the bright green "Merge" button on your pull request! Don't forget to delete the branch afterwards to keep our repo clean.
If there isn't a bright green button... well, you'll have to do some more complicated merging:
git checkout dev git pull origin dev git merge billg-123 ... resolve conflicts ... git push origin dev
-
Be ready to guide your change through our deployed environments. Your change will make its way through the DEV (dev.nugettest.org), INT (int.nugettest.org) and finally PROD (www.nuget.org). Be prepared to fix additional bugs!
Top Related Projects
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot