Visual Studio Project Item Template can't add reference assembly to .NET 5 projects

Anthony 6 Reputation points

We have a item template that adds one of our DLLs as a reference to the target project. The item can be added to a C# or VB.NET project. I can add the item to a .NET Framework project without any issues. But when I add the item to a .NET 5 project, I get the error "The reference EntityModel could not be added to the project. This wizard will continue to run, but the resulting project may not build properly". I can add the DLL manually to the .NET 5 project without any problems.

    <ProjectItem SubType="" TargetFileName="$fileinputname$.lcm" ReplaceParameters="false" CustomTool="MyModelGenerator">Model.lcm</ProjectItem>

As a test, I did try adding a <HintPath> with a hard coded path to the assembly but that didn't help either.

Any suggestions on what I need to change to avoid getting the error with .NET 5 projects?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
2,438 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,997 questions
No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Karen Payne MVP 29,236 Reputation points Microsoft MVP

    If you are trying to use .NET Core 5 say with .NET Framework 4.8 that is not possible. Consider if possible using net standard 2.0 rather than .NET Core 5 and note net standard over 2.0 will not compile with .NET Framework 4.8.

    So you have a decision to make as per above.