Pass list of references via temp file for resolve-dependencies and build commands

This commit is contained in:
Marcus Bowyer 2018-04-25 16:52:36 -07:00 committed by Steve Sanderson
parent 18b9a70dbe
commit e5d78f8886
3 changed files with 48 additions and 26 deletions

View File

@ -15,9 +15,9 @@ namespace Microsoft.AspNetCore.Blazor.Build.Cli.Commands
"Path to the HTML Page containing the Blazor bootstrap script tag.",
CommandOptionType.SingleValue);
var references = command.Option("--reference",
"The path from the _bin folder to a given referenced dll file (typically just the dll name)",
CommandOptionType.MultipleValue);
var referencesFile = command.Option("--references",
"The path to a file that lists the paths to given referenced dll files",
CommandOptionType.SingleValue);
var embeddedResourcesFile = command.Option("--embedded-resources",
"The path to a file that lists the paths of .NET assemblies that may contain embedded resources (typically, referenced assemblies in their pre-linked states)",
@ -37,7 +37,7 @@ namespace Microsoft.AspNetCore.Blazor.Build.Cli.Commands
command.OnExecute(() =>
{
if (string.IsNullOrEmpty(mainAssemblyPath.Value) ||
!clientPage.HasValue() || !references.HasValue() || !outputPath.HasValue())
!clientPage.HasValue() || !referencesFile.HasValue() || !outputPath.HasValue())
{
command.ShowHelp(command.Name);
return 1;
@ -45,6 +45,10 @@ namespace Microsoft.AspNetCore.Blazor.Build.Cli.Commands
try
{
var referencesSources = referencesFile.HasValue()
? File.ReadAllLines(referencesFile.Value())
: Array.Empty<string>();
var embeddedResourcesSources = embeddedResourcesFile.HasValue()
? File.ReadAllLines(embeddedResourcesFile.Value())
: Array.Empty<string>();
@ -52,7 +56,7 @@ namespace Microsoft.AspNetCore.Blazor.Build.Cli.Commands
IndexHtmlWriter.UpdateIndex(
clientPage.Value(),
mainAssemblyPath.Value,
references.Values.ToArray(),
referencesSources,
embeddedResourcesSources,
linkerEnabledFlag.HasValue(),
outputPath.Value());

View File

@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.IO;
using Microsoft.Extensions.CommandLineUtils;
namespace Microsoft.AspNetCore.Blazor.Build.Cli.Commands
@ -10,9 +11,9 @@ namespace Microsoft.AspNetCore.Blazor.Build.Cli.Commands
{
public static void Command(CommandLineApplication command)
{
var references = command.Option("--reference",
"Full path to a referenced assembly file",
CommandOptionType.MultipleValue);
var referencesFile = command.Option("--references",
"The path to a file that lists the paths to given referenced dll files",
CommandOptionType.SingleValue);
var baseClassLibrary = command.Option("--base-class-library",
"Full path to a directory in which BCL assemblies can be found",
@ -36,9 +37,13 @@ namespace Microsoft.AspNetCore.Blazor.Build.Cli.Commands
try
{
var referencesSources = referencesFile.HasValue()
? File.ReadAllLines(referencesFile.Value())
: Array.Empty<string>();
RuntimeDependenciesResolver.ResolveRuntimeDependencies(
mainAssemblyPath.Value,
references.Values.ToArray(),
referencesSources,
baseClassLibrary.Values.ToArray(),
outputPath.Value());

View File

@ -24,12 +24,12 @@
<FileWrites Include="@(BlazorItemOutput->'%(TargetOutputPath)')" />
</ItemGroup>
</Target>
<Target Name="_BlazorTrackResolveReferencesDidRun" AfterTargets="ResolveReferences">
<PropertyGroup>
<!-- So we know we can trust @(ReferenceCopyLocalPaths) later -->
<_BlazorResolveReferencesDidRun>true</_BlazorResolveReferencesDidRun>
</PropertyGroup>
</PropertyGroup>
</Target>
<Target Name="_BlazorBuildReport"
@ -199,7 +199,7 @@
<!-- /obj/<<configuration>>/<<targetframework>>/blazor/inputs.copylocal.txt -->
<BlazorLocalReferencesOutputPath>$(BlazorIntermediateOutputPath)inputs.copylocal.txt</BlazorLocalReferencesOutputPath>
<!-- /obj/<<configuration>>/<<targetframework>>/blazor/inputs.linkerswitch.cache -->
<BlazorBuildLinkerSwitchInputsCache>$(BlazorIntermediateOutputPath)inputs.linkerswitch.cache</BlazorBuildLinkerSwitchInputsCache>
@ -236,6 +236,9 @@
<!-- /obj/<<configuration>>/<<targetframework>>/blazor/inputs.index.cache -->
<BlazorBuildIndexInputsCache>$(BlazorIntermediateOutputPath)inputs.index.cache</BlazorBuildIndexInputsCache>
<!-- /obj/<<configuration>>/<<targetframework>>/blazor/embedded.resources.txt -->
<BlazorReferencesConfigFilePath>$(BlazorIntermediateOutputPath)references.txt</BlazorReferencesConfigFilePath>
<!-- /obj/<<configuration>>/<<targetframework>>/blazor/embedded.resources.txt -->
<BlazorEmbeddedResourcesConfigFilePath>$(BlazorIntermediateOutputPath)embedded.resources.txt</BlazorEmbeddedResourcesConfigFilePath>
@ -279,7 +282,7 @@
File="$(BlazorBuildCommonInputsCache)"
Overwrite="True"
WriteOnlyWhenDifferent="True" />
<WriteLinesToFile
Lines="@(_BlazorDependencyInput)"
File="$(BlazorLocalReferencesOutputPath)"
@ -389,9 +392,9 @@
Overwrite="True"
WriteOnlyWhenDifferent="True" />
<ItemGroup>
<FileWrites Include="$(BlazorBuildLinkerInputsCache)" />
</ItemGroup>
<ItemGroup>
<FileWrites Include="$(BlazorBuildLinkerInputsCache)" />
</ItemGroup>
</Target>
@ -472,10 +475,10 @@
<PropertyGroup>
<_CollectResolvedAssembliesDependsOn>
_ResolveBlazorApplicationAssemblies;
_ReadResolvedBlazorApplicationAssemblies;
_IntermediateCopyBlazorApplicationAssemblies;
_TouchBlazorApplicationAssemblies
_ResolveBlazorApplicationAssemblies;
_ReadResolvedBlazorApplicationAssemblies;
_IntermediateCopyBlazorApplicationAssemblies;
_TouchBlazorApplicationAssemblies
</_CollectResolvedAssembliesDependsOn>
</PropertyGroup>
@ -509,14 +512,18 @@
@(_BlazorDependencyInput)"
Outputs="$(BlazorResolvedAssembliesOutputPath)"
>
<ItemGroup>
<_DependenciesParameter Include="@(_BlazorDependencyInput->'--reference &quot;%(Identity)&quot;')" />
</ItemGroup>
<PropertyGroup>
<_ReferencesArg Condition="'@(_BlazorDependencyInput)' != ''">--references &quot;$(BlazorReferencesConfigFilePath)&quot;</_ReferencesArg>
<_BclParameter>--base-class-library &quot;$(MonoBaseClassLibraryPath)&quot; --base-class-library &quot;$(MonoBaseClassLibraryFacadesPath)&quot;</_BclParameter>
</PropertyGroup>
<Exec Command="$(BlazorBuildExe) resolve-dependencies &quot;@(IntermediateAssembly->'%(FullPath)')&quot; @(_DependenciesParameter, ' ') $(_BclParameter) --output &quot;$(BlazorResolvedAssembliesOutputPath)&quot;" />
<WriteLinesToFile
File="$(BlazorReferencesConfigFilePath)"
Lines="@(_BlazorDependencyInput)"
Overwrite="true" />
<Exec Command="$(BlazorBuildExe) resolve-dependencies &quot;@(IntermediateAssembly->'%(FullPath)')&quot; $(_ReferencesArg) $(_BclParameter) --output &quot;$(BlazorResolvedAssembliesOutputPath)&quot;" />
</Target>
@ -600,16 +607,22 @@
</ItemGroup>
<PropertyGroup>
<_LinkerEnabledFlag Condition="'$(_BlazorShouldLinkApplicationAssemblies)' != ''">--linker-enabled</_LinkerEnabledFlag>
<_ReferencesArg Condition="'@(_AppReferences)' != ''">--references &quot;$(BlazorReferencesConfigFilePath)&quot;</_ReferencesArg>
<_EmbeddedResourcesArg Condition="'@(_UnlinkedAppReferencesPaths)' != ''">--embedded-resources &quot;$(BlazorEmbeddedResourcesConfigFilePath)&quot;</_EmbeddedResourcesArg>
</PropertyGroup>
<WriteLinesToFile
File="$(BlazorReferencesConfigFilePath)"
Lines="@(_AppReferences)"
Overwrite="true" />
<WriteLinesToFile
Condition="'@(_UnlinkedAppReferencesPaths)' != ''"
File="$(BlazorEmbeddedResourcesConfigFilePath)"
Lines="@(_UnlinkedAppReferencesPaths)"
Overwrite="true" />
<Exec Command="$(BlazorBuildExe) build @(IntermediateAssembly) --html-page &quot;$(BlazorIndexHtml)&quot; @(_AppReferences->'--reference &quot;%(Identity)&quot;', ' ') $(_EmbeddedResourcesArg) $(_LinkerEnabledFlag) --output &quot;$(BlazorIndexHtmlOutputPath)&quot;" />
<Exec Command="$(BlazorBuildExe) build @(IntermediateAssembly) --html-page &quot;$(BlazorIndexHtml)&quot; $(_ReferencesArg) $(_EmbeddedResourcesArg) $(_LinkerEnabledFlag) --output &quot;$(BlazorIndexHtmlOutputPath)&quot;" />
<ItemGroup Condition="Exists('$(BlazorIndexHtmlOutputPath)')">
<_BlazorIndex Include="$(BlazorIndexHtmlOutputPath)" />
@ -627,4 +640,4 @@
</Target>
</Project>
</Project>