繁体   English   中英

如何在命令行中从msbuild配置csc?

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM