我从头开始创建了一个新的 Multitargetproject,现在我还可以包含 Xaml 文件。我唯一的问题是,当我添加例如 Test.shared.xaml 或 Test.shared.cs 时,我必须转到项目文件并删除以下生成的行:
<Project Sdk="MSBuild.Sdk.Extras">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp2.0;net461;MonoAndroid90;Xamarin.iOS10</TargetFrameworks>
<Product>$(AssemblyName) ($(TargetFramework))</Product>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<AssemblyFileVersion>1.0.0.0</AssemblyFileVersion>
<Version>1.0.0.0</Version>
<PackageVersion>1.0.0.0</PackageVersion>
<PackOnBuild>true</PackOnBuild>
<NeutralLanguage>en</NeutralLanguage>
<LangVersion>default</LangVersion>
<DefineConstants>$(DefineConstants);</DefineConstants>
<UseFullSemVerForNuGet>false</UseFullSemVerForNuGet>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)'=='Debug' ">
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)'=='Release' ">
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<DebugType>pdbonly</DebugType>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<Compile Include="**\*.shared.cs" />
<Compile Include="**\*.shared.xaml.cs" />
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('netstandard')) ">
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('MonoAndroid')) ">
<Compile Include="**\*.android.cs" />
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('Xamarin.iOS')) ">
<Compile Include="**\*.apple.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="4.3.0.819712-pre2" />
<PackageReference Include="Xamarin.Forms.PancakeView" Version="1.2.1" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'MonoAndroid90'">
<PackageReference Include="Plugin.CurrentActivity">
<Version>2.1.0.4</Version>
</PackageReference>
</ItemGroup>
</Project>
还有应该位于项目根目录中的 global.json
"sdk": {
"version": "3.0.100-preview"
},
"msbuild-sdks": {
"MSBuild.Sdk.Extras": "2.0.46"
}
}