
I recently ran into a strange issue while working on an Umbraco project running on .NET 10.
The application started just fine, and all Razor views rendered correctly. However, as soon as I made a change to a `.cshtml` file and Razor Runtime Compilation kicked in, the application crashed with the following exception:
InvalidOperationException: Cannot find compilation library location for package 'System.Security.Cryptography.Pkcs'
The strange thing was that the application could load the assembly without any problems. The issue only appeared when Razor Runtime Compilation tried to recompile a modified view.
Possible solution: GenerateRuntimeConfigDevFile
While researching the issue, I found that some developers had managed to resolve similar problems by enabling the following property in their `.csproj` file:
<PropertyGroup>
<GenerateRuntimeConfigDevFile>true</GenerateRuntimeConfigDevFile>
</PropertyGroup>
This generates a `.runtimeconfig.dev.json` file containing additional probing paths used to locate NuGet packages.
fortunately, this was already enabled in my project, so I had to keep
gging.
The actual solution: IIS permissions
It turned out that the issue was related to file system permissions.
The application was running under IIS using a different Windows identity than the user who had restored the NuGet packages.
The solution was to grant the IIS application identity read access to:
C:\Users\{Your User}\.nuget
Once the IIS process had access to the NuGet package cache, Razor Runtime Compilation could resolve its references and everything worked as expected.
No need to manually copy DLLs or mess around with MSBuild targets.
Hopefully, this will save someone else a few hours of debugging!