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

Notification

Icon
Error

Directory.build.props - Add a link to certain projects fails
UppSol
#1 Posted : Tuesday, March 1, 2022 9:16:31 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 3/21/2019(UTC)
Posts: 39
Location: Austria

Thanks: 30 times
Was thanked: 7 time(s) in 7 post(s)
Hi,

Please have a look at the directory.build.props

The problem is, that the first ItemGroup (Condition="'$(MSBuildProjectFile)'!='SolutionItems.csproj'">) works as expected, all project files have a link to AssemblyDefaults.cs and CustomDictionary.xml.

The second ItemGroup (Condition="$(MSBuildProjectFile.Contains('Audit.Test.csproj')) And !$(MSBuildProjectFile.Contains('TestHelpers.csproj')) does not work.

NCrunch gives us the following error:
CSC (0, 0): Source file 'C:\Temp\NCrunch\38704\StrauplanManager\Src\PPMS\v\1.06\Upper.PrintProcessingManager.TestHelpers\FluentAssertionsGlobalConfiguration.cs' could not be found.


VS 2022 does work and shows no errors during compilation (also the link shows up correctly), so it seems the second item group is correct.

Why does the first ItemGroup work but not the second one?

Is there a way to tell NCrunch to copy the FluentAssertionsGlobalConfiguration.cs from Upper.PrintProcessingManager.TestHelpers


Here is a simplified version of our directory.build. props
Code:
<PropertyGroup Label="Globals">
     <TargetFramework Condition="!$(MSBuildProjectFile.Contains('.sqlproj'))">net6.0</TargetFramework>
    <Nullable>enable</Nullable>
    <DebugType>Embedded</DebugType>
    <EmbedAllSources Condition="'$(Configuration)' == 'Debug'">True</EmbedAllSources>
    <ImplicitUsings>enable</ImplicitUsings>
 

  <!-- Add links to all projects, except SolutionItems -->
  <ItemGroup Condition="'$(MSBuildProjectFile)'!='SolutionItems.csproj'">
    <Compile Include="$(SolutionDir)\SolutionItems\Common\AssemblyDefaults.cs" Link="Properties\AssemblyDefaults.cs" />
    <Content Include="$(SolutionDir)\SolutionItems\Common\CustomDictionary.xml" Link="Properties\CustomDictionary.xml" />
  </ItemGroup>

  <ItemGroup Condition="$(MSBuildProjectFile.Contains('Audit.Test.csproj')) And !$(MSBuildProjectFile.Contains('TestHelpers.csproj'))">
    <Compile Include="$(SolutionDir)Upper.PrintProcessingManager.TestHelpers\FluentAssertionsGlobalConfiguration.cs" Link="FluentAssertions\FluentAssertionsGlobalConfiguration.cs" />
  </ItemGroup>

</Project>
Remco
#2 Posted : Tuesday, March 1, 2022 11:36:32 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 929 times
Was thanked: 1256 time(s) in 1169 post(s)
Hi, thanks for sharing this issue.

NCrunch has some limitations in what it can handle in the Directory.build.props file. Notably, when it loads your project, it does so under a different project name (i.e. _nCrunchTemp_....). This means that certain MSBuild properties (such as $(MSBuildProjectFile)) will return an unexpected result under NCrunch.

I suspect the reason your file is not being identified is because of the above limitation. I would suggest working around this by finding a different way to identify the projects that need to have this file included, perhaps by introducing a custom property.

Another thing that may work here is to simply include the FluentAssertionsGlobalConfiguration.cs file in your solution-level additional files to include.
1 user thanked Remco for this useful post.
UppSol on 3/2/2022(UTC)
UppSol
#3 Posted : Friday, March 4, 2022 3:27:50 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 3/21/2019(UTC)
Posts: 39
Location: Austria

Thanks: 30 times
Was thanked: 7 time(s) in 7 post(s)
Remco;16022 wrote:
Hi, thanks for sharing this issue.

NCrunch has some limitations in what it can handle in the Directory.build.props file. Notably, when it loads your project, it does so under a different project name (i.e. _nCrunchTemp_....). This means that certain MSBuild properties (such as $(MSBuildProjectFile)) will return an unexpected result under NCrunch.

I suspect the reason your file is not being identified is because of the above limitation. I would suggest working around this by finding a different way to identify the projects that need to have this file included, perhaps by introducing a custom property.

Another thing that may work here is to simply include the FluentAssertionsGlobalConfiguration.cs file in your solution-level additional files to include.


Another question: is it possible to add a project reference via directory.build.props when using NCrunch, or isn't it supported at all?

Br
Remco
#4 Posted : Friday, March 4, 2022 11:24:05 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 929 times
Was thanked: 1256 time(s) in 1169 post(s)
UppSol;16023 wrote:

Another question: is it possible to add a project reference via directory.build.props when using NCrunch, or isn't it supported at all?


Unfortunately we can't support project references inside directory.build.props. This is because the file is outside the scope of our manipulation, and we heavily manipulate the project references when building workspaces for projects.
1 user thanked Remco for this useful post.
UppSol on 3/5/2022(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.038 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download