简体   繁体   English

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

[英]How configure csc from msbuild in command line?

I have cs0518 error when build solution (console app .net framework 4.6.1 and .net standard 2.0 library for it) on jenkins(but local build without problems) and try fix it. 在jenkins上构建解决方案(控制台应用程序.net框架4.6.1和.net标准2.0库)时,我遇到cs0518错误(但本地构建没有问题)并尝试对其进行修复。 I found /nostdlib+ csc.exe param in log and it can be a reason of this error. 我在日志中找到了/ nostdlib + csc.exe参数,这可能是此错误的原因

Errors only for .net standard library: 仅适用于.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 
...

I use MSBuild.exe on jenkins, and it uses csc.exe(so I can not modify csc.exe params directly). 我在詹金斯上使用MSBuild.exe,并且它使用csc.exe(因此我无法直接修改csc.exe参数)。 I tried modify .csproj: <NoStdLib>false</NoStdLib> , but /nostdlib+ exists yet. 我尝试修改.csproj: <NoStdLib>false</NoStdLib> ,但是/ nostdlib +存在。

How I can configure csc.exe from MSBuild.exe tool or resolve this problem in different way? 如何从MSBuild.exe工具配置 csc.exe或以其他方式解决此问题?

UPD csc params: 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: libs .csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>
</Project>

nuget version: v4.9.3 nuget版本: v4.9.3

msbuild version: 15.9.21.664 msbuild版本: 15.9.21.664

I fixed problems by changing pipeline's operation order. 我通过更改管道的操作顺序来解决问题。 Needed: 需要:

1) msbuild ... \\restore 1) msbuild ... \\restore

2) nuget restore ... 2) nuget restore ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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