I'm in the process of integrating a Xamarin Android project into our CI pipeline. We already use CakeBuild for other .NET projects and so I wanted to use it here, as well.
The problem is that I always get the following error message when trying to build with Cake:
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(406,2): error : Could not load assembly 'mscorlib, Version=0.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile? [C:\[myproject].csproj]
Building works in Visual Studio 2015 and using the Visual Studio Developer Command Prompt. Because of this, I was thinking it had something to do with the environment variables that are set in VS and via the VS command prompt. So what I did was make a small batch file:
call "%vs140comntools%vsvars32.bat"
Powershell.exe ./build.ps1 -Target Build
But I'm getting the exact same error. In my projects, there is no explicit reference to mscorlib
.
The Cake build task looks like this:
Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
var settings = new MSBuildSettings()
{
ArgumentCustomization = args =>
{
args = args.Append("/t:PackageForAndroid");
args = args.Append("/p:TargetFrameworkRootPath=\"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\"");
return args;
},
Verbosity = Verbosity.Normal
};
settings.SetConfiguration(configuration);
MSBuild("../myproject.csproj", settings);
});
I had to add the TargetFrameworkRootPath
because it won't find the reference assemblies if I do not set it explicitly.
I'm wondering what else to do to replicate the build environment of VS / VS command prompt.