[英]csc.exe compilation time degradation when “Microsoft.CodeDom.Providers.DotNetCompilerPlatform” package is used
Our team is currently migrating from C# 5.0 to C# 6.0 syntax so Roslyn compiler should be used instead of the legacy one. 我们的团队目前正在从C#5.0迁移到C#6.0语法,因此应使用Roslyn编译器而不是旧版编译器。
We have to use "csc.exe" as a part of the complex solution compilation process. 我们必须在复杂的解决方案编译过程中使用“ csc.exe”。 Build commands look like this:
生成命令如下所示:
c:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe -nologo -target:library -out:c:\repo\bin64\deb\common.dll @.\rspE0FF.tmp
This command execution takes ~400ms 该命令执行大约需要400ms
"rspE0FF.tmp" content looks like this (it contains much more *.cs files, however, it does not matter, this is reproducible on any set of files): “ rspE0FF.tmp”内容看起来像这样(它包含更多* .cs文件,但是,没关系,这在任何文件集上都可以重现):
"c:\repo\shared\common\estimation\complexjob.cs"
"c:\repo\shared\common\stringdecorator.cs"
"c:\repo\shared\common\tplextensions.cs"
"/reference:mscorlib.dll" "/reference:System.dll" "/reference:System.Data.dll" "/reference:System.Xml.dll" "/reference:System.ServiceModel.Activation.dll" "/reference:System.IdentityModel.dll" "/reference:System.Data.Entity.dll"
When Roslyn compiler is used execution time shouts to ~4100ms Command is the same just csc.exe is called from the package folder: 当使用Roslyn编译器时,执行时间喊到〜4100ms。命令是相同的,只是从包文件夹中调用csc.exe:
c:\NewRepo\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\RoslynLatest\csc.exe -nologo -target:library -out:c:\repo\bin64\deb\common.dll @.\rspE0FF.tmp
We have to build the solution by sequentially running hundreds of csc.exe commands like this. 我们必须通过依次运行数百个csc.exe命令来构建解决方案。 Total compilation time has grown from 2 minutes to 8 minutes.
总编译时间从2分钟增加到8分钟。
Is this performance degradation expected? 是否会导致性能下降?
Any advice on how to tweak this? 关于如何进行调整的任何建议?
The roslyn team does not consider someone invoking csc.exe as part of its perf investigations. roslyn团队不认为有人调用csc.exe作为其perf调查的一部分。 Today you are jitting all of csc.exe on each invocation (see here for more info).
今天,您将在每次调用时将所有csc.exe压缩(有关更多信息,请参见此处 )。
Possible solutions: 可能的解决方案:
NOTE: the msbuild task does this automatically for you, but in your case you will need to do this manually. 注意:msbuild任务会自动为您执行此操作,但是,根据您的情况,您将需要手动执行此操作。
You would need to setup the server (duplicate what this code is doing) and pass /server
to all of your csc calls 您将需要设置服务器(复制此代码的作用),然后将
/server
传递给所有csc调用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.