Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .NET MAUI Blazor Hybrid + Web App solution template #21867

Closed
wants to merge 19 commits into from

Conversation

Eilon
Copy link
Member

@Eilon Eilon commented Apr 16, 2024

Description of Change

This adds a new template to dotnet new and in Visual Studio that creates a solution with .NET MAUI Blazor Hybrid app with a Blazor Web app, which share common code in a Razor Class Library project.

Here's what you'll see from the command line:

image

And from VS you get this template:

image

With these options:

image

And here's what the rough layout of files looks like:

image

And when you run the apps they look the same (because all the UI components are shared) - and include additional sample code for an IFormFactor interface to show how to write platform-specific services:

image

Most of the options from the Blazor Web project template are also available in this new template.

Issues Fixed

Fixes #1069

@Eilon Eilon added area-blazor Blazor Hybrid / Desktop, BlazorWebView do-not-merge Don't merge this PR labels Apr 16, 2024
@Eilon Eilon removed the do-not-merge Don't merge this PR label Apr 20, 2024
@Eilon Eilon marked this pull request as ready for review April 20, 2024 00:16
@Eilon Eilon requested a review from a team as a code owner April 20, 2024 00:16
@Eilon Eilon requested review from jfversluis and tj-devel709 April 20, 2024 00:16
@Eilon Eilon changed the title WIP: Add .NET MAUI Blazor Hybrid + Web App solution template Add .NET MAUI Blazor Hybrid + Web App solution template Apr 20, 2024
@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Eilon Eilon requested a review from javiercn April 22, 2024 21:17
@Eilon
Copy link
Member Author

Eilon commented Apr 22, 2024

To see the output of each template variation, check out this repo: https://github.com/Eilon/MauiBlazorWebSolution/tree/sample-code

It includes every combination of:

  1. Interactivity Location: None/WASM/Server/Auto
  2. Empty vs. With Sample Content
  3. ProgramMain vs. TopLevel statements

So navigate to the appropriate sub-folder, and see what you'd get with this template.

To view it in the form of a PR (for easier commenting), go to Eilon/MauiBlazorWebSolution#1

cc @javiercn

@Eilon
Copy link
Member Author

Eilon commented Apr 22, 2024

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@@ -15,7 +16,7 @@ public class BaseBuildTest
public const string MauiVersionCurrent = "8.0.0-rc.1.9171"; // this should not be the same as the last release
public const string MauiVersionPrevious = "7.0.86"; // this should not be the same version as the default. aka: MicrosoftMauiPreviousDotNetReleasedVersion in eng/Versions.props

char[] invalidChars = { '{', '}', '(', ')', '$', ':', ';', '\"', '\'', ',', '=', '.', '-', };
char[] invalidChars = { '{', '}', '(', ')', '$', ':', ';', '\"', '\'', ',', '=', '.', '-', ' ', };
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was to work around a bug that I need to investigate further. Once I know more I will file a bug about spaces in certain paths. The bug is unrelated to this change, but this change runs into the bug and causes tests to fail.

if (result.Length > 20)
{
// If the test name is too long, hash it to avoid path length issues
result = result.Substring(0, 15) + Convert.ToString(Math.Abs(string.GetHashCode(result.AsSpan(), StringComparison.Ordinal)), CultureInfo.InvariantCulture);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to work around Windows max_path. Some of the new template tests have extremely long names due to the pattern of using the test name + every parameter as part of the test folder name. This change makes long paths significantly shorter by hashing part of it.

Eilon added 3 commits April 30, 2024 11:12
Fix '-' in project names causing invalid projects
Add Error.razor to web project
Empty projects shouldn't link to Bootstrap
@Eilon
Copy link
Member Author

Eilon commented May 6, 2024

Closing this PR. Use #22234.

@Eilon Eilon closed this May 6, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jun 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add WebSite project type to MAUI Hybrid project type (Blazor Hybrid + Web)
2 participants