[英]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.