Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Add an override so that packages can treat frameworks as out of box. #1657

Merged
merged 1 commit into from
Aug 31, 2017
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
14 changes: 12 additions & 2 deletions src/Microsoft.DotNet.Build.Tasks.Packaging/src/ValidatePackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ private void ValidateSupport()
}
else
{
if (validateFramework.IsInbox)
if (validateFramework.IsInbox && !HasSuppression(Suppression.TreatAsOutOfBox, fx))
{
if (!hasCompileAsset && !hasCompilePlaceHolder)
{
Expand All @@ -251,7 +251,17 @@ private void ValidateSupport()
Version referenceAssemblyVersion = null;
if (!hasCompileAsset)
{
Log.LogError($"{ContractName} should be supported on {target} but has no compile assets.");
if (hasCompilePlaceHolder)
{
Log.LogError($"{ContractName} should be supported on {target} but has a compile placeholder. You may need to remove InboxOnTargetFramework Include=\"{fx.GetShortFolderName()}\" /> from your project.");
}
else
{
Log.LogError($"{ContractName} should be supported on {target} but has no compile assets.");
}

// skip the runtime checks
continue;
}
else
{
Expand Down
17 changes: 16 additions & 1 deletion src/Microsoft.DotNet.Build.Tasks.Packaging/src/ValidationTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ protected bool HasSuppression(Suppression key, string value)
return false;
}

protected bool HasSuppression(Suppression key, NuGetFramework framework)
{
HashSet<string> values;
if (_suppressions.TryGetValue(key, out values) && values != null)
{
var frameworkValues = new[] { framework.DotNetFrameworkName, framework.Framework, framework.GetShortFolderName() };
return frameworkValues.Any(fx => values.Contains(fx));
}
return false;
}

private void LoadSuppressions()
{
_suppressions = new Dictionary<Suppression, HashSet<string>>();
Expand Down Expand Up @@ -174,6 +185,10 @@ public enum Suppression
/// <summary>
/// Permits an inbox assembly to be missing from framework package. This is used for cases where the assembly is part of the framework itself (eg: in desktop).
/// </summary>
PermitMissingInbox
PermitMissingInbox,
/// <summary>
/// Treats an assembly as out of box on the given frameworks, but it must provide an assembly version that is compatible with the inbox version (>=)
/// </summary>
TreatAsOutOfBox
}
}