Conditions
- I am trying to migrate from the old project format to the new SDK-style .csproj format. See e.g. https://netexplorer.hashnode.dev/migrating-to-an-sdk-style-project
- .NetFramework 4.8 projects
- I have references, that are not NuGet Packages, not in GAC and not my projects
- In my current case, the pre-installed UFT Developer SDK
- My assumption is, that my issue is unrelated to UFT Developer SDK and that it could be any dependency installed anywhere. Except GAC and NuGet Packages, found by msbuild
Old style format .csproj code
<Reference Include="HP.LFT.Report" />
New style format .csproj code (works with absolute and relative paths)
<Reference Include="HP.LFT.Report">
<HintPath>C:\Program Files (x86)\Micro Focus\UFT Developer\SDK\DotNet\HP.LFT.Report.dll</HintPath>
</Reference>
Why do I need to add the hintPath in the new format? This is a disadvantage, because this path may change over time or from machine to machine. In the old format, somehow msbuild knew how to find my references. Is there another way to tell msbuild how to find these dependencies?
I know that msbuild's search mechanism can lead to wrong build results when it searches for "NewtonsoftJson.dll" basically anywhere. But what is the proper way to add references like this in the new format?
I found an old post with a slightly related issue. I am not sure if years later that is still the proposed solution: Reference GAC assemblies in new CSPROJ format?
By default, .NET will look in the Global Assembly Cache (GAC) and the project's output directory for assemblies.
The official document:
Global Assembly Cache (GAC)
Check whether your package is there.
But in new sdk style this feature be droped.
You can consider the way which suit your situation well based on this:
ResolveAssemblyReference.SearchPaths Property
After all only these seven type can be provided.