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

Notification

Icon
Error

What triggers a build?
MikeWard
#1 Posted : Friday, July 15, 2016 3:11:27 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 10/19/2011(UTC)
Posts: 33
Location: Ann Arbor, MI

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
I have a Web application written in C# (server) and Typescript (client). I use a single .csproj in this instance.

I've excluded *.js and *.ts files in my NCrunch settings but whenever I edit/save Typescript files, NCrunch builds/tests the C# code.

Is there a way to determine what triggers the NCrunch build?
Remco
#2 Posted : Friday, July 15, 2016 11:32:29 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Hi, thanks for posting.

Normally, NCrunch's Files Excluded From Auto Build setting should restrict the engine from automatically firing off if you make a text change to any file type specified by this setting.

If you are running any other kind of tool that may derive files from your .ts or .cs files, it's possible that this could then trigger the build indirectly.

Does this happen for you on any code that you can share with me? For example, if you create a sample web project with a .cs and .ts file and set these up in the file build exclusions, does the engine work as it should?

Something to be careful with is that this is a project-level config setting (rather than global or solution-wide), so you'll need to apply it to every project you need it to work for.
MikeWard
#3 Posted : Saturday, July 16, 2016 11:29:04 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 10/19/2011(UTC)
Posts: 33
Location: Ann Arbor, MI

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
I agree that it's likely some other tooling changing something and triggering the build. I'll see if I can put together a sample project that illustrates the problem.

Of course, this is totally your fault. If you hadn't made it so easy run tests I wouldn't have written so many and this wouldn't be a problem. :)
Remco
#4 Posted : Saturday, July 16, 2016 11:28:20 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
MikeWard;8981 wrote:
I agree that it's likely some other tooling changing something and triggering the build. I'll see if I can put together a sample project that illustrates the problem.


It could still be NCrunch .. but we won't know until we isolate it. Do let me know if you learn anything more about it.

MikeWard;8981 wrote:

Of course, this is totally your fault. If you hadn't made it so easy run tests I wouldn't have written so many and this wouldn't be a problem. :)


Feels like there's no way I can win :)
MikeWard
#6 Posted : Monday, July 18, 2016 2:32:11 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 10/19/2011(UTC)
Posts: 33
Location: Ann Arbor, MI

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
OK, I figured out the issue.

My folder structure for Typscript is:

\myproject\js\apps\...

The output folder for Typescript is:

\myproject\js\bin\

This is where the outputs for Typescript go (bundle.js and bundle.js.map).

Deleting a file in the \myproject\js\bin folder triggers an NCrunch build.

Could it be my choice of folder name here (bin)?

P.S. Renamed the bin folder to "out". Had to change a bunch of references in the project and build scripts but afterwards, things work as expected. Editing *.ts files does not trigger an NCrunch build/test cycle.
MikeWard
#7 Posted : Monday, July 18, 2016 6:50:10 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 10/19/2011(UTC)
Posts: 33
Location: Ann Arbor, MI

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
Well, this is annoying. It worked for a few hours and now the behavior is back. I can delete the bundle.js file from the out folder and NCrunch builds.
Remco
#8 Posted : Monday, July 18, 2016 10:52:54 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
It looks like something isn't right with the files you have included in the workspace. You'll want to avoid including derived files in the workspace where possible. Check for broad use of the 'Additional files to include' setting.

From memory, the 'Files excluded from auto-build' setting was intended to exclude file edits from the auto build feature. If files are physically removed from the project, this is considered to be a project change rather than a file change (as it impacts the project XML). When a project is changed, NCrunch must rebuild the project regardless of how you are using the setting.
MikeWard
#9 Posted : Tuesday, July 19, 2016 3:38:11 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 10/19/2011(UTC)
Posts: 33
Location: Ann Arbor, MI

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
OK, I see the problem. I need to include the bundle.js and bundle.js.map files in my project so the Visual Studio Publish Profile will use them. It feels like I need a, "consider these files as not part of the solution" option.
Remco
#10 Posted : Tuesday, July 19, 2016 10:51:59 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
MikeWard;8994 wrote:
OK, I see the problem. I need to include the bundle.js and bundle.js.map files in my project so the Visual Studio Publish Profile will use them. It feels like I need a, "consider these files as not part of the solution" option.


