Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

ncrunch cant build Xamarin.Forms 3.0
danius
#1 Posted : Tuesday, May 8, 2018 4:17:47 PM(UTC)
Rank: Member

Groups: Registered
Joined: 7/17/2013(UTC)
Posts: 15
Location: Ireland

Thanks: 3 times
Was thanked: 2 time(s) in 2 post(s)
After adding XF3 to .net standard 2 project, ncrunch is failing to build.
Building through Visual studio or running msbuild in command prompt is fine.
Downgrading to Xamarin.Forms 2.5 hides this error, but complains about xamarin targets not matching.


VS version 15.7
nCrunch 3.15.0.6

Error below. (Same for all XAML files).


obj\Debug\netstandard2.0\App.xaml (0, 0): Could not load file or assembly 'System.Security.Cryptography.Primitives, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.


Could you point me in the right direction please. It's confusing because VS can build and run apps.
And NCrunch worked before last VS update.
Help appreciated.

Thanks,
Daniel
Remco
#2 Posted : Tuesday, May 8, 2018 10:04:15 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 5,373

Thanks: 705 times
Was thanked: 878 time(s) in 835 post(s)
Hi Daniel,

Thanks for sharing this problem.

Unfortunately, Xamarin in all its forms is not officially supported by NCrunch. Xamarin uses a different build system to other .NET-based projects and no investment has been made to handle its edge cases or keep it updated with changes in the ecosystem. If this project worked for you in older versions of Xamarin, it was coincidental and there is a high chance of downstream problems appearing.

It may be possible to work around these problems through configuration by setting NCrunch in compatibility mode as this will bring NCrunch's build system more in alignment with a standard VS-based build.

If you want to see support extended for this platform you are most welcome to vote for it as a future feature for the product.
danius
#3 Posted : Wednesday, May 9, 2018 7:35:06 AM(UTC)
Rank: Member

Groups: Registered
Joined: 7/17/2013(UTC)
Posts: 15
Location: Ireland

Thanks: 3 times
Was thanked: 2 time(s) in 2 post(s)
Thanks for coming back. I will play with settings and I appreciate that Xamarin is not covered by NCrunch, but this project is actually .net Standard 2.0 that's using Xamarin.Forms nuget package.
It was compiling and running tests against. So I think it's just something in the latest VS build

I will keep digging.

Daniel
Remco
#4 Posted : Wednesday, May 9, 2018 8:06:26 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 5,373

Thanks: 705 times
Was thanked: 878 time(s) in 835 post(s)
Sorry Daniel - I misunderstood in thinking this was actually a Xamarin project.

I do definitely recommend trying the compatibility mode to see if that resolves the problem. It's likely that there is a XAML build step that is malfunctioning because of NCrunch's workspacing. If you can find the reference to this build step in your project you may be able to selectively disable it for NCrunch as it likely isn't required for your automated tests to run.

Sometimes things can go wrong with your project.assets.json file when juggling Nuget references and this can cause resolution issues. Clearing out your obj/bin directories with VS closed can often solve these problems.
danius
#5 Posted : Wednesday, May 9, 2018 10:38:53 AM(UTC)
Rank: Member

Groups: Registered
Joined: 7/17/2013(UTC)
Posts: 15
Location: Ireland

Thanks: 3 times
Was thanked: 2 time(s) in 2 post(s)
Downgrading nugets solved it for me, I will have to come back to this later. Build process and all the .targets logic still escapes my small brain.

gabrielrobert
#6 Posted : Thursday, May 17, 2018 2:10:06 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/17/2018(UTC)
Posts: 2
Location: Canada

Was thanked: 1 time(s) in 1 post(s)
Same problem for me. I tried to clean solution + removing bin/obj/packages, still not working. Even compatibility mode does not solve the problem, unfortunately.
Remco
#7 Posted : Thursday, May 17, 2018 11:24:00 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 5,373

Thanks: 705 times
Was thanked: 878 time(s) in 835 post(s)
I've taken a deeper look at this problem and confirmed that it is a compatibility issue between NCrunch and the Xamarin toolset.

Although this is a netstandard project, adding the reference to Xamarin.Forms includes a range of Xamarin build targets including additional compilers and complex steps. So it's probably safe to say that when you do this, you're actually making a Xamarin project.

In my testing, the problem originated from the XamlCTask. It seems to be possible to selectively disable this for NCrunch builds by applying the _XamlCAlreadyExecuted property to the project, as such:
Code:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
	<_XamlCAlreadyExecuted Condition="'$(NCrunch)' == '1'">true</_XamlCAlreadyExecuted>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Xamarin.Forms" Version="3.0.0.482510" />
  </ItemGroup>

  <ItemGroup>
    <EmbeddedResource Update="Page1.xaml">
      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
    </EmbeddedResource>
  </ItemGroup>

</Project>


Note that this will completely disable the Xamarin compile step when building the projects under NCrunch. Any code depending on the embedded resources produced by this step will likely fail. It may be enough to get your unit tests to function.

Unfortunately this is as far as I can go with providing support in this area. We have performed no development or testing with NCrunch on the Xamarin platform, so we cannot warrant that it will work and cannot invest time in investigating issues on an unsupported platform. If you'd like to see proper support added for Xamarin in future, you are most welcome to vote for it on uservoice.
1 user thanked Remco for this useful post.
danius on 6/11/2018(UTC)
gabrielrobert
#8 Posted : Thursday, May 31, 2018 5:56:37 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/17/2018(UTC)
Posts: 2
Location: Canada

Was thanked: 1 time(s) in 1 post(s)
Many thanks, Remco, you solved my issues.
1 user thanked gabrielrobert for this useful post.
Remco on 5/31/2018(UTC)
BerndU
#9 Posted : Monday, June 11, 2018 11:03:33 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/14/2018(UTC)
Posts: 3
Location: Germany

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
We encountered same issue - and was not fixable with _XamlCAlreadyExecuted cause Xamarin project has removed that from their code ;-(

We have edited as a workaround Xamarin.forms.targets and added there the condition Condition="'$(NCrunch)' == '1'" to the <Target Name="XamlC" ... line.
Works for the moment but is far from practicable.

I added a feature request to support Xamarin in visual studio 2017 - vote

1 user thanked BerndU for this useful post.
danius on 6/11/2018(UTC)
powerdude
#11 Posted : Sunday, July 8, 2018 7:00:52 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/7/2012(UTC)
Posts: 8
Location: detroit

Hello everyone,

Is it possible for NCrunch to update to 4.0.3 versions of dlls or ensure that the references it needs don't have to be present in the project being built? I've tried all of the compatibility options and neither help.
10000
#12 Posted : Monday, July 23, 2018 8:20:47 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 7/9/2018(UTC)
Posts: 2
Location: Poland

Was thanked: 3 time(s) in 1 post(s)
I confirm that NCrunch is compatible with Xamarin.Forms 3.1.0!

All you need to do is add the following line to your csproj:

Code:
<DesignTimeBuild Condition="'$(NCrunch)' == '1'">true</DesignTimeBuild>


Example:
Code:
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>
  <PropertyGroup>
    <DebugType>pdbonly</DebugType>
    <DesignTimeBuild Condition="'$(NCrunch)' == '1'">true</DesignTimeBuild>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Xamarin.Forms" Version="3.1.0.637273" />
    <PackageReference Include="Xamarin.Forms.Maps" version="3.1.0.637273" />
  </ItemGroup>
</Project>
3 users thanked 10000 for this useful post.
Remco on 7/23/2018(UTC), sgrassie on 7/26/2018(UTC), ModernRonin on 7/26/2018(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.085 seconds.