Skip to content

Commit

Permalink
fixes #76
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwlicious committed Nov 18, 2018
1 parent 2dad1c6 commit 90e1a31
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/Cake.Incubator/XDocumentExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,32 @@ internal static ICollection<PackageReference> GetPackageReferences(this XDocumen
var excludeAssetsXName = ns.GetXNameWithNamespace(ProjectXElement.ExcludeAssets);
var includeXName = ns.GetXNameWithNamespace("Include");
var versionXName = ns.GetXNameWithNamespace("Version");

// get default/empty reference
var global = document
.Descendants(packageReferenceXName)
.LastOrDefault(x => x.Element(includeXName)?.Value == null || x.GetAttributeValue("Include") == null);

string[] globalPrivate = null;
string[] globalInclude = null;
string[] globalExclude = null;

if (global != null)
{
globalPrivate = global.GetAttributeValue(ProjectXElement.PrivateAssets)?.SplitIgnoreEmpty(';') ??
global.Element(privateAssetsXName)?.Value.SplitIgnoreEmpty(';');
globalInclude = global.GetAttributeValue(ProjectXElement.IncludeAssets)?.SplitIgnoreEmpty(';') ??
global.Element(includeAssetsXName)?.Value.SplitIgnoreEmpty(';');
globalExclude = global.GetAttributeValue(ProjectXElement.ExcludeAssets)?.SplitIgnoreEmpty(';') ??
global.Element(excludeAssetsXName)?.Value.SplitIgnoreEmpty(';');
}

return document.Descendants(packageReferenceXName).Select(
x =>
{
var privateAssets = x.Element(privateAssetsXName)?.Value.SplitIgnoreEmpty(';');
var includeAssets = x.Element(includeAssetsXName)?.Value.SplitIgnoreEmpty(';');
var excludeAssets = x.Element(excludeAssetsXName)?.Value.SplitIgnoreEmpty(';');
var privateAssets = x.Element(privateAssetsXName)?.Value.SplitIgnoreEmpty(';') ?? globalPrivate;
var includeAssets = x.Element(includeAssetsXName)?.Value.SplitIgnoreEmpty(';') ?? globalInclude;
var excludeAssets = x.Element(excludeAssetsXName)?.Value.SplitIgnoreEmpty(';') ?? globalExclude;
var condition = x.GetAttributeValue("Condition") ?? x.Parent.GetAttributeValue("Condition");
return new PackageReference
{
Expand Down

0 comments on commit 90e1a31

Please sign in to comment.