Added the blogpost: "Introducing .NET MAUI – One Codebase, Many Platforms" (https://devblogs.microsoft.com/dotnet/introducing-dotnet-maui-one-codebase-many-platforms/) to the readme under "Current News".
If this would be better for an official team member to do, please go ahead : ). I just noticed that the readme was slightly out of date and wanted to fix/bring attention to it.
Thank you
For Maui's "single project" concept, we need a new item group for raw
files:
<MauiAsset Include="Raw\index.html" />
This would do the following for each platform:
* Android - add an `@(AndroidAsset)` to the `.apk`
* iOS/MacCatalyst - add a `@(Content)` to the `.app`/`.ipa`
* WinUI - add a `@(Content)` to the `Assets/` folder
To test this, I added an `index.html` file to
`Maui.Controls.Sample.SingleProject.csproj` and used it via:
<WebView Source="index.html" />
The only issue is on Android we need to load
`file:///android_asset/index.html`. I modified the Android
`WebViewRenderer` to do:
if (!url.StartsWith('/') && !Uri.IsWellFormedUriString(url, UriKind.Absolute))
{
url = AssetBaseUrl + url;
}
So for the following examples:
* `index.html` -> `file:///android_asset/index.html`
* `./index.html` -> `file:///android_asset/./index.html`
* `https://google.com` -> no change
* `/some/full/path/on/disk/index.html` -> no change, this is why we
need the explicit `/` check.
I think this is improved `WebView` behavior, in general.
Down the road, we could make a helper API that can either return a
`System.Uri` or a `System.IO.Stream` in C# for all platforms.
Other changes:
* Updated `README.md` files that described a workaround for
`--no-restore` that is no longer needed.
* `Maui.Controls.Sample.SingleProject.csproj` now actually uses `.svg`
files for its app icons.
* `Maui.Controls.Sample.SingleProject.csproj` uses `.xaml` now.
Co-authored-by: Jonathan Dick <jondick@gmail.com>
Based on: https://github.com/jonathanpeppers/maui-workload
This adds a new `DotNet.csproj` that provisions a local .NET 6 install
into `.\bin\dotnet\`.
Next, it uses versions defined in `eng/Versions.props` as required by
.NET version bumping infrastructure (called Darc):
<Project>
<PropertyGroup>
<MicrosoftNETSdkPackageVersion>6.0.100-preview.2.21155.3</MicrosoftNETSdkPackageVersion>
<MicrosoftAndroidSdkPackageVersion>11.0.200-ci.main.148</MicrosoftAndroidSdkPackageVersion>
<MicrosoftMacCatalystSdkPackageVersion>14.3.100-ci.main.337</MicrosoftMacCatalystSdkPackageVersion>
<MicrosoftiOSSdkPackageVersion>14.4.100-ci.main.1192</MicrosoftiOSSdkPackageVersion>
</PropertyGroup>
</Project>
Next, we can use these versions to consume NuGet packages for workloads:
<PackageDownload Include="Microsoft.NET.Workload.Android" Version="[$(MicrosoftAndroidSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.NET.Workload.MacCatalyst" Version="[$(MicrosoftMacCatalystSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.NET.Workload.iOS" Version="[$(MicrosoftiOSSdkPackageVersion)]" />
Then the other packs they depend on:
<PackageDownload Include="Microsoft.Android.Ref" Version="[$(MicrosoftAndroidSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.Android.Sdk.win-x64" Version="[$(MicrosoftAndroidSdkPackageVersion)]" Condition="$([MSBuild]::IsOSPlatform('windows'))" />
<PackageDownload Include="Microsoft.Android.Sdk.osx-x64" Version="[$(MicrosoftAndroidSdkPackageVersion)]" Condition="$([MSBuild]::IsOSPlatform('osx'))" />
<PackageDownload Include="Microsoft.Android.Sdk.BundleTool" Version="[$(MicrosoftAndroidSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.MacCatalyst.Ref" Version="[$(MicrosoftMacCatalystSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.MacCatalyst.Sdk" Version="[$(MicrosoftMacCatalystSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.iOS.Ref" Version="[$(MicrosoftiOSSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.iOS.Sdk" Version="[$(MicrosoftiOSSdkPackageVersion)]" />
After doing this, I can build .NET 6 projects with:
> .\bin\dotnet\dotnet.exe build .\src\Controls\samples\Controls.Sample.SingleProject\Maui.Controls.Sample.SingleProject.csproj
I can even build MacCatalyst apps on Windows!
I updated `build.cake` so the following builds for .NET 6 and opens
Visual Studio:
> dotnet cake --target=VS-NET6
This is the equivalent of these commands if you want to run them
individually:
dotnet build src\DotNet\DotNet.csproj
.\bin\dotnet\dotnet build Microsoft.Maui.BuildTasks-net6.sln
.\bin\dotnet\dotnet build Microsoft.Maui-net6.sln
.\eng\dogfood.ps1
~~ Other Changes ~~
* Rework CI setup to use .\bin\dotnet\dotnet
* We don't need boots or URLs anymore
* Fixed `MSBuildTests` to use .\bin\dotnet\dotnet if found and fall
back to the system `dotnet`
* Moved `.nuspec\package.ps1` to `eng\package.ps1`
~~ What problems does this solve? ~~
* MacCatalyst builds on Windows! (offline build that checks C#)
* Building Maui always gets you the right things installed.
* Maui becoming a .NET workload will be a breeze. We can copy files
into `.\bin\dotnet\sdk-manifests` and `.\bin\dotnet\packs`.
* We can use Darc to bump dependencies within .NET:
https://github.com/dotnet/arcade/blob/main/Documentation/Darc.md