0

I have a build build script(MyBuild.sh) set up for creating the Android apk for a xamarin forms application.

My requirement is when i give the internal test builds i want the microsoft app center crashes and analytics in the the project csproj but when i take the PROD builds i don't want the microsoft app center crashes and analytics in the project

so in the build script i check whether its a PROD build and tried to remove the app center packages from the 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

My problem is when the script is executed it correctly removes the package from the Shared Code but not from the Droid.csproj and while trying to remove the package it throws

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

Now if i remove the MSBuildExtensionsPath from the Droid.csproj and run the script it correctly removes the packages but the project cant be built throwning The target "Build" does not exist in the project

<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
George Thomas
  • 4,566
  • 5
  • 30
  • 65
  • Why are you using `dotnet` to remove the package(?), use msbuild (or nuget) directly against the project (and assigning the solution dir option) to remove the package and the "imported project" error will go away (`dotnet` does not know anything about Xamarin.Android targets) – SushiHangover Nov 09 '18 at 08:49
  • @SushiHangover Is there any documentation or example that i can refer to? – George Thomas Nov 09 '18 at 10:19
  • https://learn.microsoft.com/en-us/nuget/tools/nuget-exe-cli-reference – SushiHangover Nov 09 '18 at 10:21

0 Answers0