Create
Put your app together.
Choose a frontend, package manager, Window host, and ViewModel library.
The command below creates exactly this project. It makes the same choices dnx Runic.Create asks for in your terminal.
SDK 0.7.0-preview.5
Your command
dnx Runic.Create@0.7.0-preview.5 -- MyApp --frontend react --package-manager npm --host cswebui --view-models toolkit dnx runs the creator without installing it. It
installs Runic.Application.Templates and runs dotnet new runic-app, then prints these commands
again. Run dnx Runic.Create@0.7.0-preview.5 to answer the questions
in your terminal instead.
Then run it
cd MyApp
dotnet tool restore
dotnet runic dev Preview
Selected files from the template, rendered for your choices.
using CsWebUi;
using Microsoft.Extensions.DependencyInjection;
using Runic.Application.Views.CsWebUi;
using MyApp;
var services = new ServiceCollection();
services.AddScoped<WorkspaceViewModel>();
services.AddScoped<WelcomeViewModel>();
services.AddScoped<CounterViewModel>();
services.AddRunicViews();
using var provider = services.BuildServiceProvider(new ServiceProviderOptions
{
ValidateScopes = true,
ValidateOnBuild = true
});
// The window releases asynchronously, before WebUI cleans up its native state.
await using (var window = provider.OpenWindow<WorkspaceWindow, WorkspaceViewModel>(host => new WorkspaceWindow(host)))
{
window.SetRootFolder(Path.Combine(AppContext.BaseDirectory, "www"));
window.Show("index.html");
WebUiApplication.Wait();
}
WebUiApplication.Clean();
New to the Window and View model? Read Window and View or the getting-started guide.