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

mauihybrid solution with all plataforms even without maui #12

Closed
cesarchefinho opened this issue Oct 28, 2023 · 4 comments · Fixed by #15
Closed

mauihybrid solution with all plataforms even without maui #12

cesarchefinho opened this issue Oct 28, 2023 · 4 comments · Fixed by #15

Comments

@cesarchefinho
Copy link

Could someone please post the instructions so that a solution with Avalonia Maui Hybrid has Windows and browser projects without Maui Hybrid (use Maui would have to be conditional in the main project, for example) etc etc.

This would allow where Maui is not supported the programmer to create their own solutions.

Thank you very much in advance

@maxkatz6
Copy link
Member

You have to create separate projects for Windows and browser projects. It's simply a limitation of the SDK.
In .NET 8 it's going to be possible though, but also out of the scope of anything MAUI related. We do have plans to have some single-project support for simple apps.

@cesarchefinho
Copy link
Author

You have to create separate projects for Windows and browser projects. It's simply a limitation of the SDK. In .NET 8 it's going to be possible though, but also out of the scope of anything MAUI related. We do have plans to have some single-project support for simple apps.

I dont want an sigle project solution.

I want an solution like avalonia does today, with one project in net7 and other projects one per plataform, but with conditional to use maui hibrid only in android and ios projects and conditional for mai project to only use maui wen target is android and ios but not for windows or browser.

@CastelloBrancoTecnologia
Copy link
Contributor

CastelloBrancoTecnologia commented Jan 5, 2024

You have to create separate projects for Windows and browser projects. It's simply a limitation of the SDK. In .NET 8 it's going to be possible though, but also out of the scope of anything MAUI related. We do have plans to have some single-project support for simple apps.

This worked for me without any other solutions or projects

change shared project and add these sections with conditions to use maui only if target is IOS or android

`

< PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android' or $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'" >
	< UseMaui >true< /UseMaui >
	< UseMauiEssentials >true< /UseMauiEssentials >
	< SkipValidateMauiImplicitPackageReferences >true< /SkipValidateMauiImplicitPackageReferences >
< /PropertyGroup >

< ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android' or $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'"  >
	< PackageReference Include="Avalonia.Maui" Version="11.0.5" / >
	< PackageReference Include="Microsoft.Maui.Controls" Version="8.0.3" / >
</ItemGroup>

`
in windows or other platforms projects dont use any maui things, make your api similar to maui essentials yourself.

@CastelloBrancoTecnologia
Copy link
Contributor

THIS WORKED LIKE A SHARM !!!!!!

with this shared project csproject file you also have Browser project compiling in avalonia maui hybrid solution

also note that we are using nuget.config with avalonia nightly builds (see avalonia docs) to get avalonia 11.0.999
because avalonia 11.0.6 are getins java erros in android and net6 referencies that dont exist in net8-android

and in browser we are using avalonia 11.0.6 with browser target, because avalonia nightly are geting erros in browser project...

` 
                      
 < Project Sdk="Microsoft.NET.Sdk"  >  
	< PropertyGroup >
		< TargetFramework > net8.0 < /TargetFramework  >
		< Nullable > enable < /Nullable >
		< LangVersion > latest < /LangVersion >
		< AvaloniaUseCompiledBindingsByDefault > true < /AvaloniaUseCompiledBindingsByDefault >
	<  /PropertyGroup  > 

	< Choose > 
		< When Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android' or $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'" >
			< PropertyGroup  > 
				< UseMaui >true</UseMaui >
				< UseMauiEssentials >true< /UseMauiEssentials >
				< SkipValidateMauiImplicitPackageReferences  >true <  /SkipValidateMauiImplicitPackageReferences >
			< /PropertyGroup >

			< ItemGroup >
				< PackageReference Include="Avalonia" Version="11.0.999" / >
				 < PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.999" / >
				< PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.999" / >

				< PackageReference Include="Avalonia.Maui" Version="11.0.5" / >
				< PackageReference Include="Microsoft.Maui.Controls" Version="8.0.3" / >

				< !  -- Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration. -- >
				< PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.999" / >
			< /ItemGroup >
		< /When >
		< Otherwise >
			< ItemGroup >
				< PackageReference Include="Avalonia" Version="11.0.6" / >
				< PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.6" / >
				< PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.6" / >

				< ! -- Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration. --  > 
				< PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.6" /  >
			< /ItemGroup > 
		< /Otherwise > 
	< /Choose > 
	
	< ItemGroup > 
		< AvaloniaResource Include="Assets\**" / > 
	< /ItemGroup > 

	< ItemGroup > 
		< PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" / > 
	< /ItemGroup >
 < /Project >





`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants