我设置了一个构建构建脚本(MyBuild.sh),用于为 xamarin 表单应用程序创建 Android apk。
我的要求是,当我提供内部测试构建时,我希望项目 csproj 中的 Microsoft 应用中心崩溃和分析,但是当我进行 PROD 构建时,我不希望项目中的 microsoft 应用中心崩溃和分析
所以在构建脚本中我检查它是否是一个 PROD 构建并尝试从 csproj 中删除应用中心包。
if [ $Env == 'PROD' ]
then
dotnet remove ./Sample/Sample.csproj package Microsoft.AppCenter.Analytics
dotnet remove ./Droid/Sample.Droid.csproj package Microsoft.AppCenter.Crashes
fi
我的问题是,当脚本执行时,它正确地从共享代码中删除了包,但没有从 Droid.csproj 中删除,并且在尝试删除它抛出的包时
info : Removing PackageReference for package 'Microsoft.AppCenter.Crashes' from project './Droid/Sample.Droid.csproj'.
error: The imported project "/usr/local/share/dotnet/sdk/2.1.4/Xamarin/Android/Xamarin.Android.CSharp.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. /Users/george.thomas/Documents/Nov/Candidate/Droid/Sample.Droid.csproj
现在,如果我从 Droid.csproj 中删除 MSBuildExtensionsPath 并运行脚本,它会正确删除包但项目无法构建抛出The target "Build" does not exist in the project
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />