使用Roslyn(csc.exe)定位.NET 3.5时手动编译C#
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了使用Roslyn(csc.exe)定位.NET 3.5时手动编译C#,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2949字,纯文字阅读大概需要5分钟。
内容图文
![使用Roslyn(csc.exe)定位.NET 3.5时手动编译C#](/upload/InfoBanner/zyjiaocheng/804/f92ef55864de4800b79cc1ef8b472528.jpg)
我正在使用csc / csc2.exe手动编译应用程序.我需要引用.NET 3.5 dll,但似乎编译器自动添加了.NET 4.0 dll(导致冲突).
我手动引用了所需的mscorlib版本和其他系统dll. Visual Studio中的编译成功,但是从命令提示符手动编译同一响应文件失败.
/nostdlib+
/platform:AnyCPU
/errorendlocation
/highentropyva-
/reference:"C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll"
/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll"
/reference:"C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll"
/debug+
/debug:full
/out:obj\Debug\Target.exe
/ruleset:"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\\Rule Sets\MinimumRecommendedRules.ruleset"
/target:exe
/utf8output
Program.cs Properties\AssemblyInfo.cs
我为每个引用的程序集收到以下错误:
error CS1703: Multiple assemblies with equivalent identity have been imported: 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.dll' and 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll'. Remove one of the duplicate references.
是什么导致编译器包含.NET 4.0 dll,我该怎么做才能阻止它包含它们?
更新:
我不能使用MSBUILD,因为我已经有一个应用程序的响应文件(不是项目文件).该应用程序使用了过时的编译器版本,我正在尝试用支持C#6的新版本替换它们的编译器.
我已经使用Mono MCS编译器成功完成了这项任务,但无法与Roslyn一起工作.我不能使用MCS编译器,因为它还不支持所有C#6功能.
使用MSBUILD的唯一方法是将响应文件解析回C#项目文件.这对我来说似乎过度工程化了.
解决方法:
将/ noconfig选项添加到命令行,它应该按预期工作.
The /noconfig option tells the compiler not to compile with the
csc.rsp file, which is located in and loaded from the same directory
as the csc.exe file.The csc.rsp file references all the assemblies shipped with the .NET
Framework. The actual references that the Visual Studio .NET
development environment includes depend on the project type.
csc.rps的常用内容(v4.0.30319):
/r:Accessibility.dll
/r:Microsoft.CSharp.dll
/r:System.Configuration.dll
/r:System.Configuration.Install.dll
/r:System.Core.dll
/r:System.Data.dll
/r:System.Data.DataSetExtensions.dll
/r:System.Data.Linq.dll
/r:System.Data.OracleClient.dll
/r:System.Deployment.dll
/r:System.Design.dll
/r:System.DirectoryServices.dll
/r:System.dll
/r:System.Drawing.Design.dll
/r:System.Drawing.dll
/r:System.EnterpriseServices.dll
/r:System.Management.dll
/r:System.Messaging.dll
/r:System.Runtime.Remoting.dll
/r:System.Runtime.Serialization.dll
/r:System.Runtime.Serialization.Formatters.Soap.dll
/r:System.Security.dll
/r:System.ServiceModel.dll
/r:System.ServiceModel.Web.dll
/r:System.ServiceProcess.dll
/r:System.Transactions.dll
/r:System.Web.dll
/r:System.Web.Extensions.Design.dll
/r:System.Web.Extensions.dll
/r:System.Web.Mobile.dll
/r:System.Web.RegularExpressions.dll
/r:System.Web.Services.dll
/r:System.Windows.Forms.Dll
/r:System.Workflow.Activities.dll
/r:System.Workflow.ComponentModel.dll
/r:System.Workflow.Runtime.dll
/r:System.Xml.dll
/r:System.Xml.Linq.dll
内容总结
以上是互联网集市为您收集整理的使用Roslyn(csc.exe)定位.NET 3.5时手动编译C#全部内容,希望文章能够帮你解决使用Roslyn(csc.exe)定位.NET 3.5时手动编译C#所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。