Visual Studio 2026 - プロジェクト - MAUI いらない


 クラウディア


1. 概要
2. 対象プラットフォームを絞る
3. 参考サイト

1. 概要

 「Visual Studio 2026」で「C#」のクラスライブラリを作成すると、「.NET MAUI (Multi-platform App UI)」通称「MAUI」が作成されます。  「iOS」「Mac OS」「Android」「Windows」に対応しているらしいのですが。  プラットフォームとして「Windows」しか、対象にしていないのであれば、他は、逆に目障りになります。

2. 対象プラットフォームを絞る

 対象プラットフォームを絞るには、対象のプロジェクトの「.csproj」を開いて。

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
  	<TargetFrameworks>net10.0-android</TargetFrameworks>
  	<TargetFrameworks Condition="!$([MSBuild]::IsOSPlatform('linux'))">
  		$(TargetFrameworks);net10.0-ios;net10.0-maccatalyst</TargetFrameworks>
  	<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">
  		$(TargetFrameworks);net10.0-windows10.0.19041.0</TargetFrameworks>

  	<UseMaui-->true</UseMaui>
  	<SingleProject>true</SingleProject>
  	<ImplicitUsings>enable</ImplicitUsings>
  	<Nullable>enable</Nullable>

  	<!-- Enable XAML source generation for faster build times and improved performance.
  			This generates C# code from XAML at compile time instead of runtime inflation.
  			To disable, remove this line.
  			For individual files, you can override by setting Inflator metadata:
  			<MauiXaml Update="MyPage.xaml" Inflator="Default" /> (reverts to defaults: Runtime for Debug, XamlC for Release)
  			<MauiXaml Update="MyPage.xaml" Inflator="Runtime" /> (force runtime inflation) -->
  	<MauiXamlInflator>SourceGen</MauiXamlInflator>

  	<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">
			15.0</SupportedOSPlatformVersion>
  	<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">
			15.0</SupportedOSPlatformVersion>
  	<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
			21.0</SupportedOSPlatformVersion>
  	<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">
			10.0.17763.0</SupportedOSPlatformVersion>
  	<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">
			10.0.17763.0</TargetPlatformMinVersion>
  	<TargetFramework>net10.0-windows</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
  	<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
  </ItemGroup>
</Project>
 から、いらない「<TargetFrameworks>」「<SupportedOSPlatformVersion ...>」「<PackageReference ...>」の行を削除します。

3. 参考サイト

 本ページは、「ChatGPT」軍曹を参考にさせていただきました。

audiobook.jp
薬屋の独り言
JETBOY
健康サポート特集
アフィリエイトのアクセストレード
Amazonギフトカード
損保との違い
earthcar(アースカー)
サウンドハウス
葬送のフリーレン Prime Video
ハイスピードプラン
ベルリッツ
それがだいじWi-Fi
EaseUS
【usus ウズウズ】
TikTok Shop 【リピート用プログラム】
5G CONNECT
U-NEXT
ネットオークションの相場、統計、価格比較といえばオークファン