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

Notification

Icon
Error

Troubleshooting build of non-SDK style project using PackageReference
kalebpederson
#1 Posted : Thursday, February 13, 2020 3:41:35 PM(UTC)
Rank: Member

Groups: Registered
Joined: 2/1/2012(UTC)
Posts: 25
Location: US

Thanks: 5 times
Was thanked: 3 time(s) in 3 post(s)
I'm working with a monolith that uses a traversal build to build a set of projects that are available to us developers in a set of different solution files. I'm now trying to get NCrunch working with these solutions. I was able to include the necessary property files which allowed the build to proceed to the point where it's attempting to restore NuGet packages, at which point it failed.

In investigating, I discovered the following but am not sure how to implement the needed changes in NCrunch:


  • The generated csproj file looks good to me
  • The build fails because no NuGet package references are resolved
  • The NuGet package references aren't resolved because no project.assets.json file is present in the obj directory
  • The build fails against the generated csproj on the command line in the same way the build fails for NCrunch
  • If I do either of the following, the build succeeds:

    • dotnet restore -r win -r win-x64 -r win-x86
    • Add <RuntimeModifiers>win;win-x64;win-x86</RuntimeModifiers> to the first PropertyGroup in the csproj, and then do a nuget restore



So, given that the underlying problem is that I don't have the assets file and once I do have the assets file I need to ensure it's built for the right runtimes, how do I go about getting NCrunch properly configured?

Thanks!

--Kaleb
Remco
#2 Posted : Thursday, February 13, 2020 10:12:04 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 782 times
Was thanked: 1009 time(s) in 961 post(s)
Hi Kaleb,

Thanks for sharing this issue in such detail.

NCrunch should normally detect the project.assets.json file (along with its related 'obj' files) and copy this into the workspace with some minor manipulation. How are your projects structured in regards to project.assets.json? Is the file present? Given your description of this solution, I'm wondering if perhaps there is a customisation of some kind in place that is putting the project.assets.json file in a place where NCrunch isn't able to detect it. Are you able to find the file inside your foreground solution? If not, how is it that your foreground build is able to work without the file present? This may involve some kind of build feature that I don't yet have knowledge of.
kalebpederson
#3 Posted : Friday, February 14, 2020 5:16:59 AM(UTC)
Rank: Member

Groups: Registered
Joined: 2/1/2012(UTC)
Posts: 25
Location: US

Thanks: 5 times
Was thanked: 3 time(s) in 3 post(s)
Remco wrote:
Hi Kaleb,

Thanks for sharing this issue in such detail.

NCrunch should normally detect the project.assets.json file (along with its related 'obj' files) and copy this into the workspace with some minor manipulation. How are your projects structured in regards to project.assets.json? Is the file present?


It is present in the foreground build but not in the NCrunch copy. Out of curiosity, I added the project.assets.json file as an additional Include file for the first project in my solution after which point the build for that project completed. The output is below, which should give you an idea of the structure:

From the Windows Subsystem for Linux:

Code:

$ cd /mnt/c/users/me/AppData/local/NCrunch/20148/3/
$ tree
.
├── Directory.Build.props
├── Directory.Build.targets
├── Solution1
│   ├── Couchbase.AspNet
│   │   ├── ... snip my *.cs files ...
│   │   └── app.config
│   ├── Directory.Build.props
│   └── Analyzer.ruleset
├── Output
│   ├── bin
│   │   └── AnyCPU.Debug
│   │       └── Solution1
│   │           ├── Couchbase.AspNet.dll
│   │           ├── Couchbase.AspNet.dll.config
│   │           └── Couchbase.AspNet.pdb
│   └── obj
│       └── Solution1
│           └── Couchbase.AspNet
│               ├── AnyCPU.Debug
│               │   ├── Couchbase.AspNet.csproj.FileListAbsolute.txt
│               │   ├── Couchbase.AspNet.csprojAssemblyReference.cache
│               │   ├── Couchbase.AspNet.dll
│               │   └── Couchbase.AspNet.pdb
│               └── project.assets.json # manually included through an Include directive
├── Tools
│   └── Build
│       ├── Build.Common.targets
│       └── Build.props
├── _ncrunchreferences
└── build.root


