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

Notification

Icon
Error

Building asp.net core assembly taking 3 minutes in Ncrunch
johnhamm
#1 Posted : Saturday, May 9, 2020 1:02:54 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/17/2020(UTC)
Posts: 4
Location: United States of America

Was thanked: 1 time(s) in 1 post(s)
I purchased the 4.3.0.13 version of NCrunch and it's working great except for an odd processing time for one of my assembles (my asp.net core library). It takes 2 minutes 49 seconds every time I make a change to one of my tests before I get the results back. Below is the processing queue:



Building the same library in Visual Studio takes 3 to 4 seconds. I am getting a warning in the NCrunch window that may be contributing to the lengthy processing time:

"The Microsoft.AspNetCore.TestHost package contains code that extracts dependency data from the .deps files of user projects in its environment. NCrunch is unable to safely provide this dependency data without copying referenced assemblies to the build output directory. This will have an impact on the performance of NCrunch, as extra work must be done to rebuild this project every time one of its dependencies changes. You may also need to turn on the 'Copy referenced assemblies to workspace' NCrunch project-level configuration setting for other projects in this solution to resolve deeper dependency issues related to the use of this package. 'Copy referenced assemblies to workspace' has been implicitly enabled for this project."

What changes do I need to make to NCrunch or to my source code to make NCrunch usable again in this project?
Remco
#2 Posted : Saturday, May 9, 2020 11:32:58 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi, thanks for sharing this issue.

This specific problem won't be related to the AspNetCore.TestHost package ... this is something else. My guess would be that you have a build step taking an extraordinary long time to work.

Do you have your ASP.NET project set to compile anything other than the DLL? If you clear out all the derived files from your ASP.NET project, then rebuild it in the IDE, what is the normal compile time?

Try setting your NCrunch Log Verbosity to 'Detailed', then examine the build log inside the lower pane of the Processing Queue when the task is selected. Do you see any information about which task may be eating all this time?
johnhamm
#3 Posted : Sunday, May 10, 2020 2:57:15 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/17/2020(UTC)
Posts: 4
Location: United States of America

Was thanked: 1 time(s) in 1 post(s)
Ah - I am using Microsoft's "Angular" template. Although there's nothing explicitly defined in the CSPROJ's build events, the CSPROJ itself contains this markup:
Code:
...
<SpaRoot>ClientApp\</SpaRoot>
...
<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
    <!-- Ensure Node.js is installed -->
    <Exec Command="yarn --version" ContinueOnError="true">
      <Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
    </Exec>
    <Error Condition="'$(ErrorCode)' != '0'" Text="Yarn and Node.js are required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and Yarn, and then restart your command prompt or IDE." />
    <Message Importance="high" Text="Restoring dependencies using 'yarn'. This may take several minutes..." />
    <Exec WorkingDirectory="$(SpaRoot)" Command="yarn install" />
  </Target>

  <Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
    <!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
    <Exec WorkingDirectory="$(SpaRoot)" Command="yarn install --no-progress --non-interactive" />
    <Exec WorkingDirectory="$(SpaRoot)" Command="npm run build -- --prod --progress=false" />
    <Exec WorkingDirectory="$(SpaRoot)" Command="npm run build:ssr -- --prod" Condition=" '$(BuildServerSideRenderer)' == 'true' " />

    <!-- Include the newly-built files in the publish output -->
    <ItemGroup>
      <DistFiles Include="$(SpaRoot)dist\**; $(SpaRoot)dist-server\**" />
      <!--<DistFiles Include="$(SpaRoot)node_modules\**" Condition="'$(BuildServerSideRenderer)' == 'true'" />-->
      <ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
        <RelativePath>%(DistFiles.Identity)</RelativePath>
        <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
      </ResolvedFileToPublish>
    </ItemGroup>
  </Target>



Still, it shouldn't be executing either of these "targets". The first one only runs if there's no installed NPM packages (you run this only once when you first clone the project and it downloads the NPM packages from the internet). The second target only runs when you publish the project (the "npm run build" command compiles all typescript/javascript files and dependencies into a single javascript file among other things).

When I set the log verbosity to Detailed, the Processing Queue window log does show that it is running that second "target" which should only run when we publish the project (running msbuild /t:Publish)

Code:
...
Using "Exec" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
yarn --version
1.22.4
Task "Error" skipped, due to false condition; ('$(ErrorCode)' != '0') was evaluated as ('0' != '0').
Restoring dependencies using 'yarn'. This may take several minutes...
yarn install
yarn install v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@2.1.2: The platform "win32" is incompatible with this module.
info "fsevents@2.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@1.2.9: The platform "win32" is incompatible with this module.
info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "codelyzer > axobject-query@2.1.1" has unmet peer dependency "eslint@^5 || ^6".
[4/4] Building fresh packages...
Done in 330.99s.


I can always comment it out, but I'm not sure how that would affect our pipelines.
Remco
#4 Posted : Sunday, May 10, 2020 7:41:49 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Try adding a condition to the target so that it doesn't run under NCrunch. For example:

<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish" Condition="'$(NCrunch)' != '1'">
johnhamm
#5 Posted : Sunday, May 10, 2020 5:17:45 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/17/2020(UTC)
Posts: 4
Location: United States of America

Was thanked: 1 time(s) in 1 post(s)
That worked - thank you! I had to add it to both of the targets.

This was the final modification needed to the CSPROJ for Microsoft's asp.net core angular template:

  • <Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition="'$(NCrunch)' != '1' And '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
    <!-- Ensure Node.js is installed -->
    <Exec Command="yarn --version" ContinueOnError="true">
    <Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
    </Exec>
    <Error Condition="'$(ErrorCode)' != '0'" Text="Yarn and Node.js are required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and Yarn, and then restart your command prompt or IDE." />
    <Message Importance="high" Text="Restoring dependencies using 'yarn'. This may take several minutes..." />
    <Exec WorkingDirectory="$(SpaRoot)" Command="yarn install" />
    </Target>

    <Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish" Condition="'$(NCrunch)' != '1'">
    <!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
    <Exec WorkingDirectory="$(SpaRoot)" Command="yarn install --no-progress --non-interactive" />
    <Exec WorkingDirectory="$(SpaRoot)" Command="npm run build -- --prod --progress=false" />
    <Exec WorkingDirectory="$(SpaRoot)" Command="npm run build:ssr -- --prod" Condition=" '$(BuildServerSideRenderer)' == 'true' " />

    <!-- Include the newly-built files in the publish output -->
    <ItemGroup>
    <DistFiles Include="$(SpaRoot)dist\**; $(SpaRoot)dist-server\**" />
    <!--<DistFiles Include="$(SpaRoot)node_modules\**" Condition="'$(BuildServerSideRenderer)' == 'true'" />-->
    <ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
    <RelativePath>%(DistFiles.Identity)</RelativePath>
    <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
    </ResolvedFileToPublish>
    </ItemGroup>
    </Target>
1 user thanked johnhamm for this useful post.
Remco on 5/10/2020(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.049 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download