我正在使用一个Xamanimation依赖于Xamarin.Forms 4.1.0(写在其nuspec文件中)的包:
<dependencies>
<group targetFramework=".NETStandard2.0">
<dependency id="Xamarin.Forms" version="4.1.0.581479" exclude="Build,Analyzers" />
</group>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
但我已经为自己构建了 Xamarin.Froms 并将输出 dll 文件添加到我的项目参考中:
<Reference Include="Xamarin.Forms.Xaml">
<HintPath>..\thirdparty\xforms\Xamarin.Forms.Xaml.dll</HintPath>
</Reference>
Run Code Online (Sandbox Code Playgroud)
根据nuget的文档,我将ExcludeAssets属性(和其他测试)添加到以下部分PackageReference of Xamanimation:
<PackageReference Include="Xamanimation">
<IncludeAssets>compile</IncludeAssets>
<!-- <ExcludeAssets>compile</ExcludeAssets> -->
<!-- <PrivateAssets>all</PrivateAssets> -->
<!-- <ExcludeAssets>buildtransitive</ExcludeAssets> -->
<Version>1.3.0</Version>
</PackageReference>
Run Code Online (Sandbox Code Playgroud)
但它们都不起作用!
MSBuild 将始终使用传递依赖项 Xamarin.Forms.4.1.0 并忽略我自己的构建(其中我添加了新类并在主项目中使用它们,因此链接失败表明选择的是旧的)。
那么排除传递依赖的正确方法是什么?