Bundler Transformer Autoprefixer 后处理文件知道物理路径

Bundler Transformer Autoprefixer postprocess file knowing psysical path

我在 ASP.NET MVC 中有一个项目,我想使用 Bundler Transformer Autoprefixer 来处理我的 css 文件。 我的用例有点不寻常,我需要处理来自 "C:\somewhere\style.css". 等物理路径的 css 内容 我想我可以使用 AutoprefixCssPostProcessor class 来这样做,但它允许处理需要文件虚拟路径的资产。 是否可以使用 AutoprefixCssPostProcessor 对此类文件进行后处理?

作品:

    var tempFileVirtualPath = $"/App_Data/Temp/{Guid.NewGuid()}.css"        
    System.IO.File.WriteAllText(Server.MapPath(tempFileVirtualPath), initialCssContent);
    var autoprefixer = new AutoprefixCssPostProcessor();
    var content = autoprefixer.PostProcess(new Asset(tempFileVirtualPath)).Content;
    var absolutePath = "C:\somewhere\style.css";
    System.IO.File.WriteAllText(absolutePath, content);