简体   繁体   English

有没有办法在没有 nuget package 的情况下使用 Microsoft.CodeDom.Providers.DotNetCompilerPlatform?

[英]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:我做的步骤是:

  1. Save the files:保存文件:
  • Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll
  • Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll.refresh Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll.refresh
  • Microsoft.CodeDom.Providers.DotNetCompilerPlatform.xml Microsoft.CodeDom.Providers.DotNetCompilerPlatform.xml

of the package to a folder in the project.将 package 复制到项目中的文件夹中。

  1. Removed the nugget package using the NuGet package manager.使用 NuGet package 管理器删除了块 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
  1. Added the following entire to web.config file:在 web.config 文件中添加了以下内容:

 <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=\&quot;Web\&quot; /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.

相关问题 Microsoft.CodeDom.Providers.DotNetCompilerPlatform 的问题 - Problem with Microsoft.CodeDom.Providers.DotNetCompilerPlatform 使用“ Microsoft.CodeDom.Providers.DotNetCompilerPlatform”包时,csc.exe编译时间降低 - csc.exe compilation time degradation when “Microsoft.CodeDom.Providers.DotNetCompilerPlatform” package is used 无法加载文件或程序集“Microsoft.CodeDom.Providers.DotNetCompilerPlatform 或其依赖项之一。” 访问被拒绝 - Could not load file or assembly 'Microsoft.CodeDom.Providers.DotNetCompilerPlatform or one of its dependencies. Access is denied 无法找到CodeDom提供程序类型“Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider ...” - The CodeDom provider type “Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider …” could not be located "找不到 CodeDom 提供程序类型“Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider”" - The CodeDom provider type "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider" could not be located IIS 7无法找到Microsoft.CodDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider DLL - IIS 7 unable to find Microsoft.CodDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider DLL System.CodeDom.Compiler作为nuget-package - System.CodeDom.Compiler as nuget-package 解决 Microsoft NuGet 包引用中的版本冲突的正确方法是什么? - What is the Correct Way to Resolve Versioning Conflicts in Microsoft NuGet Package References? 有什么方法可以在Windows Phone 8中将cloudinarydotnet或Cloudinary用于.net nuget程序包 - Is there any way to use cloudinarydotnet or Cloudinary for .net nuget package in Windows Phone 8 在不安装 Microsoft.ML.OnnxRuntime 的情况下使用 ML.NET model 实例化 class nuget package - Instantiating a class with ML.NET model without installing Microsoft.ML.OnnxRuntime nuget package
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM