Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/NuGet.Core/NuGet.Build.Tasks.Pack/IPackTaskRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,7 @@ public interface IPackTaskRequest<TItem>
bool Deterministic { get; }
string DeterministicTimestamp { get; }
string PackageIcon { get; }
string SdkAnalysisLevel { get; }
string UsingMicrosoftNETSdk { get; }
}
}
4 changes: 4 additions & 0 deletions src/NuGet.Core/NuGet.Build.Tasks.Pack/PackTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ internal PackTask(IEnvironmentVariableReader environmentVariableReader)
public bool Deterministic { get; set; }
public string DeterministicTimestamp { get; set; }
public string PackageIcon { get; set; }
public string SdkAnalysisLevel { get; set; }
public string UsingMicrosoftNETSdk { get; set; }
public ILogger Logger => new MSBuildLogger(Log);

private IPackTaskLogic _packTaskLogic;
Expand Down Expand Up @@ -228,6 +230,8 @@ private IPackTaskRequest<IMSBuildItem> GetRequest()
Deterministic = Deterministic,
DeterministicTimestamp = MSBuildStringUtility.TrimAndGetNullForEmpty(DeterministicTimestamp),
PackageIcon = MSBuildStringUtility.TrimAndGetNullForEmpty(PackageIcon),
SdkAnalysisLevel = MSBuildStringUtility.TrimAndGetNullForEmpty(SdkAnalysisLevel),
UsingMicrosoftNETSdk = MSBuildStringUtility.TrimAndGetNullForEmpty(UsingMicrosoftNETSdk),
};
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/NuGet.Core/NuGet.Build.Tasks.Pack/PackTaskLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public PackArgs GetPackArgs(IPackTaskRequest<IMSBuildItem> request)
Deterministic = request.Deterministic,
DeterministicTimestamp = request.DeterministicTimestamp,
WarningProperties = WarningProperties.GetWarningProperties(request.TreatWarningsAsErrors, request.WarningsAsErrors, request.NoWarn, request.WarningsNotAsErrors),
SdkAnalysisLevel = MSBuildRestoreUtility.GetSdkAnalysisLevel(request.SdkAnalysisLevel),
UsingMicrosoftNETSdk = MSBuildRestoreUtility.GetUsingMicrosoftNETSdk(request.UsingMicrosoftNETSdk),
PackTargetArgs = new MSBuildPackTargetArgs()
};

Expand Down
2 changes: 2 additions & 0 deletions src/NuGet.Core/NuGet.Build.Tasks.Pack/PackTaskRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,7 @@ public class PackTaskRequest : IPackTaskRequest<IMSBuildItem>
public bool Deterministic { get; set; }
public string DeterministicTimestamp { get; set; }
public string PackageIcon { get; set; }
public string SdkAnalysisLevel { get; set; }
public string UsingMicrosoftNETSdk { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ Copyright (c) .NET Foundation. All rights reserved.
Deterministic="$(Deterministic)"
DeterministicTimestamp="$(DeterministicTimestamp)"
PackageIcon="$(PackageIcon)"
SdkAnalysisLevel="$(SdkAnalysisLevel)"
UsingMicrosoftNETSdk="$(UsingMicrosoftNETSdk)"
/>
</Target>

Expand Down
3 changes: 3 additions & 0 deletions src/NuGet.Core/NuGet.Commands/CommandArgs/PackArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using NuGet.Configuration;
using NuGet.Packaging;
using NuGet.ProjectModel;
using NuGet.Versioning;

namespace NuGet.Commands
{
Expand Down Expand Up @@ -47,6 +48,8 @@ public class PackArgs
public bool Deterministic { get; set; }
public string DeterministicTimestamp { get; set; }
public WarningProperties WarningProperties { get; set; }
public NuGetVersion SdkAnalysisLevel { get; set; }
public bool UsingMicrosoftNETSdk { get; set; }
public MSBuildPackTargetArgs PackTargetArgs { get; set; }
public Dictionary<string, string> Properties
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ private bool BuildPackage(PackageBuilder builder, string outputPath = null, bool
outputPath = outputPath ?? GetOutputPath(builder, _packArgs, false, builder.Version);
Directory.CreateDirectory(Path.GetDirectoryName(outputPath));

// Warn if the package ID doesn't adhere to the restricted character set (NU5052)
if (!symbolsPackage &&
_packArgs.UsingMicrosoftNETSdk &&
SdkAnalysisLevelMinimums.IsEnabled(_packArgs.SdkAnalysisLevel, _packArgs.UsingMicrosoftNETSdk, SdkAnalysisLevelMinimums.V11_0_100) &&
!PackageIdValidator.IsValidPackageId(builder.Id, useRestrictedCharacterSet: true))
{
_packArgs.Logger.Log(
PackagingLogMessage.CreateWarning(
string.Format(CultureInfo.CurrentCulture, Strings.RestrictedPackageIdWarning, builder.Id),
NuGetLogCode.NU5052));
}

// Track if the package file was already present on disk
bool isExistingPackage = File.Exists(outputPath);
try
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#nullable enable
~NuGet.Commands.PackArgs.DeterministicTimestamp.get -> string
~NuGet.Commands.PackArgs.DeterministicTimestamp.set -> void
~NuGet.Commands.PackArgs.SdkAnalysisLevel.get -> NuGet.Versioning.NuGetVersion
~NuGet.Commands.PackArgs.SdkAnalysisLevel.set -> void
NuGet.Commands.PackArgs.UsingMicrosoftNETSdk.get -> bool
NuGet.Commands.PackArgs.UsingMicrosoftNETSdk.set -> void
const NuGet.Commands.Restore.Utility.PackageSpecFactory.EnvironmentVariableName = "NUGET_USE_NEW_PACKAGESPEC_FACTORY" -> string!
NuGet.Commands.Restore.IProject.GetGlobalProperty(string! propertyName) -> string?
~static NuGet.Commands.MSBuildRestoreUtility.GetDependencySpec(System.Collections.Generic.IEnumerable<NuGet.Commands.IMSBuildItem> items, bool readOnly, bool collectAdditionalMessages) -> (NuGet.ProjectModel.DependencyGraphSpec, System.Collections.Generic.IReadOnlyList<NuGet.ProjectModel.IAssetsLogMessage>)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#nullable enable
~NuGet.Commands.PackArgs.DeterministicTimestamp.get -> string
~NuGet.Commands.PackArgs.DeterministicTimestamp.set -> void
~NuGet.Commands.PackArgs.SdkAnalysisLevel.get -> NuGet.Versioning.NuGetVersion
~NuGet.Commands.PackArgs.SdkAnalysisLevel.set -> void
NuGet.Commands.PackArgs.UsingMicrosoftNETSdk.get -> bool
NuGet.Commands.PackArgs.UsingMicrosoftNETSdk.set -> void
const NuGet.Commands.Restore.Utility.PackageSpecFactory.EnvironmentVariableName = "NUGET_USE_NEW_PACKAGESPEC_FACTORY" -> string!
NuGet.Commands.Restore.IProject.GetGlobalProperty(string! propertyName) -> string?
~static NuGet.Commands.MSBuildRestoreUtility.GetDependencySpec(System.Collections.Generic.IEnumerable<NuGet.Commands.IMSBuildItem> items, bool readOnly, bool collectAdditionalMessages) -> (NuGet.ProjectModel.DependencyGraphSpec, System.Collections.Generic.IReadOnlyList<NuGet.ProjectModel.IAssetsLogMessage>)
Expand Down
11 changes: 10 additions & 1 deletion src/NuGet.Core/NuGet.Commands/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/NuGet.Core/NuGet.Commands/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1190,4 +1190,7 @@ Upgrade your .NET SDK or remove RestoreUseLegacyDependencyResolver to use this f
<data name="Log_AliasContainsDisallowedCharacters" xml:space="preserve">
<value>The project {0} contains a TargetFramework '{1}' with disallowed characters. TargetFramework names must contain only ASCII characters and must not contain path separators.</value>
</data>
<data name="RestrictedPackageIdWarning" xml:space="preserve">
<value>The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ internal static class SdkAnalysisLevelMinimums
/// <list type="bullet">
/// <item>warning when packages use the deprecated MonoAndroid framework</item>
/// <item>error when TargetFramework alias contains non-ASCII characters</item>
/// <item>warning when package ID does not adhere to the restricted character set (NU5052)</item>
/// </list>
/// </summary>
internal static readonly NuGetVersion V11_0_100 = new("11.0.100");
Expand Down
7 changes: 6 additions & 1 deletion src/NuGet.Core/NuGet.Commands/xlf/Strings.cs.xlf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="cs" original="../Strings.resx">
<body>
Expand Down Expand Up @@ -1113,6 +1113,11 @@ Upgradujte svou sadu .NET SDK nebo odeberte RestoreUseLegacyDependencyResolver,
<target state="translated">Vyřazuje se balíček {0} jako závislost {1}. Maximální verze, která se dá vyřadit, je {2}.</target>
<note>0 - package id and version, 1 - version</note>
</trans-unit>
<trans-unit id="RestrictedPackageIdWarning">
<source>The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes.</source>
<target state="new">The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes.</target>
<note />
</trans-unit>
<trans-unit id="SignCommandCertificateFileNotFound">
<source>Certificate file '{0}' not found. For a list of accepted ways to provide a certificate, visit https://docs.nuget.org/docs/reference/command-line-reference</source>
<target state="translated">Soubor certifikátu {0} se nenašel. Seznam přijatelných způsobů, jak poskytnout certifikát, najdete tady: https://docs.nuget.org/docs/reference/command-line-reference</target>
Expand Down
7 changes: 6 additions & 1 deletion src/NuGet.Core/NuGet.Commands/xlf/Strings.de.xlf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="de" original="../Strings.resx">
<body>
Expand Down Expand Up @@ -1113,6 +1113,11 @@ Aktualisieren Sie Ihr .NET SDK oder entfernen Sie RestoreUseLegacyDependencyReso
<target state="translated">Das Paket „{0}“ wird als Abhängigkeit von „{1}“ gekürzt. Die maximal kürzbare Version ist „{2}“.</target>
<note>0 - package id and version, 1 - version</note>
</trans-unit>
<trans-unit id="RestrictedPackageIdWarning">
<source>The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes.</source>
<target state="new">The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes.</target>
<note />
</trans-unit>
<trans-unit id="SignCommandCertificateFileNotFound">
<source>Certificate file '{0}' not found. For a list of accepted ways to provide a certificate, visit https://docs.nuget.org/docs/reference/command-line-reference</source>
<target state="translated">Die Zertifikatdatei "{0}" wurde nicht gefunden. Eine Liste der anerkannten Methoden zur Bereitstellung eines Zertifikats finden Sie unter https://docs.nuget.org/docs/reference/command-line-reference.</target>
Expand Down
7 changes: 6 additions & 1 deletion src/NuGet.Core/NuGet.Commands/xlf/Strings.es.xlf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="es" original="../Strings.resx">
<body>
Expand Down Expand Up @@ -1113,6 +1113,11 @@ Actualice el SDK de .NET o quite RestoreUseLegacyDependencyResolver para usar es
<target state="translated">Eliminando el paquete '{0}' como una dependencia de '{1}'. La versión máxima que se puede eliminar es '{2}'</target>
<note>0 - package id and version, 1 - version</note>
</trans-unit>
<trans-unit id="RestrictedPackageIdWarning">
<source>The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes.</source>
<target state="new">The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes.</target>
<note />
</trans-unit>
<trans-unit id="SignCommandCertificateFileNotFound">
<source>Certificate file '{0}' not found. For a list of accepted ways to provide a certificate, visit https://docs.nuget.org/docs/reference/command-line-reference</source>
<target state="translated">No se encontró el archivo de certificado "{0}". Para obtener una lista de las formas aceptadas de proporcionar un certificado, visite https://docs.nuget.org/docs/reference/command-line-reference</target>
Expand Down
7 changes: 6 additions & 1 deletion src/NuGet.Core/NuGet.Commands/xlf/Strings.fr.xlf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="fr" original="../Strings.resx">
<body>
Expand Down Expand Up @@ -1113,6 +1113,11 @@ Mettez à niveau votre Kit de développement logiciel (SDK) .NET ou supprimez Re
<target state="translated">Nettoyage du package « {0} » en tant que dépendance de « {1} ». La version maximale pouvant être nettoyée est « {2} »</target>
<note>0 - package id and version, 1 - version</note>
</trans-unit>
<trans-unit id="RestrictedPackageIdWarning">
<source>The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes.</source>
<target state="new">The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes.</target>
<note />
</trans-unit>
<trans-unit id="SignCommandCertificateFileNotFound">
<source>Certificate file '{0}' not found. For a list of accepted ways to provide a certificate, visit https://docs.nuget.org/docs/reference/command-line-reference</source>
<target state="translated">Le fichier de certificat '{0}' est introuvable. Pour obtenir la liste des méthodes acceptées d'émission de certificats, accédez à https://docs.nuget.org/docs/reference/command-line-reference</target>
Expand Down
7 changes: 6 additions & 1 deletion src/NuGet.Core/NuGet.Commands/xlf/Strings.it.xlf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="it" original="../Strings.resx">
<body>
Expand Down Expand Up @@ -1113,6 +1113,11 @@ Per usare questa funzionalità, aggiornare .NET SDK o rimuovere RestoreUseLegacy
<target state="translated">Rimozione del pacchetto '{0}' come dipendenza di '{1}'. La versione massima rimovibile è '{2}'</target>
<note>0 - package id and version, 1 - version</note>
</trans-unit>
<trans-unit id="RestrictedPackageIdWarning">
<source>The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes.</source>
<target state="new">The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes.</target>
<note />
</trans-unit>
<trans-unit id="SignCommandCertificateFileNotFound">
<source>Certificate file '{0}' not found. For a list of accepted ways to provide a certificate, visit https://docs.nuget.org/docs/reference/command-line-reference</source>
<target state="translated">Il file di certificato '{0}' non è stato trovato. Per un elenco dei modi accettati per specificare un certificato, vedere https://docs.nuget.org/docs/reference/command-line-reference</target>
Expand Down
7 changes: 6 additions & 1 deletion src/NuGet.Core/NuGet.Commands/xlf/Strings.ja.xlf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="ja" original="../Strings.resx">
<body>
Expand Down Expand Up @@ -1113,6 +1113,11 @@ Upgrade your .NET SDK or remove RestoreUseLegacyDependencyResolver to use this f
<target state="translated">パッケージ '{0}' を '{1}' の依存関係として取り除いています。取り除きが可能な最大バージョンは '{2}' です</target>
<note>0 - package id and version, 1 - version</note>
</trans-unit>
<trans-unit id="RestrictedPackageIdWarning">
<source>The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes.</source>
<target state="new">The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes.</target>
<note />
</trans-unit>
<trans-unit id="SignCommandCertificateFileNotFound">
<source>Certificate file '{0}' not found. For a list of accepted ways to provide a certificate, visit https://docs.nuget.org/docs/reference/command-line-reference</source>
<target state="translated">証明書ファイル '{0}' は見つかりませんでした。証明書を提供する承認済みの方法のリストについて、https://docs.nuget.org/docs/reference/command-line-reference をご覧ください</target>
Expand Down
Loading