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

Notification

Icon
Error

Build fails with custom analyzers
FubarCoder
#1 Posted : Sunday, August 2, 2015 11:51:32 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/2/2015(UTC)
Posts: 4
Location: Germany

Thanks: 1 times
Hi,

when I add the StyleCopAnalyzers NuGet package, NCrunch isn't able to build the projects using this analyzer package any more. It complains that it cannot find the metadata for this analyzer assembly.

Kind regards,
Mark
Remco
#2 Posted : Monday, August 3, 2015 5:56:54 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi Mark,

Unfortunately I can't seem to find this package in the nuget directory as expected, so I haven't been able to reproduce the issue myself ... however, my first guess would be that this package is making assumptions about output assemblies being co-located: http://www.ncrunch.net/documentation/considerations-and-constraints_assembly-colocation-assumptions.

I recommend to try turning on the 'Copy referenced assemblies to workspace' for all the projects in your solution - http://www.ncrunch.net/documentation/reference_project-configuration_copy-referenced-assemblies-to-workspace.

Failing this, compatibility mode may help to narrow down the problem - http://www.ncrunch.net/documentation/troubleshooting_compatibility-mode.
FubarCoder
#3 Posted : Monday, August 3, 2015 7:54:00 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/2/2015(UTC)
Posts: 4
Location: Germany

Thanks: 1 times
Hi,

you can find the NuGet package here: https://www.nuget.org/packages/StyleCop.Analyzers/. It's for VS 2015 only and it's a development dependency, which means: It's not part of the build result which also means: No way to copy the referenced assembly, because this assembly isn't referenced in the typical sense. As I previously wrote, it's an "Analyzer" which can be installed as NuGet package and is an extension to the IntelliSense analyzation and the quick action mechanism.

It would really be nice if the analyzers (and I expect to see much more in the future) would work with NCrunch out of the box.

Kind regards,
Mark

EDIT: It's the same problem as described in this forum post, but the proposed "solution" is just a mere workaround. A real fix would be nice.
Remco
#4 Posted : Monday, August 3, 2015 10:14:11 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi Mark,

Thanks for the Nuget link. I'm not sure why this wasn't showing up via a Nuget search, but I've managed to install the package and can confirm that this is a dependency resolution issue that can be solved by including the necessary dependencies using the 'Additional files to include' setting.

Although such an issue is no doubt a cause of frustration when trying to use these sorts of packages with NCrunch, unfortunately it is not possible for NCrunch to resolve these dependencies on its own. NCrunch relies on the build process to identify the dependencies of projects. Where dependencies are not consistently declared inside the build process (as can be the case with certain files accessed via custom-made build tasks), NCrunch has no way to generically identify them.

The only solution would be to deliberately hard-code identification routines into NCrunch that are suited to each package, detailing which files should be included per package. This would be akin to trying programming a VCS with enough intelligence to identify which files were source code and which weren't, by trying to code use-case scenarios for every possible programming language used by the VCS.

Thus the 'workaround' described is in fact the correct solution. By using the 'Additional files to include' setting, you are effectively telling NCrunch which files need to be included in its workspaces. It's perfectly OK to do this. Very often there is no other way for the tool to be informed of which files are needed in a complex build such as this.
berkeleybross
#5 Posted : Monday, September 7, 2015 8:21:39 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 7/28/2015(UTC)
Posts: 6
Location: United Kingdom

Thanks: 4 times
Hi,
I hope I'm not resurrecting a dead thread, but this seems like an appropriate place to post, since I'm having the same "issue"

As FubarCoder says, StyleCop.Analyzers is marked as a development dependency

<package id="StyleCop.Analyzers" version="1.0.0-beta009" targetFramework="net452" developmentDependency="true" />

As you say, adding it manually as an "Additional" dependency works fine, but I'm hoping you could add a setting to NCrunch which turns off analyzers.
Presumably disabling analyzers will speed up build time noticeably?
berkeleybross
#7 Posted : Monday, September 7, 2015 8:22:43 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 7/28/2015(UTC)
Posts: 6
Location: United Kingdom

Thanks: 4 times
Remco
#6 Posted : Monday, September 7, 2015 9:36:28 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
berkeleybross;7698 wrote:
Hi,
I hope I'm not resurrecting a dead thread, but this seems like an appropriate place to post, since I'm having the same "issue"

As FubarCoder says, StyleCop.Analyzers is marked as a development dependency

<package id="StyleCop.Analyzers" version="1.0.0-beta009" targetFramework="net452" developmentDependency="true" />

As you say, adding it manually as an "Additional" dependency works fine, but I'm hoping you could add a setting to NCrunch which turns off analyzers.
Presumably disabling analyzers will speed up build time noticeably?


It's possible to do this by adding a condition to the the analyzer declaration in the project build XML. For example:

<ItemGroup Condition="'$(NCrunch)' != '1'">
<Analyzer Include="..\packages\FileHelpers.Analyzer.1.1.0.0\analyzers\dotnet\cs\FileHelpers.Analyzer.dll" />
</ItemGroup>
1 user thanked Remco for this useful post.
berkeleybross on 9/9/2015(UTC)
berkeleybross
#8 Posted : Wednesday, September 9, 2015 10:21:07 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 7/28/2015(UTC)
Posts: 6
Location: United Kingdom

Thanks: 4 times
Thanks, that seems to work for me.
Would it be possible to make this built into NCrunch? I'm probably being very lazy, but I'd prefer not to have to go through cs-projs for a VS extension (even when it's as awesome as NCrunch)
Remco
#9 Posted : Wednesday, September 9, 2015 11:09:13 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
berkeleybross;7707 wrote:
Thanks, that seems to work for me.
Would it be possible to make this built into NCrunch? I'm probably being very lazy, but I'd prefer not to have to go through cs-projs for a VS extension (even when it's as awesome as NCrunch)


It's already pending in the upcoming 2.17 release :)
1 user thanked Remco for this useful post.
berkeleybross on 9/9/2015(UTC)
huserben
#10 Posted : Thursday, December 17, 2015 9:34:51 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/17/2015(UTC)
Posts: 2

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Hi there

the fix worked well for me for StyleCop.Analyzers Beta 15, but with the version Beta 16+ they have changed how the settings file has to be included:
https://github.com/DotNe.../EnableConfiguration.md

Since this change ncrunch is not able to build anymore. This is what I get in the output:
CSC (0, 0): Source file 'C:\Users\chbehus\AppData\Local\NCrunch\22312\24\project\..\stylecop.json' could not be found.
WARNING - CSC (0, 0): Analyzer 'StyleCop.Analyzers.MaintainabilityRules.SA1402FileMayOnlyContainASingleClass' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
...

I tried with the newest version of ncrunch and it still happens.

Do you have any idea what causes this and how to fix it?
I really would like to be able to to use ncrunch again ;-)

Regards
Remco
#11 Posted : Thursday, December 17, 2015 10:43:07 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi,

If I understand this correctly, this should just be a matter of including the stylecop.json file in the project, or using the 'Additional files to include' setting - http://www.ncrunch.net/documentation/considerations-and-constraints_implicit-file-dependencies.
1 user thanked Remco for this useful post.
huserben on 12/17/2015(UTC)
huserben
#12 Posted : Thursday, December 17, 2015 12:37:47 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/17/2015(UTC)
Posts: 2

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Hi

indeed this seemed to have fixed the problem.
I wasn't aware of the existence of this setting, otherwise I probably would have tried before posting here

Anyway thank you very much for the quick reply and keep up the good work :-)
1 user thanked huserben for this useful post.
Remco on 12/17/2015(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.078 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download