Split BuildTools into "Build" (for end-user app builds) and "BuildTools" (for building this repo only)

This commit is contained in:
Steve Sanderson 2017-12-14 15:32:28 +00:00
parent c49a67dcf0
commit a4b85ddf53
28 changed files with 120 additions and 47 deletions

View File

@ -50,6 +50,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Blazor.Common.Tes
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Blazor.Build.Test", "test\Microsoft.Blazor.Build.Test\Microsoft.Blazor.Build.Test.csproj", "{709C7EBE-EB93-4F6D-9491-D714B0D2E898}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Blazor.Build", "src\Microsoft.Blazor.Build\Microsoft.Blazor.Build.csproj", "{8B3D0F1C-0E38-4E6D-BFF1-C4FDA0CD9815}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -120,6 +122,10 @@ Global
{709C7EBE-EB93-4F6D-9491-D714B0D2E898}.Debug|Any CPU.Build.0 = Debug|Any CPU
{709C7EBE-EB93-4F6D-9491-D714B0D2E898}.Release|Any CPU.ActiveCfg = Release|Any CPU
{709C7EBE-EB93-4F6D-9491-D714B0D2E898}.Release|Any CPU.Build.0 = Release|Any CPU
{8B3D0F1C-0E38-4E6D-BFF1-C4FDA0CD9815}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8B3D0F1C-0E38-4E6D-BFF1-C4FDA0CD9815}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8B3D0F1C-0E38-4E6D-BFF1-C4FDA0CD9815}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8B3D0F1C-0E38-4E6D-BFF1-C4FDA0CD9815}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -144,6 +150,7 @@ Global
{21EF76A4-63CC-455D-907C-F86C9E442CEC} = {B867E038-B3CE-43E3-9292-61568C46CDEB}
{7F0BF3EA-6985-49F6-8070-0BBA41448BB0} = {ADA3AE29-F6DE-49F6-8C7C-B321508CAE8E}
{709C7EBE-EB93-4F6D-9491-D714B0D2E898} = {ADA3AE29-F6DE-49F6-8C7C-B321508CAE8E}
{8B3D0F1C-0E38-4E6D-BFF1-C4FDA0CD9815} = {B867E038-B3CE-43E3-9292-61568C46CDEB}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {504DA352-6788-4DC0-8705-82167E72A4D3}

View File

@ -8,7 +8,7 @@
<ProjectReference Include="..\..\src\Microsoft.Blazor\Microsoft.Blazor.csproj" />
</ItemGroup>
<!-- Local alternative to <PackageReference Include="Microsoft.Blazor.BuildTools" /> -->
<Import Project="..\..\src\Microsoft.Blazor.BuildTools\ReferenceFromSource.props" />
<!-- Local alternative to <PackageReference Include="Microsoft.Blazor.Build" /> -->
<Import Project="..\..\src\Microsoft.Blazor.Build\ReferenceFromSource.props" />
</Project>

View File

@ -4,7 +4,7 @@
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<!-- Local alternative to <PackageReference Include="Microsoft.Blazor.BuildTools" /> -->
<Import Project="..\..\src\Microsoft.Blazor.BuildTools\ReferenceFromSource.props" />
<!-- Local alternative to <PackageReference Include="Microsoft.Blazor.Build" /> -->
<Import Project="..\..\src\Microsoft.Blazor.Build\ReferenceFromSource.props" />
</Project>

View File

@ -11,7 +11,7 @@
<ProjectReference Include="..\..\src\Microsoft.Blazor\Microsoft.Blazor.csproj" />
</ItemGroup>
<!-- Local alternative to <PackageReference Include="Microsoft.Blazor.BuildTools" /> -->
<Import Project="..\..\src\Microsoft.Blazor.BuildTools\ReferenceFromSource.props" />
<!-- Local alternative to <PackageReference Include="Microsoft.Blazor.Build" /> -->
<Import Project="..\..\src\Microsoft.Blazor.Build\ReferenceFromSource.props" />
</Project>

View File

@ -19,7 +19,10 @@
<ProjectReference Include="..\Microsoft.Blazor.Common\Microsoft.Blazor.Common.csproj" />
</ItemGroup>
<Import Project="..\Microsoft.Blazor.BuildTools\ReferenceFromSource.props" />
<Target Name="EnsureNpmRestored" Condition="!Exists('node_modules')">
<Exec Command="$(BlazorBuildToolsExe) checknodejs -v 8.3.0" />
<Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
<Exec Command="npm install" />
</Target>

1
src/Microsoft.Blazor.Build/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/tools/

View File

