diff --git a/src/BaGet.Core/Configuration/BaGetOptions.cs b/src/BaGet.Core/Configuration/BaGetOptions.cs
index efd19ee8d..db8b81473 100644
--- a/src/BaGet.Core/Configuration/BaGetOptions.cs
+++ b/src/BaGet.Core/Configuration/BaGetOptions.cs
@@ -32,6 +32,12 @@ public class BaGetOptions
///
public bool AllowPackageOverwrites { get; set; } = false;
+ ///
+ /// If enabled, pushing a pre released package that already exists will replace the
+ /// existing package.
+ ///
+ public bool AllowPreReleasePackageOverwrites { get; set; } = false;
+
///
/// If true, disables package pushing, deleting, and re-listing.
///
diff --git a/src/BaGet.Core/Indexing/PackageIndexingService.cs b/src/BaGet.Core/Indexing/PackageIndexingService.cs
index 8a3006fac..20638af07 100644
--- a/src/BaGet.Core/Indexing/PackageIndexingService.cs
+++ b/src/BaGet.Core/Indexing/PackageIndexingService.cs
@@ -82,7 +82,14 @@ public async Task IndexAsync(Stream packageStream, Cancel
// The package is well-formed. Ensure this is a new package.
if (await _packages.ExistsAsync(package.Id, package.Version, cancellationToken))
{
- if (!_options.Value.AllowPackageOverwrites)
+ if (package.IsPrerelease)
+ {
+ if (!_options.Value.AllowPreReleasePackageOverwrites)
+ {
+ return PackageIndexingResult.PackageAlreadyExists;
+ }
+ }
+ else if (!_options.Value.AllowPackageOverwrites)
{
return PackageIndexingResult.PackageAlreadyExists;
}
diff --git a/src/BaGet/appsettings.json b/src/BaGet/appsettings.json
index f431f367a..a7f0aab33 100644
--- a/src/BaGet/appsettings.json
+++ b/src/BaGet/appsettings.json
@@ -2,6 +2,7 @@
"ApiKey": "",
"PackageDeletionBehavior": "Unlist",
"AllowPackageOverwrites": false,
+ "AllowPreReleasePackageOverwrites": false,
"Database": {
"Type": "Sqlite",