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

Notification

Icon
Error

NCrunch fails to build a project with NSwag build target
joescharf
#1 Posted : Saturday, August 8, 2020 5:31:57 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 10/20/2019(UTC)
Posts: 2
Location: Australia

Thanks: 1 times
NCrunch fails to build a project that includes a NSwag build step.

I don't know much about the ms build process. Perhaps you can suggest how I may proceed.

thanks

joe



To reproduce:
  • Download repository at https://github.com/jasontaylordev/CleanArchitecture.git, e1abd2eec1e55d00b0abeb49dd9f7285310ca26d 4 Aug 2020.
    Install latest .net core sdk
    Install latest Node.js LTS
    Open solution in VS2019 16.6.5
    Build solutions (the first Node build takes a few minutes)
    Enable NCrunch.
    Ncrunch starts building (this takes a couple of minutes) but fails to build the WebUI project



To fix:
  • Comment out the NSWag target from the WebUI.csproj file
    Close VS2019
    Reopen solution in VS2019
    Rebuild the solution
    NCrunch now builds the WebUI project successfully.



Failure output from NCrunch
Quote:
EXEC (0, 0):
The command "dotnet "C:\Users\joe\.nuget\packages\nswag.msbuild\13.7.0\build\../tools/NetCore31/dotnet-nswag.dll" run /variables:Configuration=Debug" exited with code -1.
Remco
#2 Posted : Sunday, August 9, 2020 4:06:41 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 795 times
Was thanked: 1050 time(s) in 1000 post(s)
Hi, thanks for sharing this issue.

The problem here is that the command line call to NSwag is causing runtime code within user assemblies to be executed at build time. There is no way we will feasibly get such a structure to run reliably under NCrunch.

To work around this, you need to disable your custom NSwag build target for NCrunch builds. To do this, simply extend the condition on the target to take NCrunch into consideration, as such:

<Target Name="NSwag" AfterTargets="Build" Condition="'$(Configuration)' == 'Debug' AND '$(NCrunch)' != '1'">
<Copy SourceFiles="@(Reference)" DestinationFolder="$(OutDir)References" />
<Exec Command="$(NSwagExe_Core31) run /variables:Configuration=$(Configuration)" />
<RemoveDir Directories="$(OutDir)References" />
</Target>
1 user thanked Remco for this useful post.
joescharf on 8/9/2020(UTC)
joescharf
#3 Posted : Sunday, August 9, 2020 4:20:14 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 10/20/2019(UTC)
Posts: 2
Location: Australia

Thanks: 1 times
Hi Remco,

The work around fixed my problem.

Thanks

Joe
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.057 seconds.