Setup Problems

cant resolve project Dependency

Started by Joreyk on 2,547 views

i have 2 projects,
The Main Project : BFN_DamageCalculator
Second: BfnXmlLibrary ( which is both a cs library AND source generator which uses Roslyns source generator afaik )


PS C:\Users\ixlle\Documents\BFN_DamageCalculator> dotnet build
MSBuild version 17.4.1+9a89d02ff for .NET
  Wiederherzustellende Projekte werden ermittelt...
  Alle Projekte sind für die Wiederherstellung auf dem neuesten Stand.
  BfnXmlReaderLibrary -> C:\Users\ixlle\Documents\BfnXmlReaderLibrary\bin\Debug\netstandard2.0\BfnXmlReaderLibrary.dll
  BFN_DamageCalculator -> C:\Users\ixlle\Documents\BFN_DamageCalculator\bin\Debug\net6.0\BFN_DamageCalculator.dll

Der Buildvorgang wurde erfolgreich ausgeführt.
    0 Warnung(en)
    0 Fehler

Verstrichene Zeit 00:00:02.34

thats the result when i manually build it, so it works and resovles dependencies

when ncrunch wants to build it says
that the using directive to a class in the XmlLibrary cant be resolved "mybe im missing a using directive"...

"using BfnXmlLibrary;" is the line that cant be resolved.. HOW would i miss a dependency here???

the second project is included this way in the csproj
 <ProjectReference Include="..\BfnXmlReaderLibrary\BfnXmlReaderLibrary.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="true"/>
im using 4.15.0.4 and VS22 latest version
so i was able to resolve the issue

the problem is:
ncrunch cant use a project as source generator AND normal project

so you will have to extract all "normal" code of your source generator project and generate that code on the main project
this way you dont need to include it anymore as normal project which results in resolving the conflict.. i wish this would have been fixed..
Hi, thanks for sharing this issue.

I apologise for the frustration here.

Source generator projects are referenced differently inside project XML, and have a very different life-cycle through the build system. We went through some pain to make them work under NCrunch. All the examples I've seen of people building source generator projects involved having the source generator housed within its own project, separate from the rest of the application. In truth, I had no idea it was even possible for them to reside inside standard application projects without referencing issues showing up. If a source generator project is also an application project, this would require all dependencies of the application to potentially be rolled into the compile-time environment, which is a delicate place that we all need to be very careful with.

I am uncertain whether such a structure is intentional from MS's standpoint. Truthfully, I'm not qualified to make such an assessment. I'll make a note to examine this closer from NCrunch's side to see if this is something we can support. From a tooling and dependency management standpoint, I would recommend keeping source generator projects and application code separate in your solution.
This post has been deleted.

Post a reply

Log in to reply.