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

Notification

Icon
Error

Upgraded Web Project Not Building
simongh
#1 Posted : Sunday, June 3, 2018 10:25:08 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 10/20/2017(UTC)
Posts: 8
Location: United Kingdom

We have a fairly large solution of 40 projects including unit tests & 3 web projects. I'm trying to upgrade the projects to the latest format, ie changing the tooling version to 15 so we can use ProjectReference for NuGet packages, rather than package.config. But I've run into a problem with NCrunch.

We use the NCrunch Console tool with Teamcity. The solution builds fine on my machine, both by Visual Studio & NCrunch. However on the build server MSBuild works fine, NCrunch does not. It seems to ignore every NuGet reference in the main web project. All the projects build just fine, both locally & in TC. This one web project however fails in TC. The web project primarily contains WebApi & MVC controllers. Every single file reports an error of type or namespace not found related to MVC & WebApi types which come from NuGet.

I've checked the references and they are most definitely there. NCrunch VS plugin builds the project fine. MSBuild builds just fine. NCrunch Console 3.16.1 refuses to. Any ideas what I need to look for?
Remco
#2 Posted : Sunday, June 3, 2018 11:49:32 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 5,328

Thanks: 700 times
Was thanked: 866 time(s) in 824 post(s)
Hi, thanks for sharing this issue.

This feels like it could be a package resolution issue of some kind. If the solution works fine under NCrunch on your workstation, but doesn't work using the console tool on the build server, it could be something in the environment causing this.

If you try running the console tool locally on your dev machine (where I'm assuming the NCrunch VS client works fine), do you experience the problem?

Also, I do recommend moving up to v3.17 when you get the chance.
simongh
#3 Posted : Monday, June 4, 2018 2:02:07 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 10/20/2017(UTC)
Posts: 8
Location: United Kingdom

Upgraded to 3.17, no joy. Ran the the build using the console tool on my machine and it worked. Trying to run the console tool on the build agent by hand also fails - but in a different way. This time csc.exe failed with -532462766

[12:54:00.4344-?-1] Reporting engine execution results
Result: BuildFailure
[12:54:01.575-?-1] Shutting down engine
[12:54:05.4344-Core-29] ERROR (Internal): System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.IO.MemoryStream.ToArray()
at nCrunch.Client.Model.Persistence.ClientModelPersister.(PersistentModelData , DirectoryPath , FilePath )
at nCrunch.Client.Model.Persistence.ClientModelPersister.SaveData(PersistentModelData modelData)
at nCrunch.Client.Model.ClientModelSynchroniser.(SystemDisabledEvent )

[12:54:05.4813-Core-29] Cleaning up workspace: d:\ncrunch\3268\1
Remco
#4 Posted : Monday, June 4, 2018 10:28:37 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 5,328

Thanks: 700 times
Was thanked: 866 time(s) in 824 post(s)
Try the following:

- Wipe the NCrunch cache file as it exists on the build server
- Ensure you have a fresh checkout of the source code on the build server (remove any cached copies)
- Try configuring your build server to use a local user to run the console tool, which has access to the desktop/WindowsGUI
- Ensure the build server has the same exact versions of .NET Core, the .NET Framework and Visual Studio (or matching build tools) installed as your client machine
- From your client machine, copy the contents of your user's .nuget packages directory over to the build server's user profile. This is to make sure you're using the same packages on the build server as you have on your local machine, and everything is aligned

If you still get the OutOfMemory exception after this, try watching the NCrunch.exe process during the run. Does its memory consumption go over the 2GB mark? Do you see any indication to suggest that this is being loaded as an x86 process? (It should normally be x64).

Also, do let me know if you're using distributed processing as there may be other things to check if you have resolution issues on grid servers.
simongh
#5 Posted : Friday, August 10, 2018 6:30:37 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 10/20/2017(UTC)
Posts: 8
Location: United Kingdom

I've finally got a chance to have a look back at this - apologies for taking so long. Work gets in the way.

It still won't work - no nuget packages are found by one of the websites. Deleted all the caches. Fresh checkout. Latest version of the build tools (15.7.5). The NuGet references come from our own private NuGet server, so they are the same.

I'm running the same command that teamcity logs for the build:

C:\BuildAgent\tools\NCrunch_Console_3.18.0.2\ncrunch.exe D:\BuildAgent\work\c4776c547cc10dbc\solution.sln /c d:\ncrunch\global.config.xml /o NCrunchResults

The proj file has been updated the v15 tooling (<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">)

MSBuild runs just before NCrunch to build the artifacts we need to distribute. It compiles the site without problem.

There are 3 web projects in the solution and only one of the fails to build.
simongh
#6 Posted : Friday, August 10, 2018 6:48:55 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 10/20/2017(UTC)
Posts: 8
Location: United Kingdom

hmmm. There's no csproj.nuget.cache, etc being generated for the project. I'm not sure how it build on my machine, because they're not generated there either. But it's the only difference between the proj files that build and those that don't. It's also a problem with the nuget files that is being reproted
simongh
#7 Posted : Friday, August 10, 2018 7:25:41 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 10/20/2017(UTC)
Posts: 8
Location: United Kingdom

It seems this:

ProjectSection(ProjectDependencies) = postProject
{B3541D0B-45F3-483C-9574-428E153C4BB1} = {B3541D0B-45F3-483C-9574-428E153C4BB1}
EndProjectSection

in the solution file for the project along with

<CopyReferencedAssembliesToWorkspace>True</CopyReferencedAssembliesToWorkspace>

in the ncrunch setting allowed it to build on my machine, but not the build server. Having removed both, everything is building as expected. Removing the above line caused the build errors I was seeing on the build server to manifest in Ncrunch on my machine. Removing the section from the solution file allowed VS to create the missing nuget files in the obj folder, which then allowed ncrunch to build.

There was also a

<Target Name="AfterBuild">
<RemoveDir Directories="$(BaseIntermediateOutputPath)" />

That was removing the nuget files and breaking the build
Remco
#8 Posted : Saturday, August 11, 2018 1:20:28 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 5,328

Thanks: 700 times
Was thanked: 866 time(s) in 824 post(s)
simongh;12520 wrote:


There was also a

<Target Name="AfterBuild">
<RemoveDir Directories="$(BaseIntermediateOutputPath)" />

That was removing the nuget files and breaking the build


I think that this would have been the #1 issue here, as it would have caused some very inconsistent behaviour through your build system. You definitely don't want this step happening, neither locally in your NCrunch builds nor when using the console tool.

The generation of the files in the obj directory happens in response to the 'Restore' target run by MSBuild. NCrunch actually won't run this for you and it's recommended that you include it as a special build step. For example:
msbuild MySolution.sln /t:Restore
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.045 seconds.