Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,33 @@
"$schema": "http://json.schemastore.org/template",
"author": "Microsoft",
"classifications": [ "Web", "WebAssembly", "Browser" ],
"identity": "WebAssembly.Browser",
"generatorVersions": "[1.0.0.0-*)",
"groupIdentity": "WebAssembly.Browser",
"precedence": 7000,
"identity": "WebAssembly.Browser.7.0",
"description": "WebAssembly Browser App",
"name": "WebAssembly Browser App",
"shortName": "wasmbrowser",
"sourceName": "browser.0",
"preferNameDirectory": true,
"tags": {
"language": "C#",
"type": "project"
},
"symbols": {
"framework": {
"type": "parameter",
"description": "The target framework for the project.",
"datatype": "choice",
"choices": [
{
"choice": "net7.0",
"description": "Target net7.0",
"displayName": ".NET 7.0"
}
],
"defaultValue": "net7.0",
"displayName": "framework"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,32 @@
"$schema": "http://json.schemastore.org/template",
"author": "Microsoft",
"classifications": [ "Web", "WebAssembly", "Console" ],
"identity": "WebAssembly.Console",
"groupIdentity": "WebAssembly.Console",
"precedence": 7000,
"identity": "WebAssembly.Console.7.0",
"description": "WebAssembly Console App",
"name": "WebAssembly Console App",
"shortName": "wasmconsole",
"sourceName": "console.0",
"preferNameDirectory": true,
"tags": {
"language": "C#",
"type": "project"
},
"symbols": {
"framework": {
"type": "parameter",
"description": "The target framework for the project.",
"datatype": "choice",
"choices": [
{
"choice": "net7.0",
"description": "Target net7.0",
"displayName": ".NET 7.0"
}
],
"defaultValue": "net7.0",
"displayName": "framework"
}
}
}
4 changes: 2 additions & 2 deletions src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ private static string GetNuGetConfigWithLocalPackagesPath(string templatePath, s
return contents.Replace(s_nugetInsertionTag, $@"<add key=""nuget-local"" value=""{localNuGetsPath}"" />");
}

public string CreateWasmTemplateProject(string id, string template = "wasmbrowser")
public string CreateWasmTemplateProject(string id, string template = "wasmbrowser", string extraArgs = "")
{
InitPaths(id);
InitProjectDir(id);
Expand All @@ -459,7 +459,7 @@ public string CreateWasmTemplateProject(string id, string template = "wasmbrowse

new DotNetCommand(s_buildEnv, _testOutput, useDefaultArgs: false)
.WithWorkingDirectory(_projectDir!)
.ExecuteWithCapturedOutput($"new {template}")
.ExecuteWithCapturedOutput($"new {template} {extraArgs}")
.EnsureSuccessful();

return Path.Combine(_projectDir!, $"{id}.csproj");
Expand Down
20 changes: 15 additions & 5 deletions src/tests/BuildWasmApps/Wasm.Build.Tests/WasmTemplateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,18 @@ public void ConsoleBuildThenPublish(string config)
[InlineData("Debug", true)]
[InlineData("Release", false)]
[InlineData("Release", true)]
public void ConsoleBuildAndRun(string config, bool relinking)
public void ConsoleBuildAndRunDefault(string config, bool relinking)
=> ConsoleBuildAndRun(config, relinking, string.Empty);

[ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))]
[InlineData("Debug", "-f net7.0")]
public void ConsoleBuildAndRunForSpecificTFM(string config, string extraNewArgs)
=> ConsoleBuildAndRun(config, false, extraNewArgs);

private void ConsoleBuildAndRun(string config, bool relinking, string extraNewArgs)
{
string id = $"{config}_{Path.GetRandomFileName()}";
string projectFile = CreateWasmTemplateProject(id, "wasmconsole");
string projectFile = CreateWasmTemplateProject(id, "wasmconsole", extraNewArgs);
string projectName = Path.GetFileNameWithoutExtension(projectFile);

UpdateProgramCS();
Expand Down Expand Up @@ -432,12 +440,14 @@ public async Task BlazorRunTest()
Assert.Equal("Current count: 1", txt);
}

[ConditionalFact(typeof(BuildTestBase), nameof(IsUsingWorkloads))]
public async Task BrowserTest()
[ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))]
[InlineData("")]
[InlineData("-f net7.0")]
public async Task BrowserBuildAndRun(string extraNewArgs)
{
string config = "Debug";
string id = $"browser_{config}_{Path.GetRandomFileName()}";
CreateWasmTemplateProject(id, "wasmbrowser");
CreateWasmTemplateProject(id, "wasmbrowser", extraNewArgs);

// var buildArgs = new BuildArgs(projectName, config, false, id, null);
// buildArgs = ExpandBuildArgs(buildArgs);
Expand Down