Reputation: 16199
I currently have a Xamarin.Android project that references a .NET Standard 1.1 library that references AutoMapper 5.0.2.
When I try to build this through VSTS I get this error
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1316,2): Error : Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Collections.Specialized, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't exist in the Mono for Android profile?
This solution builds perfectly fine on my local machine and runs in the Android Emulator.
Things I have tried (and none have worked)
<CopyNuGetImplementations>true</CopyNuGetImplementations>
in the Android Project.Also just as a side note, I have .NET Standard 1.1 Libraries all the way through my project, yet I can see from the build log that its using .NET Standard 1.3. Not sure if this will make a difference as I am not sure how the build process manages these standards.
Copying file from "C:\Users\buildguest.nuget\packages\AutoMapper\5.0.2\lib\netstandard1.3\AutoMapper.dll" to "C:\a\1\b/Release\AutoMapper.dll".
Update 1
Just to add that I have tried using Nuget 3.4.4 and Nuget 3.5.0-beta2 in the build agent and while this solved other issues I was having, it didn't resolve the current one I am experiencing.
Update 2
Here is my Android project.json
{
"dependencies": {
"Newtonsoft.Json": "9.0.1"
},
"frameworks": {
"MonoAndroid,Version=v6.0": {}
},
"runtimes": {
"win": {}
}
}
Here is my Portable project.json
{
"supports": {},
"dependencies": {
"AutoMapper": "5.0.2",
"NETStandard.Library": "1.6.0",
"Xamarin.Forms": "2.3.0.107"
},
"frameworks": {
"netstandard1.1": {
"imports": "portable-win+net45+wp8+win81+wpa8"
}
}
}
Update 3: 18th July Just adding more test cases
I can not get even a blank project with an AutoMapper 5.0.2 reference working in the Visual Studio Build step of VSTS. Always the same error as above.
Upvotes: 2
Views: 655
Reputation: 29976
This is caused by the old Xamarin version installed on Hosted Build Agent. The version installed on hosted build agent is "Xamarin for Visual Studio 4.0.3.214". I deployed an on-premise build agent and installed this version, and then queue a build with this build agent, the build will fail with the same error message. After I upgrade the version to the latest 4.1.1.3 version, the build is completed successfully.
So the work around for this issue is deploy your own build agent and install the latest Xamarin on it. And then run your build with this on-premise build agent.
Upvotes: 1
Reputation: 1701
I believe you'll need to add a build step to download the latest NuGet.exe on build and then either call nuget restore via a build script or configure the alternate path of the VSTS NuGet Restore task to use the one you downloaded.
The issue is that the NuGet.exe bundled with VSTS is too old.
You can find the direct download paths here: https://dist.nuget.org/index.html
Upvotes: 1