diff --git a/build/Microsoft.DotNet.Cli.tasks b/build/Microsoft.DotNet.Cli.tasks index 901a48f84..1c846d8b0 100644 --- a/build/Microsoft.DotNet.Cli.tasks +++ b/build/Microsoft.DotNet.Cli.tasks @@ -1,6 +1,7 @@ + diff --git a/build_projects/dotnet-cli-build/AddToDeps.cs b/build_projects/dotnet-cli-build/AddToDeps.cs new file mode 100644 index 000000000..ca02cd474 --- /dev/null +++ b/build_projects/dotnet-cli-build/AddToDeps.cs @@ -0,0 +1,67 @@ +// 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. + +using System.IO; +using System.Linq; + +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; +using Microsoft.Extensions.DependencyModel; + +namespace Microsoft.DotNet.Cli.Build +{ + /// + /// Merges additional .deps.json files into target .deps.json files. + /// + public class AddToDeps : Task + { + /// + /// Paths to target .deps.json files, into which will be merged. + /// These files will be overwritten with the merge result. + /// + [Required] + public string[] TargetDeps { get; set; } + + /// + /// Paths to additional .deps.json files to merge into . + /// + [Required] + public string[] AdditionalDeps { get; set; } + + public override bool Execute() + { + DependencyContext additionalContext = Read(AdditionalDeps.First()); + + foreach (string additionalPath in AdditionalDeps.Skip(1)) + { + additionalContext = additionalContext.Merge(Read(additionalPath)); + } + + foreach (string targetPath in TargetDeps) + { + DependencyContext targetContext = Read(targetPath).Merge(additionalContext); + Write(targetContext, targetPath); + } + + return true; + } + + private static DependencyContext Read(string path) + { + using (FileStream stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read)) + using (var reader = new DependencyContextJsonReader()) + { + return reader.Read(stream); + } + } + + private static void Write(DependencyContext context, string path) + { + using (FileStream stream = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.Read)) + { + var writer = new DependencyContextWriter(); // unlike reader, writer is not disposable + writer.Write(context, stream); + } + } + } +} \ No newline at end of file diff --git a/build_projects/dotnet-cli-build/dotnet-cli-build.csproj b/build_projects/dotnet-cli-build/dotnet-cli-build.csproj index 872cae995..2db08aaa8 100644 --- a/build_projects/dotnet-cli-build/dotnet-cli-build.csproj +++ b/build_projects/dotnet-cli-build/dotnet-cli-build.csproj @@ -29,5 +29,6 @@ + diff --git a/src/redist/redist.csproj b/src/redist/redist.csproj index 4dbd46f5d..685e89d79 100644 --- a/src/redist/redist.csproj +++ b/src/redist/redist.csproj @@ -24,9 +24,6 @@ All - - All - @@ -77,23 +74,31 @@ - - - + + + + + "version": ".*" "version": "$(CLI_SharedFrameworkVersion)" + + + + + + + + $(CliVersionPrefix) + $(CliTargetFramework) + $(CLI_SharedFrameworkVersion) + $(RoslynDirectory)/bincore + $(CommitCount) + false + false + false + + + + + + + + + + + + + + + + + +