You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无NuGet/Visual Studio的IIS服务器上NuGet包操作及程序集报错解决

解决IIS服务器上Microsoft.CodeDom.Providers.DotNetCompilerPlatform程序集加载失败问题

不用安装Visual Studio,用以下两种方法就能解决:

方法一:用独立NuGet CLI安装

  • 下载独立的nuget.exe(直接搜索获取即可),放到服务器任意目录或复制到网站根目录
  • 打开服务器CMD,导航到网站根目录,执行命令:
    nuget install Microsoft.CodeDom.Providers.DotNetCompilerPlatform -Version 1.0.5.0
  • 找到生成的packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.5.0\lib\net45目录,把里面的Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll复制到网站的bin文件夹

方法二:从开发机复制已有的程序集

  • 在开发机的项目packages文件夹里找到对应1.0.5.0版本的程序集文件
  • 直接复制该dll文件到服务器网站的bin目录
  • 检查网站根目录的web.config,确保程序集版本配置正确:
    <system.codedom>
      <compilers>
        <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701"/>
        <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
      </compilers>
    </system.codedom>
    
  • 若web.config有绑定重定向,确认版本匹配:
    <dependentAssembly>
      <assemblyIdentity name="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
      <bindingRedirect oldVersion="0.0.0.0-1.0.5.0" newVersion="1.0.5.0"/>
    </dependentAssembly>
    

最后确保IIS应用池账户拥有网站bin目录的读取权限。

内容的提问来源于stack exchange,提问作者user153923

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 23:15:27