Build/Test Issues

NCrunch is building assemblies by just opening specific files in Visual Studio

Started by DCasado on 2,411 views

Hi,

I noticed that by just opening specific files NCrunch is building this assembly and all dependent.


By just opening a file (configured as an embedded resource)

SomeFile.xlf

Ncrunch is building the assembly and all dependencies.


Is this normal behaviour?



I just send you a bug report.
The opened file is named: PlanningEngineTranslations.de-DE.xlf

Edited

Hi, thanks for posting.

When opening this file, are you opening it in Visual Studio, or an external editor?

NCrunch will respond to changes on the file system. If you're using an external editor and it creates a resource lock file or something else on the file system that is being watched by NCrunch, this can trigger a build.

Edit: If you're using VS to edit the file directly (i.e. as XML), it's possible that loading the file into memory in VS actually causes a change in its structure. VS may be formatting the file differently to how it is physically stored in disk (in binary form). This difference causes NCrunch to naturally trigger on the file. You can probably identify the nature of this change by reading the file as it exists in the NCrunch workspace (right click the project, go to advanced->browse to workspace) and comparing it with its equivalent in your foreground solution using a hex editor/comparison tool.

Edited

I opened it from inside Visual Studio. Opening such files from external editors doesn't trigger NCrunch to build the assembly.

It seems opening the same xlf file a second time doesn't trigger NCrunch to build.

Comparing both files from disk with KDiff3 shows me that they are binary equal.
But comparing content (copied from VS Code or VS 2022) from both files with KDiff3 shows me that they have equal text but are NOT binary equal.

Edited

My guess would be that it's an encoding issue of some kind.

Probably when VS opens the file, it changes the encoding or normalises something.

If you open the file in VS, then save it, then close it and re-open it, does this trigger NCrunch?
I don't understand what's happing here :(

I identified some other embedded files (*.json files) which have the same problem.

I use KDiff3 to compare both files (from solution folder and from NCrunch workspace folder) in two different ways:

[list=1]
  • Opening the files directly by KDiff3 (in menu File -> Open)
    KDiff3 says both files are binary equal

  • Opening the files in an external editor (Notepad++, VS Code, VS 2022)
    "Files A and B have equal text, but are not binary equal."



  • I don't understand why NCrunch is triggering a build although both files are binary equal on disk.
    I don't understand why just opening both files, copy & paste content just change some binary data.

    Edited

    I'm able to reproduce this issue by
    - just creating a new .NET project in Visual Studio
    - adding a JSON file to the project
    - enabling NCrunch on the solution
    -- then every time you close the JSON file
    -- restarting the NCrunch engine
    -- opening the JSON file will trigger NCrunch to build the assembly


    This does not happen on opening .cs files.

    Edited

    Thanks for this, I'll have a look and will see what I can do.
    I just installed the latest official version (v5.12) and now the issue is gone.

    Did you fix anything in the meanwhile?
    Yes, sorry, I forgot to mention here in the thread: v5.12 contains the fix for this issue.

    Post a reply

    Log in to reply.