'InvalidOperationException: Cannot find compilation library location for package 'Microsoft.Build'

My project base on net6.0 was working fine with IIS launch setting but when i added serivce

services.AddRazorPages().AddRazorRuntimeCompilation();

It stop working on IIS but Working on IIS Express and Self host.

enter image description here



Solution 1:[1]

You can try to add this configuration setting to your .csproj file and then republish your site to the server.

<GenerateRuntimeConfigDevFile>true</GenerateRuntimeConfigDevFile>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 samwu