Build/Test Issues

NChrunch 3.22.0.1 has issue with with building.

Started by trondr on 2,599 views

NChrunch 3.22.0.1 has issue with with building.

Repro steps - Visual Studio 15.9.2
1. Create F# Console Project - .NET Framework 4.7.2 -> Visual Studio builds project OK. NChrunch builds project OK.
2. In Nuget Manager add reference to FSharp.Data and FSharp.Data.Xsd -> Visual Studio builds ok. NChrunch no longer builds project. Fails with error:

---
FSC (0, 0): The type provider 'C:\Users\devuser\AppData\Local\NCrunch\9964\1\_ncrunchreferences\FSharp.Data.dll' reported an error: Assembly attribute 'TypeProviderAssemblyAttribute' refers to a designer assembly 'FSharp.Data.DesignTime' which cannot be loaded or doesn't exist. Could not load file or assembly 'file:///C:\Users\devuser\AppData\Local\NCrunch\9964\1\_ncrunchreferences\FSharp.Data.DesignTime.dll' or one of its dependencies. The system cannot find the file specified.
FSC (0, 0): The type provider 'C:\Users\devuser\AppData\Local\NCrunch\9964\1\_ncrunchreferences\FSharp.Data.Xsd.dll' reported an error: Assembly attribute 'TypeProviderAssemblyAttribute' refers to a designer assembly 'FSharp.Data.Xsd.DesignTime' which cannot be loaded or doesn't exist. Could not load file or assembly 'file:///C:\Users\devuser\AppData\Local\NCrunch\9964\1\_ncrunchreferences\FSharp.Data.Xsd.DesignTime.dll' or one of its dependencies. The system cannot find the file specified.

WARNING - FSC (0, 0): FS3005: Referenced assembly 'C:\Users\devuser\AppData\Local\NCrunch\9964\1\_ncrunchreferences\FSharp.Data.dll' has assembly level attribute 'Microsoft.FSharp.Core.CompilerServices.TypeProviderAssemblyAttribute' but no public type provider classes were found
WARNING - FSC (0, 0): FS3005: Referenced assembly 'C:\Users\devuser\AppData\Local\NCrunch\9964\1\_ncrunchreferences\FSharp.Data.Xsd.dll' has assembly level attribute 'Microsoft.FSharp.Core.CompilerServices.TypeProviderAssemblyAttribute' but no public type provider classes were found
---

I experienced this issue initially in 3.15 which is the latest version I have support for. When I tested the latest version I do not currently have support for, 3.22.0.1, this version also have the same issue.

It seems the same issue is not reproducible in a .Net Core Console project.
Hi,

Thanks for sharing this issue. I've reproduced it as you've described.

The problem is caused by FSharp Type Providers being used in the referenced assemblies. Type Providers are a special feature native to FSharp, allowing assemblies to create implicit design-time references to other assemblies. To my knowledge, these references aren't represented inside the build system, so NCrunch is completely unaware of them. We've implemented some handling for type providers before, but this was only inside user code whereas in this case we have them appearing in libraries.

Fixing this properly in NCrunch is something that we don't yet have an acceptable way to do, but this will likely change over the next few months with some planned internal improvements. For the time being, you can work around this problem by introducing assembly references from your FSharp project directly to the missing assemblies. If you want to avoid having these assemblies placed in your normal build output directory and accidentally shipped with your software, you can include them with a condition inside your project file, for example:

<ItemGroup Condition="'$(NCrunch)' == '1'">
<Reference Include="FSharp.Data.Xsd.DesignTime">
<HintPath>..\packages\FSharp.Data.Xsd.1.0.2\lib\net45\FSharp.Data.Xsd.DesignTime.dll</HintPath>
</Reference>
<Reference Include="FSharp.Data.DesignTime">
<HintPath>..\packages\FSharp.Data.3.0.0\lib\net45\FSharp.Data.DesignTime.dll</HintPath>
</Reference>
</ItemGroup>
Thanks Remco!

I have confirmed your workaround. I have added the following (with adjusted hint paths) to my console and test projects. NChrunch is now building and running tests.

<ItemGroup Condition="'$(NCrunch)' == '1'">
<Reference Include="FSharp.Data.Xsd.DesignTime">
<HintPath>$(USERPROFILE)\.nuget\packages\fsharp.data.xsd\1.0.2\lib\net45\FSharp.Data.Xsd.DesignTime.dll</HintPath>
</Reference>
<Reference Include="FSharp.Data.DesignTime">
<HintPath>$(USERPROFILE)\.nuget\packages\fsharp.data\3.0.0\lib\net45\FSharp.Data.DesignTime.dll</HintPath>
</Reference>
</ItemGroup>

Post a reply

Log in to reply.