Remco wrote:

Given your description of this solution, I'm wondering if perhaps there is a customisation of some kind in place that is putting the project.assets.json file in a place where NCrunch isn't able to detect it. Are you able to find the file inside your foreground solution? If not, how is it that your foreground build is able to work without the file present? This may involve some kind of build feature that I don't yet have knowledge of.


I'm currently including a number of additional files using the Include directive. They are as follows:


  • Solution1/Directory.Build.props
  • Tools/Build/Build.Common.targets
  • Tools/Build/Build.props
  • build.root


Here's the set of properties that control the various output paths, one of which is likely the culprit:

Code:

  <PropertyGroup>
    <RootBinDir>$(__RootBinDir)\</RootBinDir>
    <RootBinDir Condition="'$(__RootBinDir)'==''">$(BuildRoot)Output\</RootBinDir>

    <!-- This property is used in the various projects to reference built assemblies -->
    <OutBin>$(__OutBin)\</OutBin>
    <OutBin Condition="'$(__OutBin)'==''">$(RootBinDir)bin\$(BuildArch).$(BuildType)\</OutBin>
    
    <BinDir>$(__BinDir)\</BinDir>
    <BinDir Condition="'$(__BinDir)'==''">$(OutBin)$(Component)\</BinDir>
    <BinDir Condition="'$(IsolateComponents)'=='true'">$(BinDir.TrimEnd('\'))\$(MSBuildProjectName)</BinDir>

    <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'==''">$(RootBinDir)obj\$(Component)\$(MSBuildProjectName)</BaseIntermediateOutputPath>
    <__IntermediatesDir Condition="'$(__IntermediatesDir)'==''">$(BaseIntermediateOutputPath)\$(BuildArch).$(BuildType)\</__IntermediatesDir>
    
    <IntermediateOutputPath Condition="'$(IntermediateOutputPath)'==''">$(__IntermediatesDir)\</IntermediateOutputPath>
    <IntDir>$(IntermediateOutputPath)</IntDir>
    
    <OutputPath>$(BinDir)</OutputPath>
    <OutDir>$(OutputPath)</OutDir>
    <OutDir Condition="!HasTrailingSlash($(OutDir))">$(OutDir)\</OutDir>
  </PropertyGroup>


Please let me know what other information I can provide, and thank you for your help troubleshooting this!
Remco
#4 Posted : Friday, February 14, 2020 11:08:58 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 782 times
Was thanked: 1009 time(s) in 961 post(s)
Thanks for providing the extra detail.

It looks to me like you're encountering this issue: https://forum.ncrunch.net/yaf_postst2498_-NET-Core-2-0-Support-with-re-located-build-folder.aspx

Can you try using ProjectName instead of MSBuildProjectName when overriding the BaseIntermediateOutputPath property?
1 user thanked Remco for this useful post.
kalebpederson on 2/19/2020(UTC)
kalebpederson
#5 Posted : Wednesday, February 19, 2020 11:09:08 PM(UTC)
Rank: Member

Groups: Registered
Joined: 2/1/2012(UTC)
Posts: 25
Location: US

Thanks: 5 times
Was thanked: 3 time(s) in 3 post(s)
Remco wrote:
... Can you try using ProjectName instead of MSBuildProjectName when overriding the BaseIntermediateOutputPath property?


Yes, that fixed it!

We did have a mix of non-SDK style projects and with other SDK style projects. About half way through the solution NCrunch failed to build the remaining non-SDK style projects it encountered, but I migrated those over to SDK style projects and then everything picked up and built properly.

Thanks again!

--Kaleb
1 user thanked kalebpederson for this useful post.
Remco on 2/19/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.055 seconds.