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>