[英]Problem with Microsoft.CodeDom.Providers.DotNetCompilerPlatform
[英]Is there a way to use Microsoft.CodeDom.Providers.DotNetCompilerPlatform without a nuget package?
我编写了一个 Asp.Net Webforms 应用程序 (aspx)。 该应用程序的目标是 DotNet 4.72。 在应用程序中,我使用元组,因此为了使语法正常工作,我安装了 nugget package Microsoft.CodeDom.Providers.DotNetCompilerPlatform 版本 2.0.0
不起作用的代码如下所示:
public (Person, string, Int) Foo()
{
return (new Person(), "Hello", 42);
}
有人告诉我用程序集参考替换 nugget package,但我找不到让它工作的方法。 我做的步骤是:
将 package 复制到项目中的文件夹中。
结果:我得到语法的构建错误:
error CS1031: Type expected
error CS1519: Invalid token '(' in class, struct, or interface member declaration
error CS1519: Invalid token ',' in class, struct, or interface member declaration
error CS1519: Invalid token ',' in class, struct, or interface member declaration
error CS1519: Invalid token ')' in class, struct, or interface member declaration
error CS1520: Method must have a return type
<system.codedom> <compilers> <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.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=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" /> </compilers> </system.codedom>
然后我得到一个编译错误:
Could not find a part of the path 'C:\Users\myUserName\source\repos\WebSite1\WebSite1\bin\roslyn\csc.exe'.
我可以在不使用 NuGet package 的情况下使用这个 package 吗? 如果是这样,我该怎么做?
提前致谢。
尝试将 dll 文件复制到 bin 目录或在项目中创建一个 lib 文件夹并从那里引用它。 还要确保右键单击 dll 文件-->“属性-->复制到 output 目录-->始终复制”被选中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.