Skip to content

Commit 242e10f

Browse files
committed
Make ampersands work *more* in net9-only blazor-solution template
Fixes #23105 (Note: This isn't a complete fix because there seem to be issues in other parts of the product. They are tracked separately via dotnet/aspnetcore#56765).
1 parent 4f97f92 commit 242e10f

File tree

8 files changed

+699
-0
lines changed

8 files changed

+699
-0
lines changed

src/Templates/src/templates/maui-blazor-solution/.template.config/template.json

Lines changed: 463 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
2+
3+
<PropertyGroup>
4+
<TargetFramework>DOTNET_TFM</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
<NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile>
8+
<StaticWebAssetProjectMode>Default</StaticWebAssetProjectMode>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="MS_COMPONENTS_WEBASSEMBLY_VERSION" />
13+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="8.0.0" Condition="'$(IndividualLocalAuth)' == 'True'" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<ProjectReference Include="..\XmlEncodedAppName.Shared\XmlEncodedAppName.Shared.csproj" />
18+
</ItemGroup>
19+
20+
</Project>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>${DefaultNetCoreTargetFramework}</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<UserSecretsId Condition="'$(IndividualLocalAuth)' == 'True'">aspnet-XmlEncodedAppName-53bc9b9d-9d6a-45d4-8429-2a2761773502</UserSecretsId>
8+
<NoDefaultLaunchSettingsFile Condition="'$(ExcludeLaunchSettings)' == 'True'">True</NoDefaultLaunchSettingsFile>
9+
</PropertyGroup>
10+
11+
<!--#if (IndividualLocalAuth && !UseLocalDB) -->
12+
<ItemGroup>
13+
<None Update="Data\app.db" CopyToOutputDirectory="PreserveNewest" ExcludeFromSingleFile="true" />
14+
</ItemGroup>
15+
16+
<!--#endif -->
17+
<!--#if (UseWebAssembly || IndividualLocalAuth) -->
18+
<ItemGroup>
19+
<ProjectReference Include="..\XmlEncodedAppName.Web.Client\XmlEncodedAppName.Web.Client.csproj" Condition="'$(UseWebAssembly)' == 'True'" />
20+
<ProjectReference Include="..\XmlEncodedAppName.Shared\XmlEncodedAppName.Shared.csproj" Condition="'$(UseWebAssembly)' != 'True'" />
21+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="MS_COMPONENTS_WEBASSEMBLY_SERVER_VERSION" Condition="'$(UseWebAssembly)' == 'True'" />
22+
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="${MicrosoftAspNetCoreDiagnosticsEntityFrameworkCoreVersion}" Condition="'$(IndividualLocalAuth)' == 'True'" />
23+
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="${MicrosoftAspNetCoreIdentityEntityFrameworkCoreVersion}" Condition="'$(IndividualLocalAuth)' == 'True'" />
24+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="${MicrosoftEntityFrameworkCoreSqliteVersion}" Condition="'$(IndividualLocalAuth)' == 'True' AND '$(UseLocalDB)' != 'True'" />
25+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="${MicrosoftEntityFrameworkCoreSqlServerVersion}" Condition="'$(IndividualLocalAuth)' == 'True' AND '$(UseLocalDB)' == 'True'" />
26+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="${MicrosoftEntityFrameworkCoreToolsVersion}" Condition="'$(IndividualLocalAuth)' == 'True'" />
27+
</ItemGroup>
28+
<!--#else -->
29+
<ItemGroup>
30+
<ProjectReference Include="..\XmlEncodedAppName.Shared\XmlEncodedAppName.Shared.csproj" />
31+
</ItemGroup>
32+
<!--#endif -->
33+
34+
</Project>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:MauiApp._1"
5+
xmlns:shared="clr-namespace:MauiApp._1.Shared;assembly=XmlEncodedAppName.Shared"
6+
x:Class="MauiApp._1.MainPage"
7+
BackgroundColor="{DynamicResource PageBackgroundColor}">
8+
9+
<BlazorWebView x:Name="blazorWebView" HostPage="wwwroot/index.html">
10+
<BlazorWebView.RootComponents>
11+
<RootComponent Selector="#app" ComponentType="{x:Type shared:Routes}" />
12+
</BlazorWebView.RootComponents>
13+
</BlazorWebView>
14+
15+
</ContentPage>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Razor">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>DOTNET_TFM-android;DOTNET_TFM-ios;DOTNET_TFM-maccatalyst</TargetFrameworks>
5+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);DOTNET_TFM-windows10.0.19041.0</TargetFrameworks>
6+
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
7+
<!-- <TargetFrameworks>$(TargetFrameworks);DOTNET_TFM-tizen</TargetFrameworks> -->
8+
9+
<!-- Note for MacCatalyst:
10+
The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
11+
When specifying both architectures, use the plural <RuntimeIdentifiers> instead of the singular <RuntimeIdentifier>.
12+
The Mac App Store will NOT accept apps with ONLY maccatalyst-arm64 indicated;
13+
either BOTH runtimes must be indicated or ONLY macatalyst-x64. -->
14+
<!-- For example: <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers> -->
15+
16+
<OutputType>Exe</OutputType>
17+
<RootNamespace>MauiApp._1</RootNamespace>
18+
<UseMaui>true</UseMaui>
19+
<SingleProject>true</SingleProject>
20+
<ImplicitUsings>enable</ImplicitUsings>
21+
<EnableDefaultCssItems>false</EnableDefaultCssItems>
22+
<Nullable>enable</Nullable>
23+
24+
<!-- Display name -->
25+
<ApplicationTitle>XmlEncodedAppName</ApplicationTitle>
26+
27+
<!-- App Identifier -->
28+
<ApplicationId>com.companyname.mauiapp</ApplicationId>
29+
30+
<!-- Versions -->
31+
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
32+
<ApplicationVersion>1</ApplicationVersion>
33+
34+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion>
35+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">15.0</SupportedOSPlatformVersion>
36+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">24.0</SupportedOSPlatformVersion>
37+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
38+
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
39+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
40+
</PropertyGroup>
41+
42+
<ItemGroup>
43+
<!-- App Icon -->
44+
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
45+
46+
<!-- Splash Screen -->
47+
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
48+
49+
<!-- Images -->
50+
<MauiImage Include="Resources\Images\*" />
51+
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />
52+
53+
<!-- Custom Fonts -->
54+
<MauiFont Include="Resources\Fonts\*" />
55+
56+
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
57+
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
58+
</ItemGroup>
59+
60+
<ItemGroup>
61+
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
62+
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="$(MauiVersion)" />
63+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="MS_EXT_LOG_DEBUG_VERSION" />
64+
</ItemGroup>
65+
66+
<ItemGroup>
67+
<ProjectReference Include="..\XmlEncodedAppName.Shared\XmlEncodedAppName.Shared.csproj" />
68+
</ItemGroup>
69+
70+
</Project>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest package="maui-application-id-placeholder" version="0.0.0" api-version="8" xmlns="http://tizen.org/ns/packages">
3+
<profile name="common" />
4+
<ui-application appid="maui-application-id-placeholder" exec="XmlEncodedAppName.dll" multiple="false" nodisplay="false" taskmanage="true" type="dotnet" launch_mode="single">
5+
<label>maui-application-title-placeholder</label>
6+
<icon>maui-appicon-placeholder</icon>
7+
<metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />
8+
</ui-application>
9+
<shortcut-list />
10+
<privileges>
11+
<privilege>http://tizen.org/privilege/internet</privilege>
12+
</privileges>
13+
<dependencies />
14+
<provides-appdefined-privileges />
15+
</manifest>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
3+
<assemblyIdentity version="1.0.0.0" name="XmlEncodedAppName.WinUI.app"/>
4+
5+
<application xmlns="urn:schemas-microsoft-com:asm.v3">
6+
<windowsSettings>
7+
<!-- The combination of below two tags have the following effect:
8+
1) Per-Monitor for >= Windows 10 Anniversary Update
9+
2) System < Windows 10 Anniversary Update
10+
-->
11+
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>
12+
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
13+
</windowsSettings>
14+
</application>
15+
</assembly>

