I've a c# solution with 2 projects in .net framework 4.8: ProjectA and ProjectB.
ProjectA has installed a nuget package, called NugetPackageInternal package that exports a contentFile: NugetPackageInternalFile.
ProjectB depends on ProjectA and needs to use the NugetPackageInternalFile
To use NugetPackageInternalFile in ProjectB I've added this into ProjectB.csproj:
<ItemGroup><Content Include="$(NuGetPackageRoot)\NugetPackageInternal\0.0.1\contentFiles\any\any\NugetPackageInternalFile"><Link>TestData\NugetPackageInternalFile</Link><CopyToOutputDirectory>Always</CopyToOutputDirectory></Content></ItemGroup>
This works but, whenever there is new version of NugetPackageInternal I need to manually change ProjectB.csproj to update the 0.0.X version.
To fix this the only way I found is to install the NugetPackageInternal also into ProjectB and add the GeneratePathProperty=true, so my ProjectB.csproj looks like this:
<ItemGroup><PackageReference Include="NugetPackageInternal" GeneratePathProperty="true"><Version>0.0.2</Version></PackageReference></ItemGroup><ItemGroup><Content Include="$(PkgNugetPackageInternal)\contentFiles\any\any\NugetPackageInternalFile"><Link>TestData\NugetPackageInternalFile</Link><CopyToOutputDirectory>Always</CopyToOutputDirectory></Content></ItemGroup>
This works fine also, but my question would be: Is there a way to refer NugetPackageInternalFile from ProjectA and avoid to install the NugetPackageInternal into ProjectB?
Adding GeneratePathProperty=true into ProjectA PackageReference doesn't work.