On a publish, files from a Razor Class Library are actuallty copied to the publish folder, so it makes sense that they are present/working when deployed. But I wouldn’t be surprise if Umbraco requires the physical files. Or another option is that the files are in the wrong path in your package and Umbraco doesn’t pick them up.
An option would be to use a props file. Before Razor Class Libraries, the App_Plugin files had to be copied over to be physically present. This was done with a props file that would copy when over on build. You could use that technique. I