src/TestUtils/src/Microsoft.Maui.IntegrationTests/TemplateTests.cs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,73 @@ public void Build(string id, string framework, string config, bool shouldPack)
4949
}
5050

5151
[Test]
52+
<<<<<<< Updated upstream
53+
=======
54+
// Parameters: target framework, build config, dotnet new additional parameters
55+
56+
// First, 4 default scenarios
57+
[TestCase(DotNetCurrent, "Debug", "")]
58+
[TestCase(DotNetCurrent, "Release", "")]
59+
[TestCase(DotNetCurrent, "Debug", "")]
60+
[TestCase(DotNetCurrent, "Release", "")]
61+
62+
// Then, scenarios with additional template parameters:
63+
// - Interactivity Location: None/WASM/Server/Auto
64+
// - Empty vs. With Sample Content
65+
// - ProgramMain vs. TopLevel statements
66+
// And alternately testing other options for a healthy mix.
67+
[TestCase(DotNetCurrent, "Debug", "-I None --Empty")]
68+
[TestCase(DotNetCurrent, "Release", "-I WebAssembly --Empty")]
69+
[TestCase(DotNetCurrent, "Debug", "-I Server --Empty")]
70+
[TestCase(DotNetCurrent, "Release", "-I Auto --Empty")]
71+
[TestCase(DotNetCurrent, "Debug", "-I None")]
72+
[TestCase(DotNetCurrent, "Release", "-I WebAssembly")]
73+
[TestCase(DotNetCurrent, "Debug", "-I Server")]
74+
[TestCase(DotNetCurrent, "Release", "-I Auto")]
75+
[TestCase(DotNetCurrent, "Debug", "-I None --Empty --UseProgramMain")]
76+
[TestCase(DotNetCurrent, "Release", "-I WebAssembly --Empty --UseProgramMain")]
77+
[TestCase(DotNetCurrent, "Debug", "-I Server --Empty --UseProgramMain")]
78+
[TestCase(DotNetCurrent, "Release", "-I Auto --Empty --UseProgramMain")]
79+
[TestCase(DotNetCurrent, "Debug", "-I None --UseProgramMain")]
80+
[TestCase(DotNetCurrent, "Release", "-I WebAssembly --UseProgramMain")]
81+
[TestCase(DotNetCurrent, "Debug", "-I Server --UseProgramMain")]
82+
[TestCase(DotNetCurrent, "Release", "-I Auto --UseProgramMain")]
83+
public void BuildMauiBlazorWebSolution(string framework, string config, string additionalDotNetNewParams)
84+
{
85+
const string templateShortName = "maui-blazor-web";
86+
87+
var solutionProjectDir = TestDirectory + " & More";
88+
89+
var webAppProjectDir = Path.Combine(solutionProjectDir, Path.GetFileName(solutionProjectDir) + ".Web");
90+
var webAppProjectFile = Path.Combine(webAppProjectDir, $"{Path.GetFileName(webAppProjectDir)}.csproj");
91+
92+
var mauiAppProjectDir = Path.Combine(solutionProjectDir, Path.GetFileName(solutionProjectDir));
93+
var mauiAppProjectFile = Path.Combine(mauiAppProjectDir, $"{Path.GetFileName(mauiAppProjectDir)}.csproj");
94+
95+
TestContext.WriteLine($"Creating project in {solutionProjectDir}");
96+
97+
Assert.IsTrue(DotnetInternal.New(templateShortName, outputDirectory: solutionProjectDir, framework: framework, additionalDotNetNewParams: additionalDotNetNewParams),
98+
$"Unable to create template {templateShortName}. Check test output for errors.");
99+
100+
TestContext.WriteLine($"Solution directory: {solutionProjectDir} (exists? {Directory.Exists(solutionProjectDir)})");
101+
TestContext.WriteLine($"Blazor Web app project directory: {webAppProjectDir} (exists? {Directory.Exists(webAppProjectDir)})");
102+
TestContext.WriteLine($"Blazor Web app project file: {webAppProjectFile} (exists? {File.Exists(webAppProjectFile)})");
103+
TestContext.WriteLine($"MAUI app project directory: {mauiAppProjectDir} (exists? {Directory.Exists(mauiAppProjectDir)})");
104+
TestContext.WriteLine($"MAUI app project file: {mauiAppProjectFile} (exists? {File.Exists(mauiAppProjectFile)})");
105+
106+
EnableTizen(mauiAppProjectFile);
107+
108+
TestContext.WriteLine($"Building Blazor Web app: {webAppProjectFile}");
109+
Assert.IsTrue(DotnetInternal.Build(webAppProjectFile, config, target: "", properties: BuildProps, msbuildWarningsAsErrors: true),
110+
$"Project {Path.GetFileName(webAppProjectFile)} failed to build. Check test output/attachments for errors.");
111+
112+
TestContext.WriteLine($"Building .NET MAUI app: {mauiAppProjectFile}");
113+
Assert.IsTrue(DotnetInternal.Build(mauiAppProjectFile, config, target: "", properties: BuildProps, msbuildWarningsAsErrors: true),
114+
$"Project {Path.GetFileName(mauiAppProjectFile)} failed to build. Check test output/attachments for errors.");
115+
}
116+
117+
[Test]
118+
>>>>>>> Stashed changes
52119
[TestCase("Debug", "simplemulti")]
53120
[TestCase("Release", "simplemulti")]
54121
[TestCase("Debug", "MultiProject@Symbol & More")]

0 commit comments

Comments
 (0)