Create common manifest file
This will trim additional packages such as runtime.win-arm64.runtime.native.system.data.sqlclient.sni
This commit is contained in:
parent
368883b39b
commit
bb1d80be2a
|
|
@ -175,8 +175,24 @@
|
|||
<Copy SourceFiles="$(RepositoryRoot)build\Build.RS.nuspec" DestinationFolder="$(ArtifactsDir)" Condition="'$(OSPlatform)'=='Linux'" />
|
||||
<WriteLinesToFile File="$(ArtifactsDir)version.txt" Lines="$(VersionPrefix)-$(VersionSuffix)" Overwrite="true" Condition="'$(OSPlatform)'=='Linux'" />
|
||||
|
||||
<!-- Preview 2 Workaround: remove Microsoft.AspNetCore.Mvc.Razor.ViewCompilation from publish manifest -->
|
||||
<Exec Command="sed -i -e '/microsoft.aspnetcore.mvc.razor.viewcompilation/d' $(ArtifactsDir)%(PackageStoreManifestFiles.TimestampDestinationFile)" Condition="'$(OS)' != 'Windows_NT'" />
|
||||
<!-- Add a common manifest for package trimming -->
|
||||
<MSBuild Projects="$(ProjectPath)" Targets="CreateCommonManifest" Condition="'$(OSPlatform)' == 'Windows' AND '$(PACKAGE_CACHE_PLATFORM)' == 'x64'"/>
|
||||
</Target>
|
||||
|
||||
<Target Name="CreateCommonManifest">
|
||||
<PropertyGroup>
|
||||
<CommonManifestFileName>aspnetcore-store-$(TimestampVersion)-common.xml</CommonManifestFileName>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageToTrim Include="runtime.win-arm64.runtime.native.system.data.sqlclient.sni" />
|
||||
</ItemGroup>
|
||||
|
||||
<MSBuild Projects="$(RuntimeStoreReferenceDirectory)\Build.RuntimeStore.References.csproj" Targets="GetPackageDefinitions" >
|
||||
<Output TaskParameter="TargetOutputs" ItemName="_PackageDefinitions" />
|
||||
</MSBuild>
|
||||
|
||||
<RepoTasks.CreateCommonManifest DestinationFilePath="$(ArtifactsDir)$(CommonManifestFileName)" PackageDefinitions="@(_PackageDefinitions)" Packages="@(PackageToTrim)"/>
|
||||
</Target>
|
||||
|
||||
<Target Name="ConvertZipToTGZ">
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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>
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
<Project>
|
||||
<UsingTask TaskName="RepoTasks.CreateCommonManifest" AssemblyFile="$(MSBuildThisFileDirectory)bin\publish\RepoTasks.dll" />
|
||||
</Project>
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<UsingTask TaskName="Microsoft.NET.Build.Tasks.ResolvePackageDependencies" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />
|
||||
|
||||
<Import Project="..\..\build\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
|
|
@ -8,6 +10,13 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="@(RuntimeStorePackageReference)" />
|
||||
<PackageReference Include="@(RuntimeStorePackageReference)" />
|
||||
<ProjectAssetsJson Include="$(MSBuildThisFileDirectory)**\project.assets.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="GetPackageDefinitions" Returns="@(_PackageDefinitions)" >
|
||||
<ResolvePackageDependencies ProjectPath="$(MSBuildThisFileFullPath)" ProjectAssetsFile="@(ProjectAssetsJson)">
|
||||
<Output TaskParameter="PackageDefinitions" ItemName="_PackageDefinitions" />
|
||||
</ResolvePackageDependencies>
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
|
|||
Loading…
Reference in New Issue