Mscorlib not found when creating Xamarin.Android project with CakeBuild

I am in the process of integrating the Xamarin Android project into our CI pipeline. We are already using CakeBuild for other .NET projects, so I also wanted to use it here.

The problem is that when I try to build using Cake, I always get the following error message:

C: \ Program Files (x86) \ MSBuild \ Xamarin \ Android \ Xamarin.Android.Common.targets (406.2): ​​error: failed to load assembly 'mscorlib, Version = 0.0.0.0, Culture = neutral, PublicKeyToken =' . Perhaps this does not exist in the Mono profile for Android? [C: \ [MyProject] .csproj]

Working with buildings in Visual Studio 2015 and using the Visual Studio Developer Command Prompt command line. Because of this, I thought this had something to do with environment variables that are set in VS and through the VS command line. So I made a small batch file:

call "%vs140comntools%vsvars32.bat" Powershell.exe ./build.ps1 -Target Build 

But I get the same error. There is no explicit reference to mscorlib in my projects.

The cake build task is as follows:

 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 TargetFrameworkRootPath because it will not find referenced assemblies unless I install it explicitly.

I'm wondering what else needs to be done to replicate the VS / VS command-line build environment.

+5
source share
1 answer

Are you targeting .NET Standard or are you still using PCL? What does the detailed output look like? It should give you the MSBuild command that is being executed.

call "%vs140comntools%vsvars32.bat" Powershell.exe ./build.ps1 -Target Build -Verbosity Diagnostic

0
source

Source: https://habr.com/ru/post/1275975/


All Articles