| Severity | Warning |
| Reported by | PostSharp |
| Message | Target framework "<TargetFramework>" is incompatible with the current runtime "<Runtime>". The build may fail due to missing declarations. Consider upgrading the runtime to a compatible version. |
Cause
PostSharp executes the project that it transforms, so its own process must run on a runtime that can run the target framework of the project. PostSharp chooses this runtime from the target framework of the project and from the runtimes installed on the machine: a .NET runtime for a project that targets .NET or .NET Standard, and the .NET Framework installed on the machine for a project that targets .NET Framework.
PostSharp reports PS0280 when the runtime of its process cannot run the target framework, ignoring the platform part such as -windows. <TargetFramework> is the target framework of the project, and <Runtime> is the runtime of the PostSharp process, both with their versions. For example:
- The project targets a version of .NET that is more recent than every .NET runtime installed on the machine, or than the version that the
PostSharpToolsRuntimeVersionMSBuild property requests. - The project targets a version of .NET Framework that is more recent than the one installed on the machine.
PostSharp continues, but the build can fail later, because declarations that the project uses do not exist in the runtime.
This message depends on the runtimes installed on the machine that runs the build, so no example can show it.
Resolution
- Install a runtime that supports the target framework of the project on the machine that runs the build, including the build agents: the .NET runtime of the same or a higher major version, or the .NET Framework version that the project targets. With the .NET SDK, run
dotnet --list-runtimesto see the installed runtimes. - When the project sets the
PostSharpToolsRuntimeVersionMSBuild property, remove it, or set it to a version that supports the target framework. - When the target framework is more recent than the frameworks that your version of PostSharp supports, upgrade PostSharp. See Requirements and Compatibility.
See Also
Other Resources
Requirements and Compatibility
target-frameworks
Well-Known MSBuild Properties