| Severity | Warning |
| Reported by | PostSharp |
| Message | The targeting pack for platform "<Platform>" is not installed. This platform may be the one PostSharp runs on, the target framework of the project, or the target framework of one of its references. Install the matching .NET Framework Targeting Pack or .NET Framework Developer Pack. Visit https://bit.ly/ps-targeting-packs for more information. |
Cause
To resolve the types of a .NET Framework assembly, PostSharp reads the reference assemblies of its framework version, which the .NET Framework targeting packs install, usually under %ProgramFiles(x86)%\Reference Assemblies\Microsoft\Framework\.NETFramework. Before it starts the compiler, the build lists the frameworks whose reference assemblies are installed on the machine, with the MSBuild ToolLocationHelper.
PostSharp reports PS0219, once per framework, when it needs the reference assemblies of a framework that this list does not contain. <Platform> is the name of the framework, for example .NETFramework,Version=v4.6.1. It can be:
- the target framework of the project;
- the target framework of a referenced assembly or package, which can be older than that of the project;
- the framework that PostSharp runs on.
PostSharp does not report the message for a missing portable class library (.NETPortable) targeting pack with Visual Studio 2019 or later, which no longer installs it.
Without the reference assemblies, PostSharp can fail to resolve some types later in the build.
This message depends on the targeting packs installed on the machine, so no example can show it.
Resolution
- Install the targeting pack of the framework named in the message. In the Visual Studio Installer, select it under Individual components, as .NET Framework 4.x targeting pack. On a build agent without Visual Studio, install the .NET Framework Developer Pack of this version, from the page that the link of the message opens.
- When the framework is that of an old reference, update the package or the project that provides this reference to a version that targets a framework installed on the machine.
- After the installation, restart Visual Studio, or stop the MSBuild nodes with
dotnet build-server shutdown, and build the project again. A running MSBuild process keeps the list of installed frameworks that it computed first.
See Also
Other Resources
Requirements and Compatibility
Installing PostSharp Into a Project