@ -1,11 +1,11 @@
// 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 Microsoft.Blazor.BuildTools.Core;
using Microsoft.Blazor.Build.Core;
using Microsoft.Extensions.CommandLineUtils;
using System;
namespace Microsoft.Blazor.BuildTools.Cli.Commands
namespace Microsoft.Blazor.Build.Cli.Commands
{
internal class BuildCommand
{
@ -28,7 +28,7 @@ namespace Microsoft.Blazor.BuildTools.Cli.Commands
try
{
Console.WriteLine($"Building Blazor app from {clientAssemblyPath.Value}...");
Build.Execute(clientAssemblyPath.Value, webRootPath.HasValue() ? webRootPath.Value() : null);
AppBuilder.Execute(clientAssemblyPath.Value, webRootPath.HasValue() ? webRootPath.Value() : null);
return 0;
}
catch (Exception ex)

View File

@ -0,0 +1,32 @@
// 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 Microsoft.Blazor.Build.Cli.Commands;
using Microsoft.Extensions.CommandLineUtils;
namespace Microsoft.Blazor.Build
{
static class Program
{
static int Main(string[] args)
{
var app = new CommandLineApplication
{
Name = "dotnet-blazorbuild"
};
app.HelpOption("-?|-h|--help");
app.Command("build", BuildCommand.Command);
if (args.Length > 0)
{
return app.Execute(args);
}
else
{
app.ShowHelp();
return 0;
}
}
}
}

View File

@ -1,12 +1,12 @@
// 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 Microsoft.Blazor.BuildTools.Core.FileSystem;
using Microsoft.Blazor.Build.Core.FileSystem;
using System.IO;
namespace Microsoft.Blazor.BuildTools.Core
namespace Microsoft.Blazor.Build.Core
{
internal static class Build
internal static class AppBuilder
{
internal static void Execute(string assemblyPath, string webRootPath)
{

View File

@ -6,7 +6,7 @@ using Microsoft.Extensions.FileProviders;
using System.Collections.Generic;
using System.IO;
namespace Microsoft.Blazor.BuildTools.Core.FileSystem
namespace Microsoft.Blazor.Build.Core.FileSystem
{
internal class ClientFileProvider : CompositeMountedFileProvider
{

View File

@ -7,7 +7,7 @@ using Microsoft.Blazor.Mono;
using Microsoft.Extensions.FileProviders;
using System.IO;
namespace Microsoft.Blazor.BuildTools.Core.FileSystem
namespace Microsoft.Blazor.Build.Core.FileSystem
{
internal class FrameworkFileProvider : CompositeMountedFileProvider
{

View File

@ -7,7 +7,7 @@ using System.Linq;
using Mono.Cecil;
using Microsoft.Blazor.Internal.Common.FileProviders;
namespace Microsoft.Blazor.BuildTools.Core.FileSystem
namespace Microsoft.Blazor.Build.Core.FileSystem
{
internal class ReferencedAssemblyFileProvider : InMemoryFileProvider
{

View File

@ -5,7 +5,7 @@ using Microsoft.Extensions.FileProviders;
using System.IO;
using System.Linq;
namespace Microsoft.Blazor.BuildTools.Core.FileSystem
namespace Microsoft.Blazor.Build.Core.FileSystem
{
internal class ReferencedAssemblyResolver
{

View File

@ -8,7 +8,7 @@ using System.Text;
using Microsoft.Extensions.FileProviders;
using System.Linq;
namespace Microsoft.Blazor.BuildTools.Core.FileSystem
namespace Microsoft.Blazor.Build.Core.FileSystem
{
internal class IndexHtmlFileProvider : InMemoryFileProvider
{

View File

@ -4,7 +4,7 @@
using Microsoft.Extensions.FileProviders;
using System.IO;
namespace Microsoft.Blazor.BuildTools.Core
namespace Microsoft.Blazor.Build.Core
{
internal static class FileUtil
{

View File

@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<OutputType>Exe</OutputType>
<OutDir>tools</OutDir>
<NoPackageAnalysis>true</NoPackageAnalysis>
<NuspecFile>Microsoft.Blazor.BuildTools.nuspec</NuspecFile>
<PackageVersion>0.0.1</PackageVersion>
<NuspecProperties>version=$(PackageVersion)</NuspecProperties>
</PropertyGroup>
<ItemGroup>
<None Remove="tools\**" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.Blazor.Browser\Microsoft.Blazor.Browser.csproj" />
<ProjectReference Include="..\Microsoft.Blazor.Mono\Microsoft.Blazor.Mono.csproj" />
<PackageReference Include="Microsoft.Extensions.CommandLineUtils" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Composite" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Physical" Version="2.0.0" />
<PackageReference Include="Mono.Cecil" Version="0.10.0-beta7" />
</ItemGroup>
</Project>

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>Microsoft.Blazor.BuildTools</id>
<id>Microsoft.Blazor.Build</id>
<version>$version$</version>
<authors>Microsoft</authors>
<description>Build tools for Blazor applications.</description>
<description>Build mechanism for Blazor applications.</description>
</metadata>
<files>
<file src="_._" target="lib/netstandard1.0/" />

View File

@ -0,0 +1,3 @@
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Microsoft.Blazor.Build.Test")]

View File

@ -0,0 +1,19 @@
<Project>
<!--
Importing this file is equivalent to having:
<PackageDependency Include="Microsoft.Blazor.Build" />
... except it's much more convenient when working in this repo, because it consumes the
Blazor.Build targets/exe directly without needing this project to be packed into a .nupkg.
This is only intended for use by other projects in this repo.
-->
<Import Project="$(MSBuildThisFileDirectory)targets\All.targets" />
<ItemGroup>
<!-- Ensures this project is built before the consuming project, but without
adding a runtime dependency on the .dll (to be equivalent to a <PackageDependency>
given that the packed version of this project wouldn't add a .dll reference) -->
<ProjectReference Include="$(MSBuildThisFileDirectory)Microsoft.Blazor.Build.csproj" ReferenceOutputAssembly="false" PrivateAssets="all" />
</ItemGroup>
</Project>

View File

@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<BlazorBuildToolsExe>dotnet $(MSBuildThisFileDirectory)..\tools\Microsoft.Blazor.BuildTools.dll</BlazorBuildToolsExe>
<BlazorBuildExe>dotnet $(MSBuildThisFileDirectory)..\tools\Microsoft.Blazor.Build.dll</BlazorBuildExe>
</PropertyGroup>
<Target Name="GenerateBlazorMetadataFile" BeforeTargets="GetCopyToOutputDirectoryItems">
@ -22,6 +22,6 @@
<WebRootParam Condition="Exists('$(WebRootPath)')">--webroot $(WebRootPath)</WebRootParam>
</PropertyGroup>
<!-- TODO: Find the correct time to run this (right after assemblies were written) -->
<Exec Command="$(BlazorBuildToolsExe) build $(ProjectDir)$(OutDir)$(AssemblyName).dll $(WebRootParam)" />
<Exec Command="$(BlazorBuildExe) build $(ProjectDir)$(OutDir)$(AssemblyName).dll $(WebRootParam)" />
</Target>
</Project>

View File

@ -17,7 +17,6 @@ namespace Microsoft.Blazor.BuildTools
app.HelpOption("-?|-h|--help");
app.Command("checknodejs", CheckNodeJsInstalledCommand.Command);
app.Command("build", BuildCommand.Command);
if (args.Length > 0)
{

View File

@ -4,10 +4,6 @@
<TargetFramework>netcoreapp2.0</TargetFramework>
<OutputType>Exe</OutputType>
<OutDir>tools</OutDir>
<NoPackageAnalysis>true</NoPackageAnalysis>
<NuspecFile>Microsoft.Blazor.BuildTools.nuspec</NuspecFile>
<PackageVersion>0.0.1</PackageVersion>
<NuspecProperties>version=$(PackageVersion)</NuspecProperties>
</PropertyGroup>
<ItemGroup>
@ -15,12 +11,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.Blazor.Browser\Microsoft.Blazor.Browser.csproj" />
<ProjectReference Include="..\Microsoft.Blazor.Mono\Microsoft.Blazor.Mono.csproj" />
<PackageReference Include="Microsoft.Extensions.CommandLineUtils" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Composite" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Physical" Version="2.0.0" />
<PackageReference Include="Mono.Cecil" Version="0.10.0-beta7" />
</ItemGroup>
</Project>

View File

@ -1,19 +1,11 @@
<Project>
<!--
Importing this file is equivalent to having:
<PackageDependency Include="Microsoft.Blazor.BuildTools" />
... except it's much more convenient when working in this repo, because it consumes the
BuildTools targets/exe directly without needing BuildTools to be packed into a .nupkg.
This is only intended for use by other projects in this repo.
-->
<Import Project="$(MSBuildThisFileDirectory)targets\All.targets" />
<PropertyGroup>
<BlazorBuildToolsExe>dotnet $(MSBuildThisFileDirectory)tools\Microsoft.Blazor.BuildTools.dll</BlazorBuildToolsExe>
</PropertyGroup>
<ItemGroup>
<!-- Ensures BuildTools itself is built before the consuming project, but without
adding a runtime dependency on the .dll (to be equivalent to a <PackageDependency>
given that the packed version of BuildTools wouldn't add a .dll reference) -->
adding a runtime dependency on the .dll -->
<ProjectReference Include="$(MSBuildThisFileDirectory)Microsoft.Blazor.BuildTools.csproj" ReferenceOutputAssembly="false" PrivateAssets="all" />
</ItemGroup>
</Project>

View File

@ -7,7 +7,7 @@ using System.Linq;
using Xunit;
using System;
using AngleSharp.Parser.Html;
using Microsoft.Blazor.BuildTools.Core.FileSystem;
using Microsoft.Blazor.Build.Core.FileSystem;
namespace Microsoft.Blazor.Server.Test
{

View File

@ -15,7 +15,7 @@
<ItemGroup>
<ProjectReference Include="..\..\samples\StandaloneApp\StandaloneApp.csproj" />
<ProjectReference Include="..\..\src\Microsoft.Blazor.BuildTools\Microsoft.Blazor.BuildTools.csproj" />
<ProjectReference Include="..\..\src\Microsoft.Blazor.Build\Microsoft.Blazor.Build.csproj" />
</ItemGroup>
</Project>

View File

@ -1,7 +1,7 @@
// 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 Microsoft.Blazor.BuildTools.Core.FileSystem;
using Microsoft.Blazor.Build.Core.FileSystem;
using Microsoft.Blazor.Mono;
using Mono.Cecil;
using System;