![](/img/trans.png)
[英]Passing /highentropyva- to CSC compiler from MSBuild command-line or project file
[英]How configure csc from msbuild in command line?
在jenkins上構建解決方案(控制台應用程序.net框架4.6.1和.net標准2.0庫)時,我遇到cs0518錯誤(但本地構建沒有問題)並嘗試對其進行修復。 我在日志中找到了/ nostdlib + csc.exe參數,這可能是此錯誤的原因 。
僅適用於.net標准庫的錯誤:
error CS0246: The type or namespace name 'AssemblyTitleAttribute' could not be found
error CS0518: Predefined type 'System.String' is not defined or imported
error CS0246: The type or namespace name 'System' could not be found
error CS0400: The type or namespace name 'System' could not be found in the global namespace
error CS0518: Predefined type 'System.Void' is not defined or imported
...
我在詹金斯上使用MSBuild.exe,並且它使用csc.exe(因此我無法直接修改csc.exe參數)。 我嘗試修改.csproj: <NoStdLib>false</NoStdLib>
,但是/ nostdlib +存在。
如何從MSBuild.exe工具配置 csc.exe或以其他方式解決此問題?
UPD csc參數:
csc.exe /noconfig /unsafe- /checked- /nowarn:1701,1702,1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /define:TRACE;DEBUG;NETSTANDARD;NETSTANDARD2_0 /debug+ /debug:portable /filealign:512 /optimize- /out:obj\Debug\netstandard2.0\yyy.dll /target:library /warnaserror- /utf8output /deterministic+ kkk.cs "C:\Windows\TEMP\.NETStandard,Version=v2.0.AssemblyAttributes.cs" obj\Debug\netstandard2.0\bbb.AssemblyInfo.cs
libs .csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
</Project>
nuget版本: v4.9.3
msbuild版本: 15.9.21.664
我通過更改管道的操作順序來解決問題。 需要:
1) msbuild ... \\restore
2) nuget restore ...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.