When I try to build my .csproj
file with dotnet it throws an error, but when I build project at Visual Studio 2019 it succeeds.
I need to build with dotnet
because my Azure pipeline job uses it.
This is the error:
dotnet build MyProject.Mobile.Droid.csproj --configuration Release --force
MyProject.Mobile.Droid.csproj(584,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\3.1.100\\Xamarin\Android\Xamarin.Android.CSharp.targets was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\3.1.100\\Xamarin\Android\Xamarin.Android.CSharp.targets" is correct, and the file exists on disk.
Build FAILED.
(Also as a screenshot.)
If I set the path parameter in my .csproj
to this:
<MSBuildExtensionsPath>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild</MSBuildExtensionsPath>
Then the error changes:
The reference assemblies for MonoAndroid,Version=v1.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks
Any suggestions on how to solve this?
You'll need to use msbuild
(like msbuild MySolution.sln
) to build a Xamarin project today.
You can build the individual netstandard2.x
projects using dotnet build
, however the Mono based platform projects (i.e. the Android and iOS projects) need to be built using msbuild
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With