diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dce44f287..cac07ec4e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,3 +17,6 @@ jobs: - name: Build and check run: dotnet run --project ./build -- check + + - name: Publish Blazor example + run: dotnet run --project ./build -- publish diff --git a/.gitignore b/.gitignore index b6ba230ca..b7028c6a3 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ benchmarks/data/results/*.md _ReSharper.Caches/ .idea .logs +wwwroot diff --git a/.run/Publish Blazor example.run.xml b/.run/Publish Blazor example.run.xml new file mode 100644 index 000000000..a10e319e5 --- /dev/null +++ b/.run/Publish Blazor example.run.xml @@ -0,0 +1,20 @@ + + + + \ No newline at end of file diff --git a/build/Program.cs b/build/Program.cs index e37959403..45dc9e32c 100644 --- a/build/Program.cs +++ b/build/Program.cs @@ -2,20 +2,24 @@ DI.Setup(nameof(Composition)) .Root("RootTarget") + .DefaultLifetime(Lifetime.PerBlock) - .Bind().To() - .Bind().To() + + .Bind().To() + .Bind().To() .Bind().To(_ => GetService()) - .Bind().To(_ => GetService()) + .Bind().To(_ => GetService()) + // Targets - .Bind>(typeof(GeneratorTarget)).To() - .Bind>>(typeof(LibrariesTarget)).To() - .Bind>>(typeof(CompatibilityCheckTarget)).To() - .Bind>>(typeof(PackTarget)).To() - .Bind(typeof(ReadmeTarget)).To() - .Bind>(typeof(BenchmarksTarget)).To() - .Bind(typeof(DeployTarget)).To() - .Bind(typeof(TemplateTarget)).To() - .Bind(typeof(UpdateTarget)).To(); + .Bind(Tag.Type).To() + .Bind(Tag.Type).To() + .Bind(Tag.Type).To() + .Bind(Tag.Type).To() + .Bind(Tag.Type).To() + .Bind(Tag.Type).To() + .Bind(Tag.Type).To() + .Bind(Tag.Type).To() + .Bind(Tag.Type).To() + .Bind(Tag.Type).To(); return await new Composition().RootTarget.RunAsync(CancellationToken.None); \ No newline at end of file diff --git a/build/PublishBlazorTarget.cs b/build/PublishBlazorTarget.cs new file mode 100644 index 000000000..ca7cf0344 --- /dev/null +++ b/build/PublishBlazorTarget.cs @@ -0,0 +1,31 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable HeapView.DelegateAllocation +// ReSharper disable HeapView.ClosureAllocation +// ReSharper disable ClassNeverInstantiated.Global +// ReSharper disable ReturnTypeCanBeEnumerable.Local +// ReSharper disable InvertIf + +namespace Build; + +internal class PublishBlazorTarget( + Commands commands) + : IInitializable, ITarget +{ + public Task InitializeAsync() => commands.Register( + this, + "Publish balazor web sssembly example", + "publish", + "pb"); + + [SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] + public async Task RunAsync(CancellationToken cancellationToken) + { + var result = await new DotNetPublish() + .WithProject(Path.Combine("samples", "BlazorWebAssemblyApp", "BlazorWebAssemblyApp.csproj")) + .WithConfiguration("Release") + .WithOutput("wwwroot") + .RunAsync(cancellationToken: cancellationToken); + + return result ?? 1; + } +} \ No newline at end of file