From e0daa126e2cbffafd21296cfd4ea1544cce52f44 Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 10 Nov 2017 17:26:40 -0800 Subject: [PATCH] Produce aspnetcore shared framework --- build/PackageArchive.targets | 2 +- build/RuntimeStore.targets | 2 - build/RuntimeStoreInstaller.targets | 468 ------------------ build/SharedFx.props | 44 ++ build/SharedFx.targets | 142 ++++++ build/SharedFxInstaller.targets | 262 ++++++++++ build/repo.targets | 5 +- build/tasks/AddMetapackageReferences.cs | 8 +- build/tasks/ProcessSharedFrameworkDeps.cs | 76 +++ build/tasks/RepoTasks.csproj | 1 + build/tasks/RepoTasks.tasks | 1 + build/tasks/Utilities/RuntimeGraphManager.cs | 66 +++ build/tasks/Utilities/RuntimeReference.cs | 63 +++ build/tools/packaging/changelog | 2 - build/tools/packaging/changelog.in | 2 + ...bian_config.json => debian_config.json.in} | 21 +- build/tools/templates/Archive/Archive.csproj | 4 +- .../tools/templates/SharedFx/SharedFx.csproj | 26 + .../Microsoft.AspNetCore.All.csproj | 6 +- ...ublishWithAspNetCoreTargetManifest.targets | 29 -- .../build/aspnetcore-store-2.0.0-common.xml | 3 - .../aspnetcore-store-2.0.0-linux-x64.xml | 171 ------- .../build/aspnetcore-store-2.0.0-osx-x64.xml | 171 ------- .../build/aspnetcore-store-2.0.0-win7-x64.xml | 172 ------- .../build/aspnetcore-store-2.0.0-win7-x86.xml | 172 ------- .../Microsoft.AspNetCore.All.targets | 3 - .../Microsoft.AspNetCore.All.props | 5 + .../lib/{netcoreapp2.0 => netcoreapp2.1}/_._ | 0 28 files changed, 710 insertions(+), 1217 deletions(-) delete mode 100644 build/RuntimeStoreInstaller.targets create mode 100644 build/SharedFx.props create mode 100644 build/SharedFx.targets create mode 100644 build/SharedFxInstaller.targets create mode 100644 build/tasks/ProcessSharedFrameworkDeps.cs create mode 100644 build/tasks/Utilities/RuntimeGraphManager.cs create mode 100644 build/tasks/Utilities/RuntimeReference.cs delete mode 100644 build/tools/packaging/changelog create mode 100644 build/tools/packaging/changelog.in rename build/tools/packaging/{hosting_debian_config.json => debian_config.json.in} (50%) create mode 100644 build/tools/templates/SharedFx/SharedFx.csproj delete mode 100644 src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets delete mode 100755 src/Microsoft.AspNetCore.All/build/aspnetcore-store-2.0.0-common.xml delete mode 100755 src/Microsoft.AspNetCore.All/build/aspnetcore-store-2.0.0-linux-x64.xml delete mode 100755 src/Microsoft.AspNetCore.All/build/aspnetcore-store-2.0.0-osx-x64.xml delete mode 100755 src/Microsoft.AspNetCore.All/build/aspnetcore-store-2.0.0-win7-x64.xml delete mode 100755 src/Microsoft.AspNetCore.All/build/aspnetcore-store-2.0.0-win7-x86.xml delete mode 100644 src/Microsoft.AspNetCore.All/build/netcoreapp2.0/Microsoft.AspNetCore.All.targets create mode 100644 src/Microsoft.AspNetCore.All/build/netcoreapp2.1/Microsoft.AspNetCore.All.props rename src/Microsoft.AspNetCore.All/lib/{netcoreapp2.0 => netcoreapp2.1}/_._ (100%) diff --git a/build/PackageArchive.targets b/build/PackageArchive.targets index 4475413337..d01ed8cf94 100644 --- a/build/PackageArchive.targets +++ b/build/PackageArchive.targets @@ -47,7 +47,7 @@ + Properties="RestorePackagesPath=$(FallbackStagingDir);RuntimeFrameworkVersion=$(MicrosoftNETCoreApp21PackageVersion);DotNetRestoreSourcePropsPath=$(GeneratedFallbackRestoreSourcesPropsPath);AspNetUniverseBuildOffline=true" /> diff --git a/build/RuntimeStore.targets b/build/RuntimeStore.targets index c0954a7e8b..318a2693e0 100644 --- a/build/RuntimeStore.targets +++ b/build/RuntimeStore.targets @@ -1,6 +1,4 @@ - - <_BuildScriptsDirectory>$(MSBuildThisFileDirectory)tools\scripts\ <_WorkRoot>$(RepositoryRoot).w\ diff --git a/build/RuntimeStoreInstaller.targets b/build/RuntimeStoreInstaller.targets deleted file mode 100644 index bf788a6778..0000000000 --- a/build/RuntimeStoreInstaller.targets +++ /dev/null @@ -1,468 +0,0 @@ - - - <_TemplatesDirectory>$(MSBuildThisFileDirectory)tools\templates\ - <_DockerDir>$(MSBuildThisFileDirectory)tools\docker\ - <_PackagingDir>$(MSBuildThisFileDirectory)tools\packaging\ - <_DebToolDir>$(MSBuildThisFileDirectory)tools\dotnet-deb-tool-consumer\ - <_RuntimeStoreSource>$(RepositoryRoot).deps\Signed\Store\ - <_InstallerSource>$(RepositoryRoot).deps\Installers\ - <_WorkRoot>$(RepositoryRoot).w\ - <_WorkLayoutDir>$(_WorkRoot).l\ - <_WorkOutputDir>$(_WorkRoot).o\ - <_DockerRootDirectory>/opt/code/ - <_InstallersOutputDir>$(ArtifactsDir)installers\ - - aspnetcore-store - dotnet-hosting - $(HostingInstallerName)-$(PackageVersion)-linux-x64.tar.gz - $(_PackagingDir)store_debian_config.json - $(_PackagingDir)hosting_debian_config.json - - https://dotnetcli.blob.core.windows.net/dotnet - $(KOREBUILD_DOTNET_FEED_UNCACHED) - $(PublicCoreFeedPrefix) - - $(PublicCoreFeedPrefix)/aspnetcore/store/2.0.0-26452/Build.RS. - $(CoreFeedPrefix)/Runtime/$(MicrosoftNETCoreApp20PackageVersion)/dotnet-runtime-$(MicrosoftNETCoreApp20PackageVersion)-linux-x64.tar.gz - $(_RuntimeStoreSource)aspnetcore-store-$(PackageVersion)- - $(RuntimeStoreArchivePrefix)linux-x64.tar.gz - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_DependentArchives Include="$(_InstallerSource)dotnet-runtime-$(MicrosoftNETCoreApp20PackageVersion)-linux-x64.tar.gz" /> - <_DependentArchives Include="$(_InstallerSource)Build.RS.linux.tar.gz" /> - - - - - - - - - - - - - - - - - $(RuntimeStoreArchivePrefix)linux-x64.tar.gz - - - $(RuntimeStoreArchivePrefix)osx-x64.tar.gz - - - $(RuntimeStoreArchivePrefix)win7-x64.zip - - - $(RuntimeStoreArchivePrefix)win7-x86.zip - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(MaintainerName) <$(MaintainerEmail)> - $(RPMSummary.Replace('DEB_VERSION','$(RPMVersion)')) - - - - - - - - - rhel.7 - .NET Foundation - /opt/rh/rh-dotnet20/root/usr/lib64/dotnet/ - /usr/share/dotnet/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2.0.0 - - - $(PackageVersion) - - - $(MicrosoftNETCoreApp20PackageVersion) - - - - - @(HostingDependencies->' -d "%(Identity) >= %(Version)"', ' ') - @(RSDependencies->' -d "%(Identity) >= %(Version)"', ' ') - $(RSDependencyArguments) @(RHStoreDirectories->' --directories "%(FullPath)"', ' ') - $(RSDependencyArguments) @(GenericStoreDirectories->' --directories "%(FullPath)"', ' ') - - Image=$(Image);RPMVendor=$(RPMVendor) - RPMFileSuffix=rhel.7-x64.rpm;RPMInstallRoot=$(GenericInstallerInstallRoot) - RPMFileSuffix=rh.rhel.7-x64.rpm;RPMInstallRoot=$(RHInstallerInstallRoot) - - MaintainerName=@(_RSMaintainerName);MaintainerEmail=@(_RSMaintainerEmail) - $(CommonRSArguments);RPMInstallerPrefix=$(RSInstallerName);RPMRevision=@(_RSPackageRevision) - $(CommonRSArguments);RPMSummary=@(_RSInstallerSummary);RPMDescription=@(_RSDescription) - $(CommonRSArguments);RPMLicense=@(_RSLicense);RPMHomepage=@(_RSHomepage) - - $(CommonArguments);MaintainerName=@(_HostingMaintainerName);MaintainerEmail=@(_HostingMaintainerEmail) - $(CommonHostingArguments);RPMInstallerPrefix=$(HostingInstallerName);RPMRevision=@(_HostingRevision) - $(CommonHostingArguments);RPMSummary=@(_HostingSummary);RPMDescription=@(_HostingDescription) - $(CommonHostingArguments);RPMLicense=@(_HostingLicense);RPMHomepage=@(_HostingHomepage) - - $(CommonArguments);$(CommonGenericArguments);$(CommonRSArguments) - $(RS_RPM_Arguments);RSArchive=$(RuntimeStoreLinuxArchiveFilePath);RPMVersion=$(PackageVersion);RPMArguments=$(GenericRSArguments) - - $(CommonArguments);$(CommonGenericArguments);$(CommonHostingArguments) - $(Hosting_RPM_RedHat_Arguments);RPMVersion=$(PackageVersion);RPMArguments=$(HostingFPMArguments) - - $(CommonArguments);$(CommonRHArguments);$(CommonRSArguments) - $(RS_RPM_RedHat_Arguments);RSArchive=$(RuntimeStoreLinuxArchiveFilePath);RPMVersion=$(PackageVersion);RPMArguments=$(RHRSArguments) - - $(CommonArguments);$(CommonRHArguments);$(CommonHostingArguments) - $(Hosting_RPM_Arguments);RPMVersion=$(PackageVersion);RPMArguments=$(HostingFPMArguments) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Image=$(Image);DebConfig=$(RSDebConfigFile);DebPrefix=$(RSInstallerName) - Image=$(Image);DebConfig=$(HostingDebConfigFile);DotnetVersion=$(MicrosoftNETCoreApp20PackageVersion);DebPrefix=$(HostingInstallerName) - - - - - - - - - - - - - - - Version=$(Version) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/SharedFx.props b/build/SharedFx.props new file mode 100644 index 0000000000..7a93d6c086 --- /dev/null +++ b/build/SharedFx.props @@ -0,0 +1,44 @@ + + + + <_WorkRoot>$(RepositoryRoot).w\ + <_WorkLayoutDir>$(_WorkRoot).l\ + <_WorkOutputDir>$(_WorkRoot).o\ + <_SrcDir>$(RepositoryRoot)src\ + <_AllMetapackageDir>$(_SrcDir)Microsoft.AspNetCore.All\ + <_TemplatesDir>$(MSBuildThisFileDirectory)tools\templates\ + <_DockerDir>$(MSBuildThisFileDirectory)tools\docker\ + <_PackagingDir>$(MSBuildThisFileDirectory)tools\packaging\ + <_DebToolDir>$(MSBuildThisFileDirectory)tools\dotnet-deb-tool-consumer\ + <_SharedFxSourceDir>$(RepositoryRoot).deps\Signed\SharedFx\ + <_InstallerSourceDir>$(RepositoryRoot).deps\Installers\ + <_DockerRootDir>/opt/code/ + <_InstallersOutputDir>$(ArtifactsDir)installers\ + + + aspnetcore-shared + dotnet-hosting + $(_PackagingDir)debian_config.json.in + + https://dotnetcli.blob.core.windows.net/dotnet + $(PublicCoreFeedPrefix) + + dotnet-runtime + $(DotnetRuntimePackageName)-$(MicrosoftNETCoreApp21PackageVersion) + $(DotnetRuntimeInstallerName)-linux-x64.tar.gz + $(DotNetAssetRootUrl)/Runtime/$(MicrosoftNETCoreApp21PackageVersion)/$(DotnetRuntimeInstallerArchiveName) + $(_SharedFxSourceDir)$(SharedFxInstallerName)-$(PackageVersion)-linux-x64.tar.gz + + + Microsoft + nugetaspnet@microsoft.com + https://www.asp.net/ + /usr/share/dotnet + 1 + Apache-2.0 + Microsoft ASP.NET Core $(PackageVersion) Shared Framework + Shared Framework for Microsoft ASP.NET Core. It is open source, cross-platform and is supported by Microsoft. We hope you enjoy using it! If you do, please consider joining the active community of developers that are contributing to the project on GitHub (https://github.com/aspnet/home). We happily accept issues and PRs. + Microsoft .NET Core $(PackageVersion) Linux Server Hosting + Microsoft .NET Core Linux Server Hosting enables hosting of ASP.NET Core applications and contains the ASP.NET Core Shared Framework and .NET Core Runtime. It is open source, cross-platform and is supported by Microsoft. We hope you enjoy using it! If you do, please consider joining the active community of developers that are contributing to the project on GitHub (https://github.com/aspnet/home). We happily accept issues and PRs. + + diff --git a/build/SharedFx.targets b/build/SharedFx.targets new file mode 100644 index 0000000000..74e6e3ee1a --- /dev/null +++ b/build/SharedFx.targets @@ -0,0 +1,142 @@ + + + + + + + + + + $(_WorkRoot)Microsoft.AspNetCore.All\ + <_SharedFxProps>Configuration=$(Configuration);DotNetRestoreSourcePropsPath=$(GeneratedRestoreSourcesPropsPath);AspNetUniverseBuildOffline=true + <_SharedFxProps>$(_SharedFxProps);RuntimeFrameworkVersion=$(MicrosoftNETCoreApp21PackageVersion) + + + + + + + + + + + + + + + + + + + + + <_AcceptableSharedFxRIDs Include="win7-x64;win7-x86;osx-x64;linux-x64"/> + + + + true + + + + + + + + + $(_WorkRoot)SharedFx\ + $(_WorkRoot)Publish\ + $(SharedFxOutputDirectory)shared\Microsoft.AspNetCore.All\$(PackageVersion)\ + + <_SharedFxProps>Configuration=$(Configuration);RuntimeIdentifier=$(SharedFxRID) + <_SharedFxProps>$(_SharedFxProps);RuntimeFrameworkVersion=$(MicrosoftNETCoreApp21PackageVersion) + <_SharedFxProps>$(_SharedFxProps);DotNetRestoreSourcePropsPath=$(GeneratedRestoreSourcesPropsPath) + <_SharedFxProps>$(_SharedFxProps);AspNetUniverseBuildOffline=true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + win + linux + osx + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/SharedFxInstaller.targets b/build/SharedFxInstaller.targets new file mode 100644 index 0000000000..010bcf5797 --- /dev/null +++ b/build/SharedFxInstaller.targets @@ -0,0 +1,262 @@ + + + + + + + + + + + + + + + + + + + + + + + + $(HostingInstallerName)-$(PackageVersion)-linux-x64.tar.gz + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DATE=$([System.DateTime]::UtcNow.ToString(ddd MMM dd yyyy)) + $(ChangeLogProps);MAINTAINER_NAME=$(RpmMaintainerName) + $(ChangeLogProps);MAINTAINER_EMAIL=$(RpmMaintainerEmail) + $(ChangeLogProps);PACKAGE_VERSION=$(RpmVersion) + $(ChangeLogProps);PACKAGE_REVISION=$(RpmRevision) + + + + + + + + + + + rhel.7 + .NET Foundation + /opt/rh/rh-dotnet20/root/usr/lib64/dotnet + + + + + + + + + + + + + + + + @(RpmHostingDependencies->' -d "%(Identity) >= %(Version)"', ' ') + @(RpmSharedFxDependencies->' -d "%(Identity) >= %(Version)"', ' ') + @(RpmRHSharedFxDirectories->' --directories "%(FullPath)"', ' ') + @(RpmGenericSharedFxDirectories->' --directories "%(FullPath)"', ' ') + + Image=$(Image);RpmVendor=$(RpmVendor);RpmVersion=$(PackageVersion) + $(RpmCommonArguments);RpmMaintainerName=$(MaintainerName);RpmMaintainerEmail=$(MaintainerEmail) + $(RpmCommonArguments);RpmHomepage=$(Homepage);RpmRevision=$(PackageRevision) + $(RpmCommonArguments);RpmLicense=$(LicenseType) + RpmFileSuffix=rhel.7-x64.rpm;RpmInstallRoot=$(InstallRoot) + RpmFileSuffix=rh.rhel.7-x64.rpm;RpmInstallRoot=$(RHInstallRoot) + + RpmInstallerPrefix=$(SharedFxInstallerName);SharedFxArchive=$(SharedFxLinuxArchiveFilePath) + $(RpmCommonSharedFxArguments);RpmMSummary=$(SharedFxSummary);RpmDescription=$(SharedFxDescription) + + RpmInstallerPrefix=$(HostingInstallerName);RpmArguments=$(RpmHostingArguments) + $(RpmCommonHostingArguments);RpmMSummary=$(HostingSummary);RpmDescription=$(HostingDescription) + + $(RpmCommonArguments);$(RpmCommonGenericArguments);$(RpmCommonSharedFxArguments);RpmArguments=$(RpmGenericSharedFxArguments) $(RpmSharedFxArguments) + $(RpmCommonArguments);$(RpmCommonGenericArguments);$(RpmCommonHostingArguments) + $(RpmCommonArguments);$(RpmCommonRHArguments);$(RpmCommonSharedFxArguments);RpmArguments=$(RpmRHSharedFxArguments) $(RpmSharedFxArguments) + $(RpmCommonArguments);$(RpmCommonRHArguments);$(RpmCommonHostingArguments) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MAINTAINER_NAME=$(MaintainerName) + $(DebConfigProps);MAINTAINER_EMAIL=$(MaintainerEmail) + $(DebConfigProps);HOMEPAGE=$(Homepage) + $(DebConfigProps);INSTALL_ROOT=$(InstallRoot) + $(DebConfigProps);PACKAGE_NAME=$(DebPrefix) + $(DebConfigProps);PACKAGE_REVISION=$(PackageRevision) + $(DebConfigProps);LICENSE_TYPE=$(LicenseType) + $(DebConfigProps);SHORT_DESCRIPTION=$(DebSummary) + $(DebConfigProps);LONG_DESCRIPTION=$(DebDescription) + $(DebConfigProps);DEBIAN_DEPENDENCIES=$(DebDependencies) + + + + + + + + + + + + + + + + + + + + + + + + + <_DebSharedFxDependencies Include="aspnetcore-store-2.0.3"/> + <_DebHostingDependencies Include="$(DotnetRuntimeInstallerName)"/> + <_DebHostingDependencies Include="$(SharedFxInstallerName)-$(Version)"/> + + + + @(_DebSharedFxDependencies->'"%(Identity)": {}', ', ') + @(_DebHostingDependencies->'"%(Identity)": {}', ', ') + + Image=$(Image);DebVersion=$(Version) + DebPrefix=$(SharedFxInstallerName);DebSummary=$(SharedFxSummary);DebDescription=$(SharedFxDescription) + $(DebSharedFxProps);DebDependencies=$(DebSharedFxDependencies);SharedFxArchive=$(SharedFxLinuxArchiveFilePath) + DebPrefix=$(HostingInstallerName);DebSummary=$(HostingSummary);DebDescription=$(HostingDescription) + $(DebHostingProps);DebDependencies=$(DebHostingDependencies) + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/repo.targets b/build/repo.targets index 2c2b64d08a..f32a554912 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -1,9 +1,10 @@ - + + <_RepositoryBuildTargets Condition="'$(_RepositoryBuildTargets)'=='' AND '$(SkipTests)'=='true'">/t:Package /t:VerifyPackages @@ -19,7 +20,7 @@ $(CleanDependsOn);CleanArtifacts;CleanUniverseArtifacts $(RestoreDependsOn);InstallDotNet;RestoreExternalDependencies $(CompileDependsOn);BuildRepositories - $(PackageDependsOn);BuildAllMetapackage;BuildTemplates;SplitPackages + $(PackageDependsOn);BuildMetapackage;BuildTemplates;SplitPackages $(VerifyDependsOn);VerifyCoherentVersions diff --git a/build/tasks/AddMetapackageReferences.cs b/build/tasks/AddMetapackageReferences.cs index 5488dec22e..7a33657d17 100644 --- a/build/tasks/AddMetapackageReferences.cs +++ b/build/tasks/AddMetapackageReferences.cs @@ -49,11 +49,11 @@ namespace RepoTasks var packageVersion = buildArtifacts .Single(p => string.Equals(p.PackageInfo.Id, packageName, StringComparison.OrdinalIgnoreCase)) .PackageInfo.Version.ToString(); - Log.LogMessage(MessageImportance.High, $" - Package: {packageName} Version: {packageVersion}"); + Log.LogMessage(MessageImportance.High, $" - Package: {packageName} Version: [{packageVersion}]"); var packageReferenceElement = xmlDoc.CreateElement("PackageReference"); packageReferenceElement.SetAttribute("Include", packageName); - packageReferenceElement.SetAttribute("Version", packageVersion); + packageReferenceElement.SetAttribute("Version", $"[{packageVersion}]"); packageReferenceElement.SetAttribute("PrivateAssets", "None"); itemGroupElement.AppendChild(packageReferenceElement); @@ -63,11 +63,11 @@ namespace RepoTasks { var packageName = package.ItemSpec; var packageVersion = package.GetMetadata("Version"); - Log.LogMessage(MessageImportance.High, $" - Package: {packageName} Version: {packageVersion}"); + Log.LogMessage(MessageImportance.High, $" - Package: {packageName} Version: [{packageVersion}]"); var packageReferenceElement = xmlDoc.CreateElement("PackageReference"); packageReferenceElement.SetAttribute("Include", packageName); - packageReferenceElement.SetAttribute("Version", packageVersion); + packageReferenceElement.SetAttribute("Version", $"[{packageVersion}]"); packageReferenceElement.SetAttribute("PrivateAssets", "None"); itemGroupElement.AppendChild(packageReferenceElement); diff --git a/build/tasks/ProcessSharedFrameworkDeps.cs b/build/tasks/ProcessSharedFrameworkDeps.cs new file mode 100644 index 0000000000..87250780a8 --- /dev/null +++ b/build/tasks/ProcessSharedFrameworkDeps.cs @@ -0,0 +1,76 @@ +// 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. +// Sourced from https://github.com/dotnet/core-setup/tree/be8d8e3486b2bf598ed69d39b1629a24caaba45e/tools-local/tasks, needs to be kept in sync + +using System; +using System.IO; +using System.Linq; +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; +using Microsoft.Extensions.DependencyModel; +using NuGet.Common; +using NuGet.ProjectModel; +using RepoTasks.Utilities; + +namespace RepoTasks +{ + public partial class ProcessSharedFrameworkDeps : Task + { + [Required] + public string AssetsFilePath { get; set; } + + [Required] + public string DepsFilePath { get; set; } + + public string[] PackagesToRemove { get; set; } + + [Required] + public string Runtime { get; set; } + + public override bool Execute() + { + ExecuteCore(); + + return true; + } + + private void ExecuteCore() + { + DependencyContext context; + using (var depsStream = File.OpenRead(DepsFilePath)) + { + context = new DependencyContextJsonReader().Read(depsStream); + } + + LockFile lockFile = LockFileUtilities.GetLockFile(AssetsFilePath, NullLogger.Instance); + if (lockFile == null) + { + throw new ArgumentException($"Could not load a LockFile at '{AssetsFilePath}'.", nameof(AssetsFilePath)); + } + + var manager = new RuntimeGraphManager(); + var graph = manager.Collect(lockFile); + var expandedGraph = manager.Expand(graph, Runtime); + + var trimmedRuntimeLibraries = context.RuntimeLibraries; + + if (PackagesToRemove != null && PackagesToRemove.Any()) + { + trimmedRuntimeLibraries = RuntimeReference.RemoveReferences(context.RuntimeLibraries, PackagesToRemove); + } + + context = new DependencyContext( + context.Target, + context.CompilationOptions, + context.CompileLibraries, + trimmedRuntimeLibraries, + expandedGraph + ); + + using (var depsStream = File.Create(DepsFilePath)) + { + new DependencyContextWriter().Write(context, depsStream); + } + } + } +} \ No newline at end of file diff --git a/build/tasks/RepoTasks.csproj b/build/tasks/RepoTasks.csproj index 39574ccdb1..2b538f7e0b 100644 --- a/build/tasks/RepoTasks.csproj +++ b/build/tasks/RepoTasks.csproj @@ -7,6 +7,7 @@ + diff --git a/build/tasks/RepoTasks.tasks b/build/tasks/RepoTasks.tasks index f5484f790d..10b37233ce 100644 --- a/build/tasks/RepoTasks.tasks +++ b/build/tasks/RepoTasks.tasks @@ -16,4 +16,5 @@ + diff --git a/build/tasks/Utilities/RuntimeGraphManager.cs b/build/tasks/Utilities/RuntimeGraphManager.cs new file mode 100644 index 0000000000..d3552f36be --- /dev/null +++ b/build/tasks/Utilities/RuntimeGraphManager.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Sourced from https://github.com/dotnet/core-setup/tree/be8d8e3486b2bf598ed69d39b1629a24caaba45e/tools-local/tasks, needs to be kept in sync + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Microsoft.Extensions.DependencyModel; +using NuGet.Frameworks; +using NuGet.Packaging; +using NuGet.ProjectModel; +using NuGet.RuntimeModel; + +namespace RepoTasks.Utilities +{ + internal class RuntimeGraphManager + { + private const string RuntimeJsonFileName = "runtime.json"; + + public RuntimeGraph Collect(LockFile lockFile) + { + string userPackageFolder = lockFile.PackageFolders.FirstOrDefault()?.Path; + var fallBackFolders = lockFile.PackageFolders.Skip(1).Select(f => f.Path); + var packageResolver = new FallbackPackagePathResolver(userPackageFolder, fallBackFolders); + + var graph = RuntimeGraph.Empty; + foreach (var library in lockFile.Libraries) + { + if (string.Equals(library.Type, "package", StringComparison.OrdinalIgnoreCase)) + { + var runtimeJson = library.Files.FirstOrDefault(f => f == RuntimeJsonFileName); + if (runtimeJson != null) + { + var libraryPath = packageResolver.GetPackageDirectory(library.Name, library.Version); + var runtimeJsonFullName = Path.Combine(libraryPath, runtimeJson); + graph = RuntimeGraph.Merge(graph, JsonRuntimeFormat.ReadRuntimeGraph(runtimeJsonFullName)); + } + } + } + return graph; + } + + public IEnumerable Expand(RuntimeGraph runtimeGraph, string runtime) + { + var importers = FindImporters(runtimeGraph, runtime); + foreach (var importer in importers) + { + // ExpandRuntime return runtime itself as first item so we are skiping it + yield return new RuntimeFallbacks(importer, runtimeGraph.ExpandRuntime(importer).Skip(1)); + } + } + + private IEnumerable FindImporters(RuntimeGraph runtimeGraph, string runtime) + { + foreach (var runtimePair in runtimeGraph.Runtimes) + { + var expanded = runtimeGraph.ExpandRuntime(runtimePair.Key); + if (expanded.Contains(runtime)) + { + yield return runtimePair.Key; + } + } + } + } +} \ No newline at end of file diff --git a/build/tasks/Utilities/RuntimeReference.cs b/build/tasks/Utilities/RuntimeReference.cs new file mode 100644 index 0000000000..4907a73723 --- /dev/null +++ b/build/tasks/Utilities/RuntimeReference.cs @@ -0,0 +1,63 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// Sourced from https://github.com/dotnet/core-setup/tree/be8d8e3486b2bf598ed69d39b1629a24caaba45e/tools-local/tasks, needs to be kept in sync + +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.Extensions.DependencyModel; + +namespace RepoTasks.Utilities +{ + internal class RuntimeReference + { + public static List RemoveReferences(IReadOnlyList runtimeLibraries, IEnumerable packages) + { + List result = new List(); + + foreach (var runtimeLib in runtimeLibraries) + { + if (string.IsNullOrEmpty(packages.FirstOrDefault(elem => runtimeLib.Name.Equals(elem, StringComparison.OrdinalIgnoreCase)))) + { + List toRemoveDependecy = new List(); + foreach (var dependency in runtimeLib.Dependencies) + { + if (!string.IsNullOrEmpty(packages.FirstOrDefault(elem => dependency.Name.Equals(elem, StringComparison.OrdinalIgnoreCase)))) + { + toRemoveDependecy.Add(dependency); + } + } + + if (toRemoveDependecy.Count > 0) + { + List modifiedDependencies = new List(); + foreach (var dependency in runtimeLib.Dependencies) + { + if (!toRemoveDependecy.Contains(dependency)) + { + modifiedDependencies.Add(dependency); + } + } + + + result.Add(new RuntimeLibrary(runtimeLib.Type, + runtimeLib.Name, + runtimeLib.Version, + runtimeLib.Hash, + runtimeLib.RuntimeAssemblyGroups, + runtimeLib.NativeLibraryGroups, + runtimeLib.ResourceAssemblies, + modifiedDependencies, + runtimeLib.Serviceable)); + + } + else if (string.IsNullOrEmpty(packages.FirstOrDefault(elem => runtimeLib.Name.Equals(elem, StringComparison.OrdinalIgnoreCase)))) + { + result.Add(runtimeLib); + } + } + } + return result; + } + } +} \ No newline at end of file diff --git a/build/tools/packaging/changelog b/build/tools/packaging/changelog deleted file mode 100644 index f28d88ed10..0000000000 --- a/build/tools/packaging/changelog +++ /dev/null @@ -1,2 +0,0 @@ -* DATE MAINTAINER_NAME - PACKAGE_VERSION-PACKAGE_REVISION -- \ No newline at end of file diff --git a/build/tools/packaging/changelog.in b/build/tools/packaging/changelog.in new file mode 100644 index 0000000000..9196011924 --- /dev/null +++ b/build/tools/packaging/changelog.in @@ -0,0 +1,2 @@ +* ${DATE} ${MAINTAINER_NAME} <${MAINTAINER_EMAIL}> - ${PACKAGE_VERSION}-${PACKAGE_REVISION} +- \ No newline at end of file diff --git a/build/tools/packaging/hosting_debian_config.json b/build/tools/packaging/debian_config.json.in similarity index 50% rename from build/tools/packaging/hosting_debian_config.json rename to build/tools/packaging/debian_config.json.in index 92c825e901..d7449760c4 100644 --- a/build/tools/packaging/hosting_debian_config.json +++ b/build/tools/packaging/debian_config.json.in @@ -1,17 +1,17 @@ { - "maintainer_name": "Microsoft", - "maintainer_email": "nugetaspnet@microsoft.com", + "maintainer_name": "${MAINTAINER_NAME}", + "maintainer_email": "${MAINTAINER_EMAIL}", - "package_name": "dotnet-hosting", - "install_root": "/usr/share/dotnet", + "package_name": "${PACKAGE_NAME}", + "install_root": "${INSTALL_ROOT}", - "short_description": "Microsoft .NET Core DEB_VERSION Linux Server Hosting", - "long_description": "Microsoft .NET Core Linux Server Hosting enables hosting of ASP.NET Core applications and contains the ASP.NET Core Runtime Package Store and .NET Core Runtime. It is open source, cross-platform and is supported by Microsoft. We hope you enjoy using it! If you do, please consider joining the active community of developers that are contributing to the project on GitHub (https://github.com/aspnet/home). We happily accept issues and PRs.", - "homepage": "https://www.asp.net/", + "short_description": "${SHORT_DESCRIPTION}", + "long_description": "${LONG_DESCRIPTION}", + "homepage": "${HOMEPAGE}", "release":{ "package_version":"0.0.0.0", - "package_revision":"1", + "package_revision":"${PACKAGE_REVISION}", "urgency" : "low", "changelog_message" : "" }, @@ -24,12 +24,11 @@ "copyright": "Microsoft", "license": { - "type": "Apache-2.0", + "type": "${LICENSE_TYPE}", "full_text": "Copyright (c) .NET Foundation. All rights reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\nthese files except in compliance with the License. You may obtain a copy of the\nLicense at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed\nunder the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\nCONDITIONS OF ANY KIND, either express or implied. See the License for the\nspecific language governing permissions and limitations under the License." }, "debian_dependencies": { - "dotnet-runtime-DOTNET_VERSION": {}, - "aspnetcore-store-DEB_VERSION": {} + ${DEBIAN_DEPENDENCIES} } } \ No newline at end of file diff --git a/build/tools/templates/Archive/Archive.csproj b/build/tools/templates/Archive/Archive.csproj index b548cc6f7a..5c25bc8c1d 100644 --- a/build/tools/templates/Archive/Archive.csproj +++ b/build/tools/templates/Archive/Archive.csproj @@ -3,9 +3,9 @@ - netcoreapp2.0 + netcoreapp2.1 false - netcoreapp2.0 + netcoreapp2.1 $(DotNetRestoreSources) $(RestoreSources);https://dotnet.myget.org/F/dotnet-core/api/v3/index.json; diff --git a/build/tools/templates/SharedFx/SharedFx.csproj b/build/tools/templates/SharedFx/SharedFx.csproj new file mode 100644 index 0000000000..0f4be93f8d --- /dev/null +++ b/build/tools/templates/SharedFx/SharedFx.csproj @@ -0,0 +1,26 @@ + + + + + + netcoreapp2.1 + true + true + $(DotNetRestoreSources) + + $(RestoreSources); + https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; + https://dotnet.myget.org/F/aspnetcore-master/api/v3/index.json; + https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; + + + $(RestoreSources); + https://api.nuget.org/v3/index.json; + + + + + + + + diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index 5636024221..491f3f3b01 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -16,16 +16,14 @@ false false - netcoreapp2.0 + netcoreapp2.1 aspnetcore Microsoft.AspNetCore.All false - $(MicrosoftNETCoreApp20PackageVersion) - - + diff --git a/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets b/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets deleted file mode 100644 index a590cf01f1..0000000000 --- a/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets +++ /dev/null @@ -1,29 +0,0 @@ - - - true - - - - - - - - - - - - - $(TargetManifestFiles);@(AspNetCoreTargetManifestFiles) - - - diff --git a/src/Microsoft.AspNetCore.All/build/aspnetcore-store-2.0.0-common.xml b/src/Microsoft.AspNetCore.All/build/aspnetcore-store-2.0.0-common.xml deleted file mode 100755 index 3b0c4bda7c..0000000000 --- a/src/Microsoft.AspNetCore.All/build/aspnetcore-store-2.0.0-common.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/Microsoft.AspNetCore.All/build/aspnetcore-store-2.0.0-linux-x64.xml b/src/Microsoft.AspNetCore.All/build/aspnetcore-store-2.0.0-linux-x64.xml deleted file mode 100755 index e548a00368..0000000000 --- a/src/Microsoft.AspNetCore.All/build/aspnetcore-store-2.0.0-linux-x64.xml +++ /dev/null @@ -1,171 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Microsoft.AspNetCore.All/build/aspnetcore-store-2.0.0-osx-x64.xml b/src/Microsoft.AspNetCore.All/build/aspnetcore-store-2.0.0-osx-x64.xml deleted file mode 100755 index 369db3ef5b..0000000000 --- a/src/Microsoft.AspNetCore.All/build/aspnetcore-store-2.0.0-osx-x64.xml +++ /dev/null @@ -1,171 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Microsoft.AspNetCore.All/build/aspnetcore-store-2.0.0-win7-x64.xml b/src/Microsoft.AspNetCore.All/build/aspnetcore-store-2.0.0-win7-x64.xml deleted file mode 100755 index 0155a8e72c..0000000000 --- a/src/Microsoft.AspNetCore.All/build/aspnetcore-store-2.0.0-win7-x64.xml +++ /dev/null @@ -1,172 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Microsoft.AspNetCore.All/build/aspnetcore-store-2.0.0-win7-x86.xml b/src/Microsoft.AspNetCore.All/build/aspnetcore-store-2.0.0-win7-x86.xml deleted file mode 100755 index 362dab9895..0000000000 --- a/src/Microsoft.AspNetCore.All/build/aspnetcore-store-2.0.0-win7-x86.xml +++ /dev/null @@ -1,172 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Microsoft.AspNetCore.All/build/netcoreapp2.0/Microsoft.AspNetCore.All.targets b/src/Microsoft.AspNetCore.All/build/netcoreapp2.0/Microsoft.AspNetCore.All.targets deleted file mode 100644 index 0bed51f606..0000000000 --- a/src/Microsoft.AspNetCore.All/build/netcoreapp2.0/Microsoft.AspNetCore.All.targets +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/Microsoft.AspNetCore.All/build/netcoreapp2.1/Microsoft.AspNetCore.All.props b/src/Microsoft.AspNetCore.All/build/netcoreapp2.1/Microsoft.AspNetCore.All.props new file mode 100644 index 0000000000..3a5216e5f1 --- /dev/null +++ b/src/Microsoft.AspNetCore.All/build/netcoreapp2.1/Microsoft.AspNetCore.All.props @@ -0,0 +1,5 @@ + + + Microsoft.AspNetCore.All + + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.All/lib/netcoreapp2.0/_._ b/src/Microsoft.AspNetCore.All/lib/netcoreapp2.1/_._ similarity index 100% rename from src/Microsoft.AspNetCore.All/lib/netcoreapp2.0/_._ rename to src/Microsoft.AspNetCore.All/lib/netcoreapp2.1/_._