This repository was archived by the owner on Nov 21, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This will trim additional packages such as runtime.win-arm64.runtime.native.system.data.sqlclient.sni
- Loading branch information
Showing
5 changed files
with
107 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Linq; | ||
using System.Xml; | ||
using Microsoft.Build.Framework; | ||
using Microsoft.Build.Utilities; | ||
|
||
namespace RepoTasks | ||
{ | ||
/// <summary> | ||
/// Creates a common manifest file used for trimming publish output given a list of packages and package definitions containing their versions. | ||
/// </summary> | ||
public class CreateCommonManifest : Task | ||
{ | ||
/// <summary> | ||
/// The path for the common manifest file to be created. | ||
/// </summary> | ||
/// <returns></returns> | ||
[Required] | ||
public string DestinationFilePath { get; set; } | ||
|
||
/// <summary> | ||
/// The packages to include in the common manifest file. | ||
/// </summary> | ||
/// <returns></returns> | ||
[Required] | ||
public ITaskItem[] Packages { get; set; } | ||
|
||
/// <summary> | ||
/// The package definitions used for resolving package versions. | ||
/// </summary> | ||
/// <returns></returns> | ||
[Required] | ||
public ITaskItem[] PackageDefinitions { get; set; } | ||
|
||
public override bool Execute() | ||
{ | ||
var xmlDoc = new XmlDocument(); | ||
var packagesElement = xmlDoc.CreateElement("StoreArtifacts"); | ||
|
||
foreach (var package in Packages) | ||
{ | ||
var packageName = package.ItemSpec; | ||
var packageElement = xmlDoc.CreateElement("Package"); | ||
|
||
var idAttribute = xmlDoc.CreateAttribute("Id"); | ||
idAttribute.Value = packageName; | ||
packageElement.Attributes.Append(idAttribute); | ||
|
||
var versionAttribute = xmlDoc.CreateAttribute("Version"); | ||
versionAttribute.Value = PackageDefinitions | ||
.Where(p => string.Equals(p.GetMetadata("Name"), packageName, StringComparison.OrdinalIgnoreCase)) | ||
.Select(p => p.GetMetadata("Version")).Single(); | ||
packageElement.Attributes.Append(versionAttribute); | ||
|
||
packagesElement.AppendChild(packageElement); | ||
} | ||
|
||
xmlDoc.AppendChild(packagesElement); | ||
xmlDoc.Save(DestinationFilePath); | ||
|
||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Import Project="$(RepoTasksSdkPath)\Sdk.props" Condition="'$(RepoTasksSdkPath)' != '' "/> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<Import Project="$(RepoTasksSdkPath)\Sdk.targets" Condition="'$(RepoTasksSdkPath)' != '' "/> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<Project> | ||
<UsingTask TaskName="RepoTasks.CreateCommonManifest" AssemblyFile="$(MSBuildThisFileDirectory)bin\publish\RepoTasks.dll" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters