[英]Is there a way to use Microsoft.CodeDom.Providers.DotNetCompilerPlatform without a nuget package?
I've written an Asp.Net Webforms app (aspx).我编写了一个 Asp.Net Webforms 应用程序 (aspx)。 The app is targeting DotNet 4.72.该应用程序的目标是 DotNet 4.72。 In the app, I'm using Tuples, so in order for the syntax to work, I've installed the nugget package Microsoft.CodeDom.Providers.DotNetCompilerPlatform version 2.0.0在应用程序中,我使用元组,因此为了使语法正常工作,我安装了 nugget package Microsoft.CodeDom.Providers.DotNetCompilerPlatform 版本 2.0.0
the code that is not working looks like this:不起作用的代码如下所示:
public (Person, string, Int) Foo()
{
return (new Person(), "Hello", 42);
}
I was told to replace the nugget package with assembly reference, and I can't find a way to make it work.有人告诉我用程序集参考替换 nugget package,但我找不到让它工作的方法。 The steps I did are:我做的步骤是:
of the package to a folder in the project.将 package 复制到项目中的文件夹中。
Result: I get build errors for the syntax:结果:我得到语法的构建错误:
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>
Then I got a compile error:然后我得到一个编译错误:
Could not find a part of the path 'C:\Users\myUserName\source\repos\WebSite1\WebSite1\bin\roslyn\csc.exe'.
Can I use this package without using NuGet package?我可以在不使用 NuGet package 的情况下使用这个 package 吗? If so, how do I do this?如果是这样,我该怎么做?
Thanks in advance.提前致谢。
try copy dll files to bin directory or create a lib folder in project and reference it from there.尝试将 dll 文件复制到 bin 目录或在项目中创建一个 lib 文件夹并从那里引用它。 Also make sure to right click dll file --> "properties --> copy to output directory --> copy always" is selected还要确保右键单击 dll 文件-->“属性-->复制到 output 目录-->始终复制”被选中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.