There is a way we can do this :)

Where the files are declared inside your Build XML, for example:

<ItemGroup>
<None Include="bundle.js" />
<None Include="bundle.js.map" />
</ItemGroup>

You can exclude them for NCrunch with a condition:

<ItemGroup>
<None Include="bundle.js" Condition="'$(NCrunch)' != '1'" />
<None Include="bundle.js.map" Condition="'$(NCrunch)' != '1'" />
</ItemGroup>

Or alternatively:

<ItemGroup Condition="'$(NCrunch)' != '1'">
<None Include="bundle.js" />
<None Include="bundle.js.map" />
</ItemGroup>

The files will then be detected by the IDE and VS publish, but excluded from NCrunch.

MikeWard
#11 Posted : Wednesday, July 20, 2016 3:29:59 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 10/19/2011(UTC)
Posts: 33
Location: Ann Arbor, MI

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
added to my .csproj:

<ItemGroup Condition="'$(NCrunch)' != '1'">
<None Include="js\out\bundle.js" />
<None Include="js\out\vendor.js" />
<None Include="js\out\vendor.css" />
</ItemGroup>

When I delete js\out\bundle.js NCrunch builds/tests.
Remco
#12 Posted : Wednesday, July 20, 2016 11:45:37 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
MikeWard;9011 wrote:

When I delete js\out\bundle.js NCrunch builds/tests.


Are you making use of the 'Additional files to include' setting at all? Do you know if there are any other references to this file through your project structure?

A good way to test whether NCrunch is still including the file in its workspace is to break this project so it won't build (or copy/produce the .js files in your out dir), then reset the engine. You can then inspect the workspace by going through the Advanced->Browse to workspace option in the Tests Window. Is the file shown in the workspace? If so, that means NCrunch will likely have identified it as a dependency and copied it. If not, there may be something else watching this file that is triggering NCrunch.
MikeWard
#13 Posted : Thursday, July 21, 2016 4:59:15 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 10/19/2011(UTC)
Posts: 33
Location: Ann Arbor, MI

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
Here's a very small VS solution I threw together that demonstrates the issue.

(- BROKEN LINK -)

Once setup (see README.md) you can edit the itunes-app.ts file. Save it and NCrunch builds.

P.S. Just noticed I left a syntax error in Bootstrapper.cs trying your earlier suggestion.
Remco
#14 Posted : Thursday, July 21, 2016 11:11:06 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Thanks for the sample project.

In this case, NCrunch's build is being triggered by the derived files from the typescript auto generation. When you hit save, typescript is automatically running code over the .ts files to generate outputs. Because these outputs are included in your project file, NCrunch is watching them for changes and will trigger when they are modified on disk.

I was able to suppress this behaviour with the following modifications made to the project file:

<ItemGroup>
<Content Include="Content\nancy-logo.png" />
<None Condition="'$(NCrunch)' != '1'" Include="Content\out\bundle.js" />
<None Condition="'$(NCrunch)' != '1'" Include="Content\out\vendor.css" />
<None Condition="'$(NCrunch)' != '1'" Include="Content\out\vendor.js" />
<Content Include="Web.config" />
</ItemGroup>

Edit: I'd like to add that this does actually look like a bug in NCrunch. The 'Files excluded from auto build' is only being applied to changes that come from the IDE, not from the file system. It seems like it should work for both. I've noted this down for review.
1 user thanked Remco for this useful post.
MikeWard on 7/23/2016(UTC)
Remco
#15 Posted : Monday, August 8, 2016 5:04:23 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
v2.25 has just been released, including a fix for the 'Files excluded from auto build' setting not working for file system changes.
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.